Non-synchronized nodes in different machines. What to do?
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.