View my account

Extract point clouds from BAG file

Comments

10 comments

  • MartyX Grover

    Hi Varsha 11891 Bag files store the data of individual streams such as depth and color.  A point cloud can be generated in real-time once the bag file is loaded into the computer's memory.

     

    Could you provide information about the questions below, please.

     

    1.  Did you record your bag file in ROS or in the RealSense SDK with a tool such as RealSense Viewer

    2.  Do you wish to generate a point cloud from a bag using the RealSense SDK or by using ROS, rendering it in a ROS interface such as RViz

    3.  If you would like to use a script to generate a point cloud from the bag in the RealSense SDK, which programming language would you be using (C++, Python, C#, etc)

    0
    Comment actions Permalink
  • Varsha 11891

    Hi Marty,

    Thanks for the reply.

    1- Yes, BAG file was recorded on Realsense Viewer.

    2- I wish to generate point cloud by using ROS and rendering it on RViz

     

    0
    Comment actions Permalink
  • MartyX Grover

    The RealSense SDK's bag format has some differences from the ROS rosbag format that may make an SDK-recorded bag (such as a Viewer-recorded one) incompatible with ROS and vice versa, as decribed in the link below.

    https://github.com/IntelRealSense/librealsense/issues/3020

     

    If you would like to read a bag file in ROS then the ideal approach would be to record it within ROS using the rosbag record command.  You can define a list of specific ROS topics in a rosbag record instruction to be recorded or record all currently active topics.

    http://wiki.ros.org/rosbag/Commandline#rosbag_record

    To define a list of specific topics to record, you start the instruction with rosbag record and then simply put a list of topic names after it with a space between them, like the example below that was used to record three specific topics from the RealSense ROS wrapper:

    rosbag record /camera/infra1/image_rect_raw /camera/infra2/image_rect_raw /camera/imu

    Whilst to record all currently active tpics, you would use:

    rosbag record --all

     

    In regard to playing back a rosbag file in Rviz, you can try the following steps:

    1.  Start roscore

    roscore >/dev/null 2>&1 &

    2.  Set roscore to use 'simulation time'

    rosparam set use_sim_time true

    3.  Play the bag file along with the clock signal

    rosbag play my_bagfile_1.bag --clock

     

    At this point, Intel's guide to performing SLAM with RealSense (which the above commands are taken from) suggests performing a roslaunch of the opensource_tracking.launch launch file in offline mode to display a point cloud in RViz.

    roslaunch realsense2_camera opensource_tracking.launch offline:=true

     

    The guide can be found here:

    https://github.com/IntelRealSense/realsense-ros/wiki/SLAM-with-D435i

     

     

    A non-RealSense discussion where a ROS user also wanted to visualize a point cloud in RViz from a bag took a similar approach to the RealSense ROS SLAM guide, except they additionally set up a dummy TF and then simply launched RViz instead of performing a roslaunch.

    https://answers.ros.org/question/241230/how-to-visualize-depthimages-from-rosbag-file-with-rviz/?answer=241297#post-id-241297

    0
    Comment actions Permalink
  • Garimell

    Hi, I tried the above method using my L515. I followed the exact same steps, except that my rosbag recording was ~2.7 seconds, so I looped it:

    rosbag play my_bagfile_1.bag --clock -l

    and then I entered:

    roslaunch realsense2_camera opensource_tracking.launch offline:=true

    The RViz window shows up, but I do not see any point cloud or image of the recorded map being generated. There is an error message in the terminal: [ WARN] [1655418079.936150445, 0.853509704]: Failed to meet update rate! Took 0.0067387280000000002525 which keeps repeating itself. How do I fix the update rate so that RViz can meet the update rate of the .bag recorded file? Please help urgently thank you.

    0
    Comment actions Permalink
  • MartyX Grover

    A general ROS user (not RealSense) who experienced this error with a bag suggested using the --rate command of rosbag play.

    https://github.com/cra-ros-pkg/robot_localization/issues/584#issuecomment-850997020

     

    The link below provides an explanation about 'Rates' in ROS.

    https://roboticsbackend.com/ros-rate-roscpy-roscpp/

     

    0
    Comment actions Permalink
  • Garimell

    Hi MartyG, thanks for your reply. I tried to adjust the --rate 0.8 and I still got the same error message [ WARN] [1655418079.936150445, 0.853509704]: Failed to meet update rate! Took 0.0067387280000000002525.

    I saw that I needed to adjust the --rate and --hz based on the topic that I was subscribed to, so I tried using "rostopic list" to see what topics there are and there was a long list of published topics (please see below). I have no idea which topic(s) to match the update rate to as there are so many. Which topic should I subscribe to and how? Here is another error message which led me to do the above:

    [ WARN] [1655492275.689279654]: /rtabmap/rtabmap: Did not receive data since 5 seconds! Make sure the input topics are published ("$ rostopic hz my_topic") and the timestamps in their header are set. If topics are coming from different computers, make sure the clocks of the computers are synchronized ("ntpdate"). If topics are not published at the same rate, you could increase "queue_size" parameter (current=10).

    /clock
    /device_0/info
    /device_0/sensor_0/Depth_0/image/data
    /device_0/sensor_0/Depth_0/image/metadata
    /device_0/sensor_0/Depth_0/info
    /device_0/sensor_0/Depth_0/info/camera_info
    /device_0/sensor_0/Depth_0/tf/0
    /device_0/sensor_0/Infrared_0/image/data
    /device_0/sensor_0/Infrared_0/image/metadata
    /device_0/sensor_0/Infrared_0/info
    /device_0/sensor_0/Infrared_0/info/camera_info
    /device_0/sensor_0/Infrared_0/tf/0
    /device_0/sensor_0/info
    /device_0/sensor_0/l500_data
    /device_0/sensor_0/option/Alternate_IR/description
    /device_0/sensor_0/option/Alternate_IR/value
    /device_0/sensor_0/option/Apd_Temperature/description
    /device_0/sensor_0/option/Apd_Temperature/value
    /device_0/sensor_0/option/Confidence_Threshold/description
    /device_0/sensor_0/option/Confidence_Threshold/value
    /device_0/sensor_0/option/Depth_Offset/description
    /device_0/sensor_0/option/Depth_Offset/value
    /device_0/sensor_0/option/Depth_Units/description
    /device_0/sensor_0/option/Depth_Units/value
    /device_0/sensor_0/option/Digital_Gain/description
    /device_0/sensor_0/option/Digital_Gain/value
    /device_0/sensor_0/option/Enable_IR_Reflectivity/description
    /device_0/sensor_0/option/Enable_IR_Reflectivity/value
    /device_0/sensor_0/option/Enable_Max_Usable_Range/description
    /device_0/sensor_0/option/Enable_Max_Usable_Range/value
    /device_0/sensor_0/option/Error_Polling_Enabled/description
    /device_0/sensor_0/option/Error_Polling_Enabled/value
    /device_0/sensor_0/option/Frames_Queue_Size/description
    /device_0/sensor_0/option/Frames_Queue_Size/value
    /device_0/sensor_0/option/Freefall_Detection_Enabled/description
    /device_0/sensor_0/option/Freefall_Detection_Enabled/value
    /device_0/sensor_0/option/Global_Time_Enabled/description
    /device_0/sensor_0/option/Global_Time_Enabled/value
    /device_0/sensor_0/option/Host_Performance/description
    /device_0/sensor_0/option/Host_Performance/value
    /device_0/sensor_0/option/Humidity_Temperature/description
    /device_0/sensor_0/option/Humidity_Temperature/value
    /device_0/sensor_0/option/Inter_Cam_Sync_Mode/description
    /device_0/sensor_0/option/Inter_Cam_Sync_Mode/value
    /device_0/sensor_0/option/Invalidation_Bypass/description
    /device_0/sensor_0/option/Invalidation_Bypass/value
    /device_0/sensor_0/option/LDD_temperature/description
    /device_0/sensor_0/option/LDD_temperature/value
    /device_0/sensor_0/option/Laser_Power/description
    /device_0/sensor_0/option/Laser_Power/value
    /device_0/sensor_0/option/Ma_Temperature/description
    /device_0/sensor_0/option/Ma_Temperature/value
    /device_0/sensor_0/option/Mc_Temperature/description
    /device_0/sensor_0/option/Mc_Temperature/value
    /device_0/sensor_0/option/Min_Distance/description
    /device_0/sensor_0/option/Min_Distance/value
    /device_0/sensor_0/option/Noise_Estimation/description
    /device_0/sensor_0/option/Noise_Estimation/value
    /device_0/sensor_0/option/Noise_Filtering/description
    /device_0/sensor_0/option/Noise_Filtering/value
    /device_0/sensor_0/option/Post_Processing_Sharpening/description
    /device_0/sensor_0/option/Post_Processing_Sharpening/value
    /device_0/sensor_0/option/Pre_Processing_Sharpening/description
    /device_0/sensor_0/option/Pre_Processing_Sharpening/value
    /device_0/sensor_0/option/Receiver_Gain/description
    /device_0/sensor_0/option/Receiver_Gain/value
    /device_0/sensor_0/option/Sensor_Mode/description
    /device_0/sensor_0/option/Sensor_Mode/value
    /device_0/sensor_0/option/Visual_Preset/description
    /device_0/sensor_0/option/Visual_Preset/value
    /device_0/sensor_0/post_processing
    /device_0/sensor_1/Color_0/image/data
    /device_0/sensor_1/Color_0/image/metadata
    /device_0/sensor_1/Color_0/info
    /device_0/sensor_1/Color_0/info/camera_info
    /device_0/sensor_1/Color_0/tf/0
    /device_0/sensor_1/info
    /device_0/sensor_1/option/Auto_Exposure_Priority/description
    /device_0/sensor_1/option/Auto_Exposure_Priority/value
    /device_0/sensor_1/option/Backlight_Compensation/description
    /device_0/sensor_1/option/Backlight_Compensation/value
    /device_0/sensor_1/option/Brightness/description
    /device_0/sensor_1/option/Brightness/value
    /device_0/sensor_1/option/Contrast/description
    /device_0/sensor_1/option/Contrast/value
    /device_0/sensor_1/option/Enable_Auto_Exposure/description
    /device_0/sensor_1/option/Enable_Auto_Exposure/value
    /device_0/sensor_1/option/Enable_Auto_White_Balance/description
    /device_0/sensor_1/option/Enable_Auto_White_Balance/value
    /device_0/sensor_1/option/Exposure/description
    /device_0/sensor_1/option/Exposure/value
    /device_0/sensor_1/option/Frames_Queue_Size/description
    /device_0/sensor_1/option/Frames_Queue_Size/value
    /device_0/sensor_1/option/Gain/description
    /device_0/sensor_1/option/Gain/value
    /device_0/sensor_1/option/Global_Time_Enabled/description
    /device_0/sensor_1/option/Global_Time_Enabled/value
    /device_0/sensor_1/option/Host_Performance/description
    /device_0/sensor_1/option/Host_Performance/value
    /device_0/sensor_1/option/Hue/description
    /device_0/sensor_1/option/Hue/value
    /device_0/sensor_1/option/Power_Line_Frequency/description
    /device_0/sensor_1/option/Power_Line_Frequency/value
    /device_0/sensor_1/option/Saturation/description
    /device_0/sensor_1/option/Saturation/value
    /device_0/sensor_1/option/Sharpness/description
    /device_0/sensor_1/option/Sharpness/value
    /device_0/sensor_1/option/White_Balance/description
    /device_0/sensor_1/option/White_Balance/value
    /device_0/sensor_1/post_processing
    /device_0/sensor_2/info
    /device_0/sensor_2/option/Enable_Motion_Correction/description
    /device_0/sensor_2/option/Enable_Motion_Correction/value
    /device_0/sensor_2/option/Frames_Queue_Size/description
    /device_0/sensor_2/option/Frames_Queue_Size/value
    /device_0/sensor_2/option/Global_Time_Enabled/description
    /device_0/sensor_2/option/Global_Time_Enabled/value
    /file_version
    /rosout
    /rosout_agg


    0
    Comment actions Permalink
  • MartyX Grover

    My recollection from the SDK's rosbag inspector tool is that it is the /data topics that contain the image messages.

     

    /device_0/sensor_0/Depth_0/image/data

    /device_0/sensor_0/Infrared_0/image/data

    /device_0/sensor_1/Color_0/image/data

     

    A couple of examples of discussions about the /data topics are at the links below.

    https://github.com/IntelRealSense/librealsense/issues/10458

    https://github.com/IntelRealSense/realsense-ros/issues/1376

     

    More information about the rosbag inspector bag analysis tool can be found here:

    https://github.com/IntelRealSense/librealsense/tree/master/tools/rosbag-inspector

    0
    Comment actions Permalink
  • Garimell

    I will check how to use the rosbag inspector bag analysis tool as per your suggestion. Now I am stuck on a different problem, which is to record using rosbag record. Earlier I used the realsense-viewer to record the rosbag file and it worked with the Python script. I am trying to use rosbag -record --all but it does not play in the python script and gives me this error: RuntimeError: Failed to resolve request. Request to enable_device_from_file("test.bag") was invalid, Reason: Failed to create ros reader: Invalid file format, file does not contain topic "/file_version" nor "/FILE_VERSION"

    I ran roslaunch realsense2_camera demo_pointcloud.launch from ~/catkin_ws/src/realsense-ros/realsense2_camera/launch to open realsense ros topics; below is what I get when I enter rostopic list. Which specific topics do I select to record rosbag and be able to play it from the Python script?

    I looked at https://github.com/IntelRealSense/librealsense/issues/3020 to try and understand why this error occurs but I did not find a solution.

    /camera/color/camera_info
    /camera/color/image_raw
    /camera/color/image_raw/compressed
    /camera/color/image_raw/compressed/parameter_descriptions
    /camera/color/image_raw/compressed/parameter_updates
    /camera/color/image_raw/compressedDepth
    /camera/color/image_raw/compressedDepth/parameter_descriptions
    /camera/color/image_raw/compressedDepth/parameter_updates
    /camera/color/image_raw/theora
    /camera/color/image_raw/theora/parameter_descriptions
    /camera/color/image_raw/theora/parameter_updates
    /camera/color/metadata
    /camera/confidence/camera_info
    /camera/confidence/image_rect_raw
    /camera/confidence/image_rect_raw/compressed
    /camera/confidence/image_rect_raw/compressed/parameter_descriptions
    /camera/confidence/image_rect_raw/compressed/parameter_updates
    /camera/confidence/image_rect_raw/compressedDepth
    /camera/confidence/image_rect_raw/compressedDepth/parameter_descriptions
    /camera/confidence/image_rect_raw/compressedDepth/parameter_updates
    /camera/confidence/image_rect_raw/theora
    /camera/confidence/image_rect_raw/theora/parameter_descriptions
    /camera/confidence/image_rect_raw/theora/parameter_updates
    /camera/confidence/metadata
    /camera/depth/camera_info
    /camera/depth/color/points
    /camera/depth/image_rect_raw
    /camera/depth/image_rect_raw/compressed
    /camera/depth/image_rect_raw/compressed/parameter_descriptions
    /camera/depth/image_rect_raw/compressed/parameter_updates
    /camera/depth/image_rect_raw/compressedDepth
    /camera/depth/image_rect_raw/compressedDepth/parameter_descriptions
    /camera/depth/image_rect_raw/compressedDepth/parameter_updates
    /camera/depth/image_rect_raw/theora
    /camera/depth/image_rect_raw/theora/parameter_descriptions
    /camera/depth/image_rect_raw/theora/parameter_updates
    /camera/depth/metadata
    /camera/extrinsics/depth_to_color
    /camera/l500_depth_sensor/parameter_descriptions
    /camera/l500_depth_sensor/parameter_updates
    /camera/motion_module/parameter_descriptions
    /camera/motion_module/parameter_updates
    /camera/pointcloud/parameter_descriptions
    /camera/pointcloud/parameter_updates
    /camera/realsense2_camera_manager/bond
    /camera/rgb_camera/parameter_descriptions
    /camera/rgb_camera/parameter_updates
    /clicked_point
    /diagnostics
    /initialpose
    /move_base_simple/goal
    /rosout
    /rosout_agg
    /tf
    /tf_static

    0
    Comment actions Permalink
  • MartyX Grover

    There are differences in the RealSense SDK's bag file-format compared to the ROS rosbag format that may cause compatibility issues when trying to play a ROS-recorded rosbag in the RealSense SDK or an SDK-recorded bag in ROS.

    https://github.com/IntelRealSense/librealsense/issues/3020

    0
    Comment actions Permalink
  • Alaosion

    I met the same problem as you and it took me a week to solve it. Could you please share your code with me at that time? alaosion@163.com

    0
    Comment actions Permalink

Please sign in to leave a comment.