Rosanswers logo

Hi All,

I'm trying to use the ROS-Matlab I/O package to publish and subscribe to topics from a roscore on a networked machine. I have gone through the network setup, and this is the current state of the whole system:

Machine A (running ROS)

The /etc/hosts file lists localhost The-Master The-Doctor

The relevant (as far as I know) environment variables are:



Machine B (running Matlab)

The /etc/hosts file lists localhost The-Doctor The-Master

The relevant environment variables are:





I can ping the between the two machines, both by IP and by name. I can netcat between both of them just fine. Using rosmatlab, I can create a node on The-Doctor which is seen by The-Master. I can create a publisher which is also seen by The-Master. The-Doctor can publish data to The-Master and it shows up just fine when I do a "rostopic echo" on The-Master.

The problem is: when The-Doctor tries to subscribe to a topic from The-Master, the callback function defined in the Matlab code never gets called. Just to make sure that I wasn't making any major mistakes, I ran the rosmatlab_basic.m example included with ROS-Matlab I/O, and the subscribers in that example don't work either (even though the publishers do).

Any idea on what might be wrong? I'm running Matlab R2013b, but I have tested this with multiple versions, both Windows and Ubuntu. I see the same problem which leads me to believe that somewhere along the line I'm doing something wrong in the network setup and am too dumb to know what.

Please help :\

Originally posted by Jari on ROS Answers with karma: 112 on 2014-04-20

Post score: 1


1 Answer 1


Rosanswers logo

I found the solution here. http://www.mathworks.com/matlabcentral/answers/119559-why-is-the-ros-subscriber-callback-in-matlab-not-triggered-when-messages-are-published-from-an-exter

Configure the two hosts precisely according to the instructions and it works for me.

Originally posted by redsuncheng with karma: 36 on 2014-04-21

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by Jari on 2014-04-22:
It works. The subscribers can see the data now. What I don't understand is why my setup wasn't working. From all indications I did not have any name resolution problems. Interestingly enough, when I go back to the named approach now, Matlab throws an error whenever data is available for a subscriber

Comment by Jie Sky on 2014-12-13:
hello! I want to realize the communication between turtlebot and MATLAB,but i do not know where to download ros-matlab.Can you tell me where i can download it?thank you very much!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.