0
$\begingroup$

Rosanswers logo

I have two different machines connected by wifi sharing a ROS_MASTER. One of them is the erratic robot which is sending odom messages continuously. The point is that those messages are being received in the other machine with header.stamp > ros::Time::now() ... when it should be header.stamp <= ros::Time::now(). The time distance is ~0.001s. The machines's clocks clearly aren't synchronized (a past reading can never came from the future).

I don't know in depth how NTP works but I expected it would be working properly. What should I do? Is there any typical way to afford this problem?

In the case of the erratic robot I've been diving a bit in its driver and we get that the stamp comes from the internal player code:

   player_msghdr_t* hdr = msg->GetHeader();

        if ((hdr->type == PLAYER_MSGTYPE_DATA) &&
            (hdr->subtype == PLAYER_POSITION2D_DATA_STATE) &&
            (hdr->addr.interf == PLAYER_POSITION2D_CODE))
        {
            // Cast the message payload appropriately
            player_position2d_data_t* pdata = (player_position2d_data_t*) msg->GetPayload();

[...]

odom.header.frame_id = tf::resolve(tf_prefix_, odom_frame_id);
            odom.header.stamp.sec = (long long unsigned int) floor(hdr->timestamp);
            odom.header.stamp.nsec = (long long unsigned int) ((hdr->timestamp - floor(hdr->timestamp)) * 1000000000ULL);

Regards.


Originally posted by Pablo Iñigo Blasco on ROS Answers with karma: 2982 on 2012-12-19

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Just install ntpd server and checking they share the same synchronization servers (/etc/ntpd.conf) looks to solve the problem. I'll keep you informed.

sudo apt-get install ntp

ref: https://help.ubuntu.com/8.04/serverguide/NTP.html


Originally posted by Pablo Iñigo Blasco with karma: 2982 on 2012-12-19

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Lorenz on 2012-12-19:
On the PR2 and a couple of other robots I know about, chrony is used.

Comment by Pablo Iñigo Blasco on 2012-12-19:
Right. I'll take it into account. It looks great https://wiki.archlinux.org/index.php/Chrony

Comment by weiin on 2012-12-19:
There's a tutorial that talks about this: http://www.ros.org/wiki/ROS/NetworkSetup#Timing_issues.2C_TF_complaining_about_extrapolation_into_the_future.3F

Comment by weiin on 2012-12-19:
But I must add that I tried this, and have not gotten the two laptops on my custom-made robot to time sync, maybe because their wireless link is through a router

Comment by Pablo Iñigo Blasco on 2013-01-13:
weiin. Did you use ntp or chrony?

Comment by weiin on 2013-01-14:
I followed that faq I linked above. chrony.conf to slowly correct drifts, ntpdate to do immediate corrections. But so far I'm usually still getting around 0.2s discrepancy after a while (that's why I use ntpdate to correct instantly)

Comment by Pablo Iñigo Blasco on 2013-01-14:
How much is it a while? more or less?? seconds, minutes, hours?

Comment by weiin on 2013-01-14:
I have not done any quantification for 'a while'. I believe it depends on the connection between the two laptops since by definition in chrony.conf, the second laptop needs to sync to the server. As mentioned, my laptops are connected through a wireless router, so connection can get flaky

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.