- Are messages being sent on that specified topic continuously?
- Are the messages being sent frequently enough that the timeout period would cover at least two messages?
- Are you able to see messages being sent on that topic by running "rostopic echo" in another terminal on the machine sending the messages?
Setup ROS subscriber in Matlab
6 views (last 30 days)
I am trying to subscribe to a ROS /topic in Matlab and I am running out of ideas, what could cause my errors. On my remote machine with Ubuntu 20.4 and ROS Noetic, I can confirm, that the topic is publishing (rostopic echo /topicname). Trying to use the same command in Matlab does not give any output.
In Matlab I run the following code:
rosIP = '192.168.2.18';
rosHOSTNAME = '192.168.2.18';
Shutdown existing ROS server and connect to ROS server on Tinkerboard
Display all available ros nodes and its topics
temperatureSub = rossubscriber('/SOLO1_Temperature', 'std_msgs/Int32')
temperatureMsg = receive(temperatureSub,5)
I get the following error message:
Error using ros.Subscriber/receive (line 456)
The function did not receive any data and timed out.
Do I have to define a callback function first? Or could the error occur because of ROS Noetic? Afaik Matlab only supports ROS Melodic.
Thank you very much!
Cam Salzberger on 7 Feb 2022
If the "receive" call is timing out, that is because it did not receive any data within the timeout period. First, check the obvious:
If it seems like messages are being published correctly, then the issue is the connection between the machines. First check that the topic is visible to MATLAB by doing "rostopic list" (before creating any subscribers or publishers in MATLAB). If you can see the topic with introspection, but not receive any messages on it, the issue is usually with the environment (usually ROS_IP) on the machine sending the messages. See here for a detailed answer.