Re: [ros-users] Wifi communication getting slow

Top Page
Attachments:
Message as email
+ (text/plain)
+ consumer.cpp (text/x-c++src)
+ publisher.cpp (text/x-c++src)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: User discussions
Subject: Re: [ros-users] Wifi communication getting slow
Hello Josh,

While trying to reproduce the delay build-up, I checked that the
behaviour you described is the one I observe, as long as my message
queue is positive.

However, I could reproduce the behaviour when the message queue is zero:
ros::Subscriber sub = n.subscribe("chatter", 0, chatterCallback);

What is the intended behaviour in this case? I might have thought that
zero would disable the queue when I wrote the code earlier...
I guess the subscribe functions should document the semantic or flag
an error if the value is invalid.

Find my test programs attached. I'm postponing filing a ticket until I
understand if there is a mistake somewhere else than in my code :)

Best.

On Wed, Jan 5, 2011 at 7:38 PM, Josh Faust <> wrote:
>> In this case, I was getting message build-up even with when the
>> subscriber used a queue size of one. It seems that the teleop message
>> where small enough to accumulate in the TCP kernel or HW buffer and
>> not being discarded while the callback was running. This can be easily
>> identified by looking at the message timestamp. In our case, the
>> message age was increasing (obviously, you can only evaluate that on
>> machines with synchronised clocks).
>
> If you have a way to reproduce this, please file a ticket -- roscpp should
> be draining the sockets as quickly as possible whether or not your callbacks
> take a long time.  They should be totally decoupled.
> Josh
>
> _______________________________________________
> ros-users mailing list
>
> https://code.ros.org/mailman/listinfo/ros-users
>
>




--
Cedric Pradalier
#include "ros/ros.h"
#include "std_msgs/Time.h"

void chatterCallback(const std_msgs::Time::ConstPtr& msg)
{
    double t_here = ros::Time::now().toSec();
    double t_there = (msg->data).toSec();


    ROS_INFO("Got message aged %.3fs", t_here - t_there);
    double x = exp(1);
    unsigned long i=0;
    while (i < 1e6) {
        x = sin(exp(x));
        i ++;
    }


    ROS_INFO("Finished processing it");


}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "listener");
    ros::NodeHandle n;


    ros::Subscriber sub = n.subscribe("chatter", 0, chatterCallback);


    ros::spin();


    return 0;
}


#include "ros/ros.h"
#include "std_msgs/Time.h"

#include <sstream>

/**
 * This tutorial demonstrates simple sending of messages over the ROS system.
 */
int main(int argc, char **argv)
{
    ros::init(argc, argv, "talker");
    ros::NodeHandle n;
    ros::Publisher chatter_pub = n.advertise<std_msgs::Time>("chatter", 1000);


    ros::Rate loop_rate(500);


    int count = 0;
    while (ros::ok())
    {
        std_msgs::Time msg;
        msg.data = ros::Time::now();


        chatter_pub.publish(msg);


        ros::spinOnce();


        loop_rate.sleep();
        ++count;
    }



    return 0;
}