MATLAB Answers

Publish / send message on ROS topic to ROS Master

7 views (last 30 days)
Benedikt Theimer
Benedikt Theimer on 22 Oct 2020
Commented: Cam Salzberger on 26 Oct 2020
How is it possible to publish the content of a string in a ROS topic? Unfortunately only the topic is created, but the content (msg.Data = 'xyz') is not transmitted. The instructions on mathworks ( to send messages on ROS does not produce any result.
Using 30 days trail version of MATLAB 2020b with Robotics toolbox.
Thanks in advance!
Best Regards,
Cam Salzberger
Cam Salzberger on 26 Oct 2020
The most important variable to set is ROS_IP on your non-MATLAB machine, in every terminal that you are using ROS from. It's also important that you are using the correct IP address, as some machines have multiple network interfaces. You could post the results of running "ifconfig" (with the actual addresses "X"ed out), and we could point to which is the correct network interface.
Addtionally, firewalls can be an issue for ROS communication. Check the other suggested fixes in those two links Ameer posted, as well as here.
Also, what version of ROS are you using on your Linux machine? I assume the message type you are testing with is std_msgs/String, but if that is not correct, also please post the message type you are using.

Sign in to comment.

Answers (1)

Ameer Hamza
Ameer Hamza on 22 Oct 2020
Edited: Ameer Hamza on 22 Oct 2020
I faced exactly the same problem a while ago. I don't remember exactly now, but the problem was related to not setting the ROS_MASTER_URI and ROS_IP on the master node running on Linux? Have you properly set these variables on both machines? You will find information in the following answers helpful
Ameer Hamza
Ameer Hamza on 23 Oct 2020
What about setting these variables on your Linux machine.

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!