Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to replay lidar data recorded under ros1 with ros2 #270

Closed
rdouguet opened this issue Nov 27, 2023 · 10 comments
Closed

How to replay lidar data recorded under ros1 with ros2 #270

rdouguet opened this issue Nov 27, 2023 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@rdouguet
Copy link

Describe your question

I'm trying to replay lidar data recorded under ros1 (melodic) in the ros2 (Humble) environment with the Ouster driver for ROS2. So far, I still haven't succeeded but I don't know if I'm going in the right direction.

Here are the step for replaying a recording :
First, I convert my ROS1 recording file to ROS2 using the rosbags tool (https://pypi.org/project/rosbags/)
Next, I compile the ros ouster package so that normally ROS is able to recognize lidar custom messages.
But when I start the replay of this new file, the ouster topics are not recognized and I have the following error :

Screenshots
Capture d’écran du 2023-11-27 11-41-13

I work the same way with other sensors and have never had this problem.

Platform

  • Ouster Sensor: OS1-64
  • (Logger) ROS version/distro/package: melodic / Ubuntu 18.04 / ouster_ros=0.2.1
  • (replay) ROS version/distro/package: humble / Ubuntu 22.04 / ouster_ros=0.12.0
@rdouguet rdouguet added the question Further information is requested label Nov 27, 2023
@Samahu Samahu self-assigned this Nov 27, 2023
@Samahu
Copy link
Contributor

Samahu commented Nov 27, 2023

@rdouguet I didn't try to convert from ROS1 to ROS2 but when doing the opposite I had to add and register the message definitions within rosbags then I was successful with the conversion. I believe you have to do the same thing.

@rdouguet
Copy link
Author

Thanks for your feedback @Samahu

I've just seen the possibility of adding messages with the rosbags tool. I'll try that and see if it works then.
https://ternaris.gitlab.io/rosbags/topics/typesys.html#extending-the-type-system

@rdouguet
Copy link
Author

Finally is not really simple as problem, I did not find easy way...

Maybe we can use "rosbags tools" to add custom message and analyzing the rosbag with python scripts... but my goal is to use old rosbag(ros1) to test new fusion algorithm (develop under ros2) between some sensors such as Lidar, camera and radar.

One solution that I haven't yet had time to finalize is to follow the steps explain at the start (convert ros1 to ros2 and next compile ros ouster package). Finally, you can change manually the type of message in new dB3 log... to replace the type "/ouster_ros/msg/PacketMsg" by "/ouster_sensor_msgs/msg/PacketMsg". In this way, you can publish raw lidar data.

Now I must find how the new ros ouster node can subscribe to these topics to generate the point cloud ?

@Samahu
Copy link
Contributor

Samahu commented Nov 30, 2023

To find how to read load and read the packets from a bag file you should checkout the file replay.launch.xml (or replay.launch for ROS1).

@rdouguet
Copy link
Author

rdouguet commented Dec 1, 2023

Thanks for your feedback. Indeed I see the replay.launch.xml but I 'm not sure to understand completely this replay mode... It is mandatory to fill the path of the rosbag ? I tested by providing the metadata et my rosbag but I did not see point cloud. I have this warning:

Erreur_Replay_Lidar

But my need is to be able to replay rosbag (with several topic provided from different sensors) and for the ouster data, I just need to transform the raw lidar data ("/os_node/imu_packets" and /os_node/lidar_packets") to point cloud... I don't want to run the rosbag command from this script.

I must admit that in previous versions, I was able to do this quite easily, but no matter how much I read the readme documentation, it's hard to understand without going into the code...

Is there a solution for replaying the data without passing it the rosbag but only indicating the input topics?

Thanks in advance

@Samahu
Copy link
Contributor

Samahu commented Dec 6, 2023

@rdouguet I only suggested that you examine replay.launch so you could implement your solution based on it.

If you examine the file closely (using ROS2 version here):

<node_container pkg="rclcpp_components" exec="component_container_mt" name="os_container" output="screen" namespace="">
<composable_node pkg="ouster_ros" plugin="ouster_ros::OusterCloud" name="os_cloud">
<param name="sensor_frame" value="$(var sensor_frame)"/>
<param name="lidar_frame" value="$(var lidar_frame)"/>
<param name="imu_frame" value="$(var imu_frame)"/>
<param name="point_cloud_frame" value="$(var point_cloud_frame)"/>
<param name="timestamp_mode" value="$(var timestamp_mode)"/>
<param name="ptp_utc_tai_offset" value="$(var ptp_utc_tai_offset)"/>
<param name="use_system_default_qos" value="$(var use_system_default_qos)"/>
<param name="proc_mask" value="$(var proc_mask)"/>
<param name="scan_ring" value="$(var scan_ring)"/>
<param name="point_type" value="$(var point_type)"/>
</composable_node>
<composable_node pkg="ouster_ros" plugin="ouster_ros::OusterImage" name="os_image">
<param name="use_system_default_qos" value="$(var use_system_default_qos)"/>
</composable_node>
</node_container>

You can see that along with the os_replay node, we construct an os_cloud and os_image nodes (components). These two nodes process the raw lidar/imu packets when published on the default /ouster/lidar_packets and /ouster/imu_packets topics. which is what the rosbag play command is doing.

If you need to have more than one senosr then you would need to a pair of os_cloud and os_image nodes for each sensor that you intend to replay and utilize topic remapping to set each pair differently for each sensor.

@rdouguet
Copy link
Author

rdouguet commented Dec 6, 2023

Thanks for your help, I can finally replay the data provided by an old rosbag :)

To make it work, I removed the part that launches the ros2 bag from the launch file and deleted the "bag_file" arg. I directly renamed my topics from the *.db3 log file ("/os_node/lidar_packets" to "/ouster/lidar_packets" and /os_node/imu_packets" to "/ouster/imu_packets").

But I suppose it would also work if I remapped these topics with the remapping function.

@rdouguet rdouguet closed this as completed Dec 6, 2023
@Samahu
Copy link
Contributor

Samahu commented Dec 6, 2023

Thanks for your help, I can finally replay the data provided by an old rosbag :)

To make it work, I removed the part that launches the ros2 bag from the launch file and deleted the "bag_file" arg. I directly renamed my topics from the *.db3 log file ("/os_node/lidar_packets" to "/ouster/lidar_packets" and /os_node/imu_packets" to "/ouster/imu_packets").

But I suppose it would also work if I remapped these topics with the remapping function.

The topic prefix /os_node/ is quite old more than 18 months since I actually took over and normalized all topics under a single default namespace /ouster/.. I totally forgot about it. happy to learn that you managed to convert the bag files and replay them.

@Rotoslider
Copy link

Is there a converter now for playing bags created with a device running Ros1 Noetic that needs to be played back on a different machine with Ros2 Humble? The machine with Ros2 does not have Ros1 on it.

@Samahu
Copy link
Contributor

Samahu commented Sep 23, 2024

@Rotoslider please checkout these two helper scripts that allows you to switch between ROS1/ROS2 using rosbags library ouster-lidar/ouster-ros-extras#2. Note that I have developed these scripts for my own use and they are not production ready.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants