Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/rs_driver/driver/decoder/basic_attr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,31 @@ inline void createTimeUTCWithUs(uint64_t us, RSTimestampUTC* tsUtc)
}
}

inline std::pair<uint64_t, uint32_t> parseTimeUTCWithNs(const RSTimestampUTC* tsUtc)
{
// sec
uint64_t sec = 0;
for (int i = 0; i < 6; i++)
{
sec <<= 8;
sec += tsUtc->sec[i];
}

// ns
uint32_t ns = 0;
for (int i = 0; i < 4; i++)
{
ns <<= 8;
ns += tsUtc->ss[i];
}

#ifdef ENABLE_STAMP_WITH_LOCAL
sec -= getTimezone();
#endif

return std::make_pair(sec, ns);
}

inline uint64_t parseTimeYMD(const RSTimestampYMD* tsYmd)
{
std::tm stm;
Expand Down
3 changes: 2 additions & 1 deletion src/rs_driver/driver/decoder/decoder_RS128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ inline bool DecoderRS128<T_PointCloud>::internDecodeMsopPkt(const uint8_t* packe
double pkt_ts = 0;
if (this->param_.use_lidar_clock)
{
pkt_ts = parseTimeUTCWithUs(&pkt.header.timestamp) * 1e-6;
std::pair<uint64_t, uint32_t> secAndNs = parseTimeUTCWithNs(&pkt.header.timestamp);
pkt_ts = secAndNs.first + secAndNs.second * 1e-9;
}
else
{
Expand Down