ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

Non-synchronized nodes in different machines. What to do?

asked 2012-12-19 07:11:25 -0500

updated 2012-12-19 07:19:20 -0500

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2012-12-19 07:26:10 -0500

updated 2012-12-19 07:26:39 -0500

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

edit flag offensive delete link more

Comments

1

On the PR2 and a couple of other robots I know about, chrony is used.

Lorenz gravatar image Lorenz  ( 2012-12-19 07:30:21 -0500 )edit

Right. I'll take it into account. It looks great https://wiki.archlinux.org/index.php/Chrony

Pablo Iñigo Blasco gravatar image Pablo Iñigo Blasco  ( 2012-12-19 07:50:27 -0500 )edit
2
1

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

weiin gravatar image weiin  ( 2012-12-19 13:35:13 -0500 )edit

weiin. Did you use ntp or chrony?

Pablo Iñigo Blasco gravatar image Pablo Iñigo Blasco  ( 2013-01-13 05:56:23 -0500 )edit

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)

weiin gravatar image weiin  ( 2013-01-14 12:36:17 -0500 )edit

How much is it a while? more or less?? seconds, minutes, hours?

Pablo Iñigo Blasco gravatar image Pablo Iñigo Blasco  ( 2013-01-14 12:55:51 -0500 )edit

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

weiin gravatar image weiin  ( 2013-01-14 15:46:57 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2012-12-19 07:11:25 -0500

Seen: 2,263 times

Last updated: Dec 19 '12