ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Right way to replay laser scan from bag file and visualize in rviz

asked 2023-02-05 03:14:02 -0500

shrini96 gravatar image

updated 2023-02-05 09:06:01 -0500

I recorded a rosbag containing laser scans and while trying to play it back and visualize the output in rviz I get the following warning: Detected jump back in time of 1.0252e-05s. Clearing TF buffer.

The jump-back time just keeps increasing. I realize this problem has something to do with using the --clock option in rosbag play and using use_sim_time. Both of which are rightly done. I set at the very beginning of the launch file:

<param name="/use_sim_time" type="bool" value="true"/>

and pass the --clock option to rosbag play. I still get the warning.

The scans are being visualized in rviz, but every now and then there is a flicker in the screen and the scans go away and then come back. This is surely not how it's normally supposed to behave. (Additionally, when I feed the rosbag laser scans and other sensor data to a SLAM algorithm, it doesn't work. While in fact, the rosbag was recorded the first time with said algorithm, rtabmap).

Edit: Adding the launch file and a snippet of what the rosbag file contains:

<launch>   
    <param name="/use_sim_time" type="bool" value="true"/>
    <node pkg="rosbag" type="play" name="playback_vel_rtab"
          args="--clock $(find my_pkg)/datacapture/bagname.bag">
          <remap from="/scan"            to="/fake_scan"/>
    </node>
</launch>

And here is my bagfile:

path:        rtab_in_2023-01-27-10-05.bag
version:     2.0
duration:    2:22s (142s)
start:       Jan 01 1970 01:00:00.29 (0.29)
end:         Jan 01 1970 01:02:23.02 (143.02)
size:        6.2 GB
messages:    159462
compression: none [919/919 chunks]
types:       nav_msgs/Odometry      [cd5e73d190d741a2f92e81eda573aca7]
             rosgraph_msgs/Clock    [a9c97c1d230cfc112e270351a944ee47]
             sensor_msgs/CameraInfo [c9a58c1b0b154e0e6da7578cb991d214]
             sensor_msgs/Image      [060021388200f6f0f447d0fcd9c64743]
             sensor_msgs/LaserScan  [90c7ef2dc6895d81024acba2ac42f369]
             tf2_msgs/TFMessage     [94810edda583a504dfda3829e70d7eec]
topics:      /camera/depth/image_raw      459 msgs    : sensor_msgs/Image     
             /camera/rgb/camera_info      459 msgs    : sensor_msgs/CameraInfo
             /camera/rgb/image_raw        459 msgs    : sensor_msgs/Image     
             /clock                    141763 msgs    : rosgraph_msgs/Clock   
             /odom                       4274 msgs    : nav_msgs/Odometry     
             /scan                        712 msgs    : sensor_msgs/LaserScan 
             /tf                        11335 msgs    : tf2_msgs/TFMessage     (3 connections)
             /tf_static                     1 msg     : tf2_msgs/TFMessage
edit retag flag offensive close merge delete

Comments

Is it possible you have two sources publishing to /clock topic? It won't work if both gazebo and rosbag are publishing the ros time.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-02-05 08:26:14 -0500 )edit

No, it is only the rosbag that is publishing. Let me update the question with my launch file and a snippet of my rosbag file^^

shrini96 gravatar image shrini96  ( 2023-02-05 09:00:26 -0500 )edit
2

When the bag file was created, it recorded the /clock topic; this is a problem because I believe that the --clock option synthesizes (i.e. generates) a ros clock. So your play command is sending two different data streams to the /clock topic. I would try specifying the topics you want rosbag to play back, and make sure not to publish the /clock topic from the bag file.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-02-05 10:16:16 -0500 )edit

You are right. This works like a charm (with the exception of occasionally getting the TF_REPEATED_DATA warning, which i think is a different issue altogether).

Thanks a lot. You can write this as an answer and I will mark it as accepted.

shrini96 gravatar image shrini96  ( 2023-02-07 06:33:47 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-02-07 10:11:05 -0500

Mike Scheutzow gravatar image

When the bag file was created, it recorded the /clock topic; this is a problem because I believe that the --clock option synthesizes (i.e. generates) a ros clock. So your play command is sending two different data streams to the /clock topic.

I would try specifying the topics you want rosbag to play back, and make sure not to publish the /clock topic from the bag file.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2023-02-05 03:14:02 -0500

Seen: 362 times

Last updated: Feb 07 '23