Reproduction steps:
ROS Master:
In Linux terminal,
$ roscore
Publisher:
In a new Linux terminal,
$ rostopic pub -r 2 /chatter std_msgs/String {}
Subscriber:
In MATLAB:
Node = rosmatlab.node('Test','http://localhost:11311'); Sub = Node.addSubscriber('/chatter','std_msgs/String',10); Sub.setOnNewMessageListeners({@test_fun});
In a new file “test_fun.m”:
function test_fun(msg) disp('Message received!') end
With the above setup, no messages are received in MATLAB.
Best Answer