From 95f7bd930e84b78c745f799509849fb22c12f5a4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 14:55:56 -0400 Subject: [PATCH] avoid unstable LaserScan status for rviz2 (#614) (#616) Signed-off-by: Chen Lihui (cherry picked from commit 83046c2316038030edf94a4a0a31c8ee65345b58) Co-authored-by: Chen Lihui --- dummy_robot/dummy_sensors/README.md | 2 +- dummy_robot/dummy_sensors/src/dummy_laser.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dummy_robot/dummy_sensors/README.md b/dummy_robot/dummy_sensors/README.md index 86427271e..fdfc0b413 100644 --- a/dummy_robot/dummy_sensors/README.md +++ b/dummy_robot/dummy_sensors/README.md @@ -27,7 +27,7 @@ ros2 run dummy_sensors dummy_laser # Terminal Output [INFO] [1658564972.776089023] [dummy_laser]: angle inc: 0.004363 [INFO] [1658564972.776138078] [dummy_laser]: scan size: 1081 -[INFO] [1658564972.776148752] [dummy_laser]: scan time increment: 0.000028 +[INFO] [1658564972.776148752] [dummy_laser]: scan time increment: 0.000000 ``` ### **2 - dummy_joint_states** diff --git a/dummy_robot/dummy_sensors/src/dummy_laser.cpp b/dummy_robot/dummy_sensors/src/dummy_laser.cpp index 2a93276d8..1e1bc19c6 100644 --- a/dummy_robot/dummy_sensors/src/dummy_laser.cpp +++ b/dummy_robot/dummy_sensors/src/dummy_laser.cpp @@ -58,8 +58,9 @@ int main(int argc, char * argv[]) } msg.ranges.resize(static_cast(num_values)); - msg.time_increment = - static_cast((angle_resolution / 10000.0) / 360.0 / (scan_frequency / 100.0)); + // Set `time_increment` with 0 to avoid unstable status shown in the `LaserScan` display of rviz2 + // while looking up transform with a forward time value. + msg.time_increment = 0.0f; msg.angle_increment = static_cast(angle_resolution / 10000.0 * DEG2RAD); msg.angle_min = static_cast(start_angle / 10000.0 * DEG2RAD - M_PI / 2); msg.angle_max = static_cast(stop_angle / 10000.0 * DEG2RAD - M_PI / 2);