- Are you able to receive message sent from MATLAB instead of Simulink?
- Check the setting for ROS_MASTER_URI and ROS_IP for both MALTAB and Ubuntu (See more details in this post)
- Are you using VMware Player? If yes, what kind of Network connection did you pick? We always find "NAT" is a good option.
- 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.
Why can't I publish ROS messages using simulink?
5 次查看(过去 30 天)
显示 更早的评论
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1362843/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1362848/image.png)
![configuration of publisher](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1362853/configuration%20of%20publisher.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1362858/image.png)
In ubuntu, I check the node by rqt_graph. It shows that simulink successfully connect to the master.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1362863/image.png)
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
0 个评论
回答(1 个)
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:
Hope this helps,
Thanks,
Josh
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Publishers and Subscribers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!