Why does the ROS MATLAB connection via topic receive command (ROS-Toolbox) not work in R2020a but in R2020b

16 views (last 30 days)
Since we were using the trial version of MATLAB R2020b we could connect MATLAB with a ROS topic and receive newly published data with the receive command of the ROS toolbox.
However the same code does not work with MATLAB R2020a (we use a licensed version now). We do see the topic with rostopic list. We can also see incoming data with rostopic echo /topic within MATLAB. Initially we used a custom message format but we also checked it with a simple String. Furthermore we tried the receive command with and without timeout, makes no difference.
We are using ROS Kinetic (LINUX UBUNTU) and as mentioned before MATLAB R2020a (LINUX UBUNTU). We ran the software on two different PCs and also tried it on one single PC.
While debugging the program pointer is not jumping over the receive command.
We use the following simple test script:
rosshutdown;
setenv('ROS_MASTER_URI','http://XXX.XXX.XXX.109:11311')
setenv('ROS_IP','XXX.XXX.XXX.149')
rosinit('XXX.XXX.XXX.109');
sub = rossubscriber('/test_state', 'std_msgs/String');
a = receive(sub);
b = assembly_state.Data;

Answers (1)

Cam Salzberger
Cam Salzberger on 30 Nov 2020
Edited: Cam Salzberger on 30 Nov 2020
Hello Oliver,
The most common reason for being able to see rostopic, but not being able to receive messages from one or other other side of the communication is not having the ROS_IP environment variable set correctly on the non-MATLAB machine. See this post for more details.
Also as an FYI, if you call rosinit with an IP address, that overrides the ROS_MASTER_URI environment variable. It's not a problem, just wanted you to know the behavior.
I'm not sure why it would work in R2020b but not in R2020a. There was a big change to the back-end of ROS in R2020b (using roscpp instead of rosjava as the core, and updating to Melodic while R2020a uses Indigo). If you were using messages that changed definition between versions, that could cause this issue too, but std_msgs/String isn't one of those. It could be that the way ROS sets up the communication on the back-end has been updated in Melodic, and is therefore able to work around the lack of a ROS_IP setting.
-Cam
  1 Comment
Oliver Heineking
Oliver Heineking on 30 Nov 2020
Hello, thank you very much for your reply! We already got the solution, we just had to update and upgrade the UBUNTU system and now it works fine :)

Sign in to comment.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!