Explanation TimeSync with ROS2 and XRCE-DDS bridge

Hi @Toto ,

time synchronization is automatically managed by the XRCE-DDS bridge.
estimated_offset compares the time difference (in microseconds) between PX4 and the clock on the agent side (pay attention that this is the wall clock, not the ROS clock. These two are normally the same as long as the ROS 2 parameter use_sim_time is false). So let’s assume that you have use_sim_time=false.
The PX4 clock starts counting and is resetted when you power up the board. The Jetson instead is using unix time format, therefore its zero is set to JAN 1st, 1970.
You should see now why the offset is so large.

So the bridge automatically compute the offset, then applies it to every message that go from ROS 2 to PX4 and vice-versa. You can see it by using listener command on the nuttx shell or by using the mavlink inspector and comparing the timestamp values with the ones of the associated ROS 2 topics.

You can use the timestamps of /fmu/out/vehicle_local_position (or any other topic) without any further modification :smile:

1 Like