Cannot get laser scan data in windows using rosserial_windows [closed]

asked 2016-07-12 03:52:57 -0600

imranz30 gravatar image

updated 2016-07-14 04:55:37 -0600

Hi,

I am rosserial_windows to connect to the ros under windows using ros_lib. 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 rosserial_server socket_node 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 laser_scan_callback 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.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by imranz30
close date 2017-01-13 09:54:31.832546

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.

imranz30 gravatar image imranz30  ( 2016-07-14 04:47:57 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-14 05:07:01 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-14 05:08:35 -0600 )edit

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?

imranz30 gravatar image imranz30  ( 2016-07-15 02:31:45 -0600 )edit

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)?

gvdhoorn gravatar image gvdhoorn  ( 2016-07-15 02:52:23 -0600 )edit

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 :)

imranz30 gravatar image imranz30  ( 2016-07-15 03:01:21 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-15 03:58:16 -0600 )edit