Class ActiveTimeCorrection

Class Documentation

class ActiveTimeCorrection

Class to handle active time correction for LidarFrames.

This class provides methods to correct and reset timestamps in LidarFrames based on sensor information. It checks for synchronization between sensors, ensures monotonicity of timestamps, and applies corrections as needed.

Typical usage pattern: ActiveTimeCorrection time_correction(infos);

for (auto frames : frame_set_source) { time_correction.update(frames); // to apply time correction slam_engine.update(frames); // SLAM processing time_correction.reset(frames); // to reset the timestamps }

Public Functions

ActiveTimeCorrection(const std::vector<std::shared_ptr<core::SensorInfo>> &infos)

Construct an ActiveTimeCorrection object from sensor info structures.

Parameters:

infos[in] A vector of shared pointers to SensorInfo objects, one per sensor.

void update(core::FrameSet &frame_set)

pre-registration frames time check and synchronization.

It modifies the frames by adding corrected timestamp field. Use the reset() method to remove the added corrected frame timestamps field.

Steps taken: • Compute overall frame timestamp range. • Check inter-sensor synchronization:

  • If sensors are out of sync, enable packet-offset mode. • Monotonicity check (ignoring zero timestamps):

  • For any frame whose timestamps go backwards, correct its timestamps and enable packet-offset mode. • Packet-offset handling:

  • If offset mode is active, compute fallback timestamp offsets. • Finally: it detects frames that come out of order.

Remark

when an out of order frame is detected, its range field is zeroed out to invalidate it. This behavior will be revised in the future to avoid modifying the frame data.

Parameters:

frame_set[inout] A vector of LidarFrame objects to be processed.

void reset(core::FrameSet &frame_set)

reset frames sensor time post-registration

Parameters:

frame_set[inout] A vector of LidarFrame objects to be processed.

inline std::vector<std::pair<int64_t, int64_t>> &last_frame_ts_range()

get frame ts ranges

Returns:

vector of (start_ts, end_ts) pairs for each frame within the frame set

bool check_sensors_synchronization(const std::vector<std::pair<int64_t, int64_t>> &frame_ts_range) const

Determines whether a set of lidar frames are pre-synchronized based on their start timestamps.

This function compares the earliest and latest start timestamps from a range of frames and checks if their difference is within the smallest frame duration available. If the time difference is less than or equal to the minimum frame gap, the frames are considered pre-synchronized.

Parameters:

frame_ts_range[in] A vector of (start_ts, end_ts) pairs representing the time value range for each frame.

Returns:

true if the frames are pre-synchronized, false otherwise.

void correct_frame_ts(core::LidarFrame &frame, size_t sensor_idx)

Corrects the timestamps of the input Lidar frame based on the previous frame’s timestamp range and the sensor’s frame duration.

Parameters:
  • frame[inout] The LidarFrame object whose timestamps need to be corrected.

  • sensor_idx[in] The index of the sensor associated with the frame.

Public Static Functions

static bool is_monotonically_increasing(Eigen::Ref<const core::LidarFrame::Header<uint64_t>> timestamps, int64_t last_frame_stop_ts)

Checks if the timestamps in each lidar frame are strictly increasing (ignoring any zeros) and its first non-zero timestamp is greater than the previous frame’s end timestamp.

Parameters:
  • timestamps[in] a vector representing lidar timestamps.

  • last_frame_stop_ts[in] The end timestamp of the previous frame.

Returns:

true if the input timestamps are monotonically increasing, false otherwise.