From 784bcbcdc982fbc5b857320884d6faa6c358c3ac Mon Sep 17 00:00:00 2001 From: Marco Lampacrescia Date: Thu, 16 Sep 2021 16:02:35 +0200 Subject: [PATCH 1/2] Fix Duration casting issue leading to no undistortion Signed-off-by: Marco Lampacrescia --- src/laser_geometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser_geometry.cpp b/src/laser_geometry.cpp index 7031290..3928d90 100644 --- a/src/laser_geometry.cpp +++ b/src/laser_geometry.cpp @@ -427,8 +427,8 @@ void LaserProjection::transformLaserScanToPointCloud_( TIME end_time = scan_in.header.stamp; // TODO(anonymous): reconcile all the different time constructs if (!scan_in.ranges.empty()) { - end_time = end_time + rclcpp::Duration( - static_cast((scan_in.ranges.size() - 1) * scan_in.time_increment), 0); + end_time = start_time + rclcpp::Duration::from_seconds( + (scan_in.ranges.size() - 1) * scan_in.time_increment); } std::chrono::nanoseconds start(start_time.nanoseconds()); From 93db1470f1d3bf29976e48c39254e546e3853e92 Mon Sep 17 00:00:00 2001 From: Marco Lampacrescia Date: Thu, 9 Dec 2021 11:44:47 +0100 Subject: [PATCH 2/2] Explicit cast to double to prevent loss of precision Signed-off-by: Marco Lampacrescia --- src/laser_geometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laser_geometry.cpp b/src/laser_geometry.cpp index 3928d90..d07b7c5 100644 --- a/src/laser_geometry.cpp +++ b/src/laser_geometry.cpp @@ -428,7 +428,7 @@ void LaserProjection::transformLaserScanToPointCloud_( // TODO(anonymous): reconcile all the different time constructs if (!scan_in.ranges.empty()) { end_time = start_time + rclcpp::Duration::from_seconds( - (scan_in.ranges.size() - 1) * scan_in.time_increment); + static_cast(scan_in.ranges.size() - 1) * static_cast(scan_in.time_increment)); } std::chrono::nanoseconds start(start_time.nanoseconds());