Livox-SDK / livox_ros_driver

Livox device driver under ros, support Lidar Mid-40, Mid-70, Tele-15, Horizon, Avia.
Other
363 stars 203 forks source link

Packet time offset calculation is wrong when packet timestamp decreases #101

Open vvnekb opened 3 years ago

vvnekb commented 3 years ago

I've encoutered a problem when collecting lidar data in Livox customized data package format (that includes timebase and time offset for each point). Our lidar is Livox MID-100.

The problem is illustrated on the following screenshot:

image

It can be seen clearly that at some moment the point offset jumps more than 4 second forward. Coincidentally, the offset value is very close to maximum value of unsigned 32-bit integer.

It looks like the problem is at this line: https://github.com/Livox-SDK/livox_ros_driver/blob/d05c78483981d49e4f1e509366a583a0a775b53e/livox_ros_driver/livox_ros_driver/lddc.cpp#L430

When we iterate over the packets and the next packet (somehow) have a timestamp that is earlier than the timebase - we get a negative value at this line which is then casted to unsigned int, yielding very large value.

What is the reason for the packet timestamp decrease is a different question. I assume this could be related to time synchronization routine? The decrease is about 7-10 ms in our case, which is quite a lot to be attributed to time drift which was then corrected by PPS, leading to timestamp decrease.