Robotics StackExchange | Archived questions

Cannot get laser scan data in windows using rosserial_windows

Hi,

I am rosserialwindows to connect to the ros under windows using roslib. I have written the following code to subscribe to the laser scan data but I don't receive anything in the terminal in windows. It connects with the server and just keeps waiting. Here is the code that I wrote:

void laser_scan_callback(const sensor_msgs::LaserScan & msg)
{
    printf("%d",msg.header.seq);
}

int _tmain(int argc, _TCHAR* argv[])
{
    ros::NodeHandle nh;
    char *ros_master = "192.168.0.110:11411";

    printf("Connecting to server at %s\n", ros_master);
    nh.initNode(ros_master);

    ros::Subscriber<sensor_msgs::LaserScan> laser_scan_sub("scan", &laser_scan_callback);
    nh.subscribe(laser_scan_sub);
    printf("Waiting to receive messages\n");

    while(1)
    {
        nh.spinOnce();
        Sleep(1000);
    }

    printf("All done\n");
    return 0;
}

Some more information is below: On the Ubuntu machine I installed the rosserial for jade as "sudo apt-get install ros-jade-rosserial-windows" and "sudo apt-get install ros-jade-rosserial-server". On the ROS computer I am running rosserialserver socketnode command which is listening to port 11411 and I am connecting to that port through non-ROS computer. I don't understand why it doesn't receive scan data. It seems like that the callback function laserscancallback is never invoked. I also tried to publish data on a topic and that worked. I published on the topic /cmd_vel and the robot in gazebo moved. But I don't know why I don't receive the data from /scan topic.

Asked by imranz30 on 2016-07-12 03:52:57 UTC

Comments

I have tried a lot of things with this but I am still unsuccessful. There are errors like "unknown error returned due to write operation: system 104", sometimes the server give errors like "cannot read unknown error". I am using ros jade should I switch to ros hydro, will that change anything.

Asked by imranz30 on 2016-07-14 04:47:57 UTC

Seems you've already reported this on the rosserial issue tracker, so the developers know about it. Seeing as this is probably not used by too many readers here, it might be most efficient to try and debug this yourself, I'm afraid.

Asked by gvdhoorn on 2016-07-14 05:07:01 UTC

Can you make it work with a more simple (smaller) message type? Ie: try publishing and subscribing to a std_msgs/String topic to test. That would give you at least an indication that your basic setup is working. Perhaps Laserscan msgs are too big for the transport without additional buffering.

Asked by gvdhoorn on 2016-07-14 05:08:35 UTC

I created my own laser_scan_publisher node in ros and ran it to publish data on /scan topic. And now when I connect through rosserial_windows I am able to get that data in the terminal. I think then the problem is not with rosserial_windows. What could be the problem then?

Asked by imranz30 on 2016-07-15 02:31:45 UTC

You don't mention it explicitly, but you do have a node publishing laser scans, right? Or is that what your gazebo model should do? Can you receive laser scans on the ROS computer from the Gazebo model directly (ie: without rosserial in between)?

Asked by gvdhoorn on 2016-07-15 02:52:23 UTC

Well, I solved the problem. It seemed that the laser scanner had a sampling rate of 720, I changed it to 100 and now I receive the data :)

Asked by imranz30 on 2016-07-15 03:01:21 UTC

Hm. Might be interesting to report this on the rosserial issue tracker. Could be a performance problem, a satured link or perhaps a buffering issue.

Asked by gvdhoorn on 2016-07-15 03:58:16 UTC

Answers