Publish / send message on ROS topic to ROS Master

10 views (last 30 days)
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 (https://www.mathworks.com/help/ros/ref/send.html) 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,
Benedikt
  2 Comments
Benedikt Theimer
Benedikt Theimer on 22 Oct 2020
Is it a problem to send/publish it with MATLAB running on windows and read the topic's content with Linux?
But the reverse order works (Publish message from ROS Master running on Linux, and receive this message in MATLAB running on Windows).
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.
-Cam

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
  2 Comments
Benedikt Theimer
Benedikt Theimer on 23 Oct 2020
Hello Ameer,
thank you so much for your help, your fast answer and adding these links!
Yes, I tried these settings on the machine and this on MATLAB:
setenv('ROS_MASTER_URI','http://ROS-Master-PC-IP')
setenv('ROS_IP','MATLAB-PC-IP')
rosinit(ROS-Master-PC-IP)
Unfortunately it doesn't work yet.
Ameer Hamza
Ameer Hamza on 23 Oct 2020
Edited: Ameer Hamza on 23 Oct 2020
What about setting these variables on your Linux machine.

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!