Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: UTC_TIME for RS128 is in "s.ns" format, not "s.us". #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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