MATLAB Answers

Receive message from ROS to Matlab robotics toolbox

13 views (last 30 days)
Good morning everyone,
I am getting started with ros using matlab. I use a macbook which i installed matlab in, and i simultaneously use a Vm runnning on my mac as a second machine.
I am using Vmware fusion in which i installed Ubuntu and ROS on it. Gazebo is installed and i am using turtlebot3 package and wanted to receive data from the /scan topic after launching gazebo with this command "roslaunch turtlebot3_gazebo turtlebot3_world.launch".
After using the rosinit command on matlab side, the connection seems to be working pretty much fine. Here is the basic matlab code i am using :
scanSub = rossubscriber('/scan')
laserMsg = receive(scanSub,2);
i get this message error : Error using ros.Subscriber/receive (line 294)
The function did not receive any data and timed out.
Error in test (line 4)
laserMsg = receive(scanSub,2);
also, by using the command "rostopic echo scan" i was able to see that messages were indeed published by the scan topic.
When i used the command "rostopic info /scan" i saw also that "/matlab_global_node_46314 (http://172.16.115.1:52998/)" was a suscriber of the scan topic
Moreover, i also tried to ad those lines "export ROS_MASTER_URI=http//192.168.1.28:11311" and "export ROS_HOSTNAME=192.168.1.28" on my bashrc. but as soon as i had them i get this error message while trying to luch gazebo or even roscore commands i get this error as well : "RLEception : Unable to contact my own server at [http://192.168.0103:41401/].
This usually means that the network is not configured properly.
a common cause is that the machine cannot ping itslef. please check ofr errors by running :
ping 192.168.0.103
for more tips, please use
the traceback for the execption was written to the log file

  0 Comments

Sign in to comment.

Accepted Answer

Cam Salzberger
Cam Salzberger on 27 Apr 2020
Edited: Cam Salzberger on 27 Apr 2020
Hello Jeannot,
The most common cause I've seen for two systems being nominally connected (able to use rostopic and other introspection commands to see reciprocol topics) but not able to communicate at least in one direction is that the side publishing the data is not advertising itself correctly. I believe you are trying to address this appropriately by setting the ROS_HOSTNAME environment variable but, as you said, it's not working out.
I can suggest a few things based off of what you said:
  • I believe you have a typo in your ROS_MASTER_URI setting (export ROS_MASTER_URI=http//192.168.1.28:11311"). There should be a colon after http.
  • The ROS_MASTER_URI should only be used by the node to find where the master is located. If your turtlebot node is able to be run without setting this, it is likely finding your master fine already, so you could try excluding this from your bashrc file. Or just run this in the terminal that launches the node and not in the one that starts the roscore.
  • Try setting ROS_IP to the IP address, rather than ROS_HOSTNAME. It theoretically shouldn't matter, but since you are advertising an IP rather than a host, it makes sense. Also, do not set both variables.
  • Make sure that this IP address is correct for the right network interface on your VM. I've typically seen 4 network interfaces show up in the VM interface (though I don't have as much experience with Mac and VMware Fusion). Two are for VM communication with the host, one for standard internet interface (eth0 or similar) and one the loopback interface, if I remember correctly. I think the standard internet interface is the one you want to advertise, though you can try them all. The IP should match whatever IP is printed as the Master address when roscore starts.
There is a similar question with additional information here as well. Hope this helps!
-Cam

  0 Comments

Sign in to comment.

More Answers (0)