Skip to content

Commit

Permalink
fix(hw_interfaces): fix the lossy nanoseconds extraction
Browse files Browse the repository at this point in the history
Signed-off-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
M. Fatih Cırıt committed Nov 30, 2023
1 parent c71a157 commit 1a24da7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ void HesaiHwInterface::ReceiveCloudPacketCallback(const std::vector<uint8_t> & b
auto now_nanosecs =
std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
pandar_packet.stamp.sec = static_cast<int>(now_secs);
pandar_packet.stamp.nanosec =
static_cast<int>((now_nanosecs / 1000000000. - static_cast<double>(now_secs)) * 1000000000);
pandar_packet.stamp.nanosec = static_cast<std::uint32_t>(now_nanosecs % 1000000000);
scan_cloud_ptr_->packets.emplace_back(pandar_packet);

int current_phase = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ void VelodyneHwInterface::ReceiveCloudPacketCallback(const std::vector<uint8_t>
std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
velodyne_packet.data = packet_data;
velodyne_packet.stamp.sec = static_cast<int>(now_secs);
velodyne_packet.stamp.nanosec =
static_cast<int>((now_nanosecs / 1000000000. - static_cast<double>(now_secs)) * 1000000000);
velodyne_packet.stamp.nanosec = static_cast<std::uint32_t>(now_nanosecs % 1000000000);
scan_cloud_ptr_->packets.emplace_back(velodyne_packet);
processed_packets_++;

Expand Down

0 comments on commit 1a24da7

Please sign in to comment.