Why can't I publish ROS messages using simulink?

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

Antworten (2)

Josh Chen
Josh Chen am 24 Apr. 2023

0 Stimmen

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

2 Kommentare

RAI
RAI am 25 Feb. 2026
i am also facing same problem in 2025b version.
RAI
RAI am 26 Feb. 2026
trun off the windows defender its blocking the ros data. control panel> windows defender> off

Melden Sie sich an, um zu kommentieren.

RAI
RAI am 26 Feb. 2026

0 Stimmen

trun off the windows defender its blocking the ros data. control panel> windows defender> off

Kategorien

Produkte

Version

R2020b

Gefragt:

am 21 Apr. 2023

Beantwortet:

RAI
am 26 Feb. 2026

Community Treasure Hunt

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

Start Hunting!

Translated by