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

激光授时后使用 use_lidar_clock=true 解析时间戳有问题 #29

Open
tisyang opened this issue Dec 5, 2022 · 0 comments
Open

Comments

@tisyang
Copy link

tisyang commented Dec 5, 2022

测试用的 RS16,用GPS板卡给激光授时,配置文件激活了 use_lidar_clock=true,但是使用 rs_lidar_sdk [获取的消息时间与相对准确的系统时间相差8个小时,packet 截取所示:

Screenshot_20221205_101129

直连激光使用的配置:

Screenshot_20221205_101217

使用命令行概算时间戳的偏移:

Screenshot_20221205_101310

大概就是 CST 时区的偏置量,8 小时。

看了下代码,应该是这里使用 mktime 问题

time_t sec = std::mktime(&stm);

mktime 会使用当前时区,将参数当作 localtime 来处理,但是授时 RMC 数据都是格林尼治时间,所以会少算时区偏置量。
建议使用 timegm 代替,或者 mktime(...) - _timezone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant