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

Node synchronization

asked 2015-09-30 05:28:43 -0600

alextoind gravatar image

I have several instances of the same node (type A) which execute their code at a predefined common frequency using ros::Timer structures. Each node publishes a message on a common topic every time the timer triggers (after simple computation). A different node (type B) is subscribed to that topic and has the purpose of gathering those messages together and send them back on another topic where all the other nodes are subscribed to.

This is a quick overview of my system and I can't change this configuration because it is mimicking a hardware implementation.

Now the question: the createTimer(ros::Duration(rate), timerCallback) method sets up the loop frequency, but how to synchronize all the timers to trigger at about the same time (e.g. from 12:00:00.000 forever every 100 ms)? Normally, the time depends on the instant on which the method is called and this could be considerably different in a multi-thread environment.

To solve the problem I have thought about a remarkable delay in each constructor to make it wake up at a specific time and then initialize the timer. Of course I have to wait for some natural deadline, e.g. hh:mm:s0.000 or something similar. I do not need a perfect synchronization, do you think that this could be enough? Does still exist something to synchronize nodes? I have already looked at message_filters/approximate_time_policy but it works with distinct topics and I have all the messages on the same one.

Thank you all.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-09-30 05:52:26 -0600

Frank Engelhardt gravatar image

Is it maybe sufficient, if you specify the desired timestamp in the message headers, rather than the actual generation time (I guess you would use ros::Time::now())?

For B, synchronizing with the desired timestamp is easier and avoids using message_filters/approximate_time_policy. There is always an unknown delay for B for message reception due to transmission times an OS scheduling, so generating messages at exact time instants does probably not give you good results either.

edit flag offensive delete link more

Comments

Thanks. I have thought a bit more about it and I decided to proceed as follows: B is the common node, so it has to act like a master in the communication; it computes ros::Time::now() on initialization and sends it to each A node which uses it (plus a common value) as the barrier sync time

alextoind gravatar image alextoind  ( 2015-09-30 09:11:14 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-09-30 05:28:43 -0600

Seen: 3,201 times

Last updated: Sep 30 '15