LivoxIntegration
LivoxIntegration copied to clipboard
Problem about sync
Hello, I want to know, if it means that I have to write the code to fuse GPS-time and Livox-data-time myself? Or the code exists somewhere?
Here is the pseudocode to achieve this synchronization:
// GPS Time Synchronization
static uint64_t LiDAR_time_last;
static uint64_t LiDAR_time_real;
// 1. Read total second of the UTC time, Unit is second.
uint32_t gps_time_s = get_gps_utc_second();
// 2. Read LiDAR point time, Unit is nanosecond.
uint64_t LiDAR_time = get_LiDAR_pack_time();
// 3. Update real time.
if (LiDAR_time < LiDAR_time_last)
{
//LiDAR time jump indicates the generation of GPS pulse.
LiDAR_time_real = gps_time_s*(1e9) + LiDAR_time%(1000000000);
}
else
{
LiDAR_time_real += LiDAR_time - LiDAR_time_last;
}
//Update history
LiDAR_time_last = LiDAR_time;