Ask Your Question
2

Unable to receive data from ROS Master using Matlab

asked 2016-04-01 07:48:51 -0600

UserK gravatar image

updated 2016-04-01 12:34:25 -0600

I would like to connect to ROS network using Matlab and plot the laser scanner data

  • The ROS framework runs on a rover with IP address: 160.80.97.150. The rover is publishing laserscanner data on the /scan topic
  • Matlab runs on another computer with IP: 160.80.97.241

The port 11311 on the rover is opened:

heavylab@HeavyLab:~$ nmap 160.80.97.150 -p 11311

Starting Nmap 6.40 ( http://nmap.org ) at 2016-04-01 14:30 CEST
Nmap scan report for 160.80.97.150
Host is up (0.000030s latency).
PORT      STATE SERVICE
11311/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds

The Problem

I am able to see the published topics from matlab but they seems empty. The receive command returns an error.

    % Connect to a remote ROS instance on port 11311
    rosinit('http://160.80.97.150:11311', 'NodeHost', '160.80.97.241')

    % Check for topics
    rostopic list

/scan            

    % Echo for /scan topic
    laser = rossubscriber('/scan')


laser = 

  Subscriber with properties:

        TopicName: '/scan'
      MessageType: 'sensor_msgs/LaserScan'
    LatestMessage: [0x1 LaserScan]
       BufferSize: 1
    NewMessageFcn: []

    % Receive Scan data
    scandata = receive(laser,10)

     Error using robotics.ros.Subscriber/receive
     (line 291)
     The function did not receive any data and timed
     out.

Do have any advice?

EDIT

Here is the output of the rosnode ping from Matlab:

 rosnode ping /rosout
    Pinging the /rosout node with a timeout of 3 seconds.
    Received no ping response.
edit retag flag offensive close merge delete

Comments

Are these both Linux machines? Do you have a working DNS server that can resolve both hostnames to their IPs? What is the output of rosnode ping <nodename>?

gvdhoorn gravatar imagegvdhoorn ( 2016-04-01 10:07:51 -0600 )edit

Yes, they are both linux machines. No I don't have any DNS. I added the output of the command in the question

UserK gravatar imageUserK ( 2016-04-01 12:22:39 -0600 )edit

I'm getting the exact same issue. Any progress on an answer?

runbren gravatar imagerunbren ( 2016-08-02 20:09:25 -0600 )edit

No Nothing

UserK gravatar imageUserK ( 2016-08-03 07:30:03 -0600 )edit

I meet the same problem too. And there is no answer to the issue on the Internet.

wangxvx gravatar imagewangxvx ( 2016-11-14 07:44:03 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2016-11-14 20:53:28 -0600

wangxvx gravatar image

I solved the problem following an answer below: http://cn.mathworks.com/matlabcentral...

edit flag offensive delete link more

Comments

That is exactly what I wrote above in my answer: always make sure you either have a working DNS setup for all computers in your network, or use ROS_IPorROS_HOSTNAME together with a proper value for ROS_MASTER_URI. But thanks for posting the URL @wangxvx.

gvdhoorn gravatar imagegvdhoorn ( 2016-11-15 02:06:03 -0600 )edit

Note that the suggested 'fix' on the mathworks support page (setting ROS_IP and ROS_MASTER_URI to hard-coded values) will only work if you're not on a network with DHCP that (frequently) changes your computer's IP address. If you are, you'll run into even more problems.

gvdhoorn gravatar imagegvdhoorn ( 2016-11-15 02:07:19 -0600 )edit
1

answered 2016-08-13 11:38:34 -0600

gvdhoorn gravatar image

I'm not entirely sure what Mathworks recommends in their documentation, but be sure to set correct values for the ROS_MASTER_URI and ROS_IP environment variables on all involved hosts. ROS_IP should equal the IP address of the host, ROS_MASTER_URI should point to the rover's IP.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2016-04-01 07:48:51 -0600

Seen: 2,544 times

Last updated: Nov 14 '16