0
$\begingroup$

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 127.0.0.1 localhost 127.0.1.1 The-Master 192.168.2.7 The-Doctor

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

$ROS_MASTER_URI=http://The-Master:11311/

$ROS_HOSTNAME=The-Master

Machine B (running Matlab)

The /etc/hosts file lists

127.0.0.1 localhost

127.0.1.1 The-Doctor

192.168.2.3 The-Master

The relevant environment variables are:

$ROS_MASTER_URI=http://The-Master:11311/

$ROS_HOSTNAME=The-Doctor

.

.

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

$\endgroup$

1 Answer 1

0
$\begingroup$

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!

$\endgroup$

Your Answer

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