Why can't I publish ROS messages using simulink?

조회 수: 8 (최근 30일)
zr Ling
zr Ling 2023년 4월 21일
답변: Josh Chen 2023년 4월 24일
Hi,
I am testing exchange data between simulink and ROS. I have a laptop running a ROS project called tuetlesim, which is a example project of ROS. In this ROS project, a turtle will move according to the command from the topic called /turtle1/cmd_vel . The type of the message of the topic is geometry_msgs/Twist.
What I want to do is using simulink to publish the message and move the turtle. So,
Firstly, I set my network in matlab and ubuntu
% in matlab
setenv('ROS_MASTER_URI','http://192.168.1.250:11311')
% in ubuntu ~/.bashrc
export ROS_IP=192.168.1.250
Secondly, I test the network in matlab. It works and can show all topics
rosinit
rostopic list
Finally, I create a model as below. In this model, I also use a subscriber to subscribe the topic called /turtle1/pose, which contains the position(X/Y) of the turtle. This subscriber work perfectly. However, the publisher doesn't work.
configuration of publisher
In ubuntu, I check the node by rqt_graph. It shows that simulink successfully connect to the master.
However, there is no message can be receive from the /turtle1/cmd_vel.
Can anyone give me any hint about why this behaviour?
Thank you very much in advance,
Regards,
Liam

답변 (1개)

Josh Chen
Josh Chen 2023년 4월 24일
Hello Liam,
When this kind of "only one way communication available" happens, it usually has something to do with the setting of environment variables or virtual machine.
Some ideas of troubleshooting for your reference:
  1. Are you able to receive message sent from MATLAB instead of Simulink?
  2. Check the setting for ROS_MASTER_URI and ROS_IP for both MALTAB and Ubuntu (See more details in this post)
  3. Are you using VMware Player? If yes, what kind of Network connection did you pick? We always find "NAT" is a good option.
  4. In general, you could probably just start ROS Master in VM, and use "rosinit('<ip_address>')" in MATLAB to make the connection. Please feel free to reach out to our technical support team if you are still facing this issue.
Hope this helps,
Thanks,
Josh

카테고리

Help CenterFile Exchange에서 Publishers and Subscribers에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by