function did not receive any data and timed out

18 views (last 30 days)
Here is the detail.
machine 1: windows 10 with MatLab 2017
machine 2 (turtlebot pc): ubuntu 14 with ROS indigo attached with TURTLEBOT 2 and ROS ASTRA PRO.
both machines can ping each other and i can see the rostopics from Matlab machine node also. I run following commands on machine 1
$ roscore
$ roslaunch turtlebot_bringup minimal.launch
I am trying to run MatLab code from explore basic behaviour of turtlebot example on machine 2 . and i got MatLab error at code line laser = rossubscriber('/scan'); while I was not getting /scan topic listed on MatLab output for rostopic list also. th`en I executed the following command also on machine 1 and executed again Matlab code on pc2. and this time i resolved thisproblem and listed /scan topic also in rostopic list on Matlab output successfully.
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
but now i am stuck at next line of /scan topic code line scan = receive(laser,3) and getting timeout error message Error using robotics.ros.Subscriber/receive The function did not receive any data and timed out. i even tried and checked all help on my setup from these two threads link 1 and link 2. still, i am getting same timeout error message and i am not able to run code completely for turtlebot. please help. here is the screen shot.Screenshot_1.jpg

Accepted Answer

naria on 31 Jan 2020
sorry to answer my own question, I have plotted the data received from /scan topic on MATLAB. I am using it for obstacle avoidance and navigation. The main reason that i was not receiving the scan topic data for astra pro 3d sensor is that i was missing the command $rosrun depthimage_to_laserscan depthimage_to_laserscan image:=/camera/depth/image_raw for astra on ros machine.
problem solved. Thanks for all your support.

More Answers (1)

Cam Salzberger
Cam Salzberger on 29 Jan 2020
After you create the subscriber "laser", does it receive any messages from the turtlebot? To determine this, you can check the LatestMessage property, or add a callback function to display the message:
laser.NewMessageFcn = @(~, msg) disp(msg);
If you are receiving messages, you may simply need to increase the timeout. If you are not receiving messages, you can also check with rostopic:
rostopic echo /scan
Use Ctrl+C to exit the echo. If that also is not working, then make sure that the turtlebot is actually sending messages. You can do the rostopic echo on one of the Linux terminals on the turtlebot machine to check that.
If messages are being sent, but not received, then there is a connection issue. Make sure that both MATLAB and turtlebot are using the same ROS Master. Also check that the turtlebot is advertising its IP address by setting the ROS_IP environment variable appropriately before launching the turtlebot node. You can also try simpler demos (talker/listener) to see if you can get communication going between MATLAB and the turtlebot machine without involving the complexity of the actual turtlebot.
Cam Salzberger
Cam Salzberger on 30 Jan 2020
I'm not sure I understood all of that, but it sounds like you are receiving the LaserScan messages when using the subscriber callbacks, but not when using the "receive" function. It could simply be that if you increase the timeout value for "receive", you would see the messages. Otherwise, you could restructure your code to use either the subscriber callback or LatestMessage properties.
It looks like the intensity values are empty, but the range values are provided. It may simply be that your sensor is not detecting or setting the intensity values (range is what matters the most anyway).

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by