1. Timestamp Correction - leggedrobotics/hardware_time_sync GitHub Wiki
Overview
This guide covers a process for correcting timestamps from multiple sensor measurements. Sensors are generally some embedded device which acquires a measurement and passes the data to a PC where it is timestamp on reception. However, if there is a significant delay between the acquisition and timestamping the data might not be useful for applications that require a high update rate. Additionally, if two different sensors are required (such as an IMU and camera for VIO) they have different delays making the data useless. Even devices with their own clocks will eventually drift with respect to the PC and other sensors.
The goal is to correct all measurement timestamps to be with respect to the same clock. Additionally we want the timestamps to be as close as possible to the instant in time the measurement was taken. There are a couple important points to make note of:
- We are not synchronizing multiple sensors in the sense that we do not force them to record their measurements at the same time. Each sensor can start and stop on its own and run at its own rate.
- We assume every sensor measurement can be triggered by an external signal. The Intel Realsense camera is an exception.
- While the timestamp will be correct, there will be an increase in delay of arrival of a measurement.
General Hardware Setup
We treat all sensors in the same way: triggering them externally from a microcontroller. Once triggered, the sensor send its measurement along to the PC.
General Software
We run a Timestamp Correction (TC) nodelet which acts as an intermediary between all the sensor drivers and everything else which uses the data. All measurements pass from the sesnro drivers to the TC via a ROS nodelet manager. This is because nodelets pass messages by reference rather than copying. This greatly speeds up timestamp correction for data such as images.
In order to match the uncorrected data with the arduino timestamps, each sensor publishes an additional counter topic which has the exact same uncorrected timestamp as the measurement data. Then, using message_filters::TimerSynchronization we subscribe to both topics simultaneously and use the Sequence Number to search in a queue of arduino messages for the corresponding correct timestamp.