Krishtof-Korda / pcap-to-bag

Tool to convert ouster lidar sensor pcap files into rosbag files for use in ouster_example/ouster_ros
49 stars 12 forks source link

Wrong Topics #14

Closed CantLooseToAMoose closed 5 months ago

CantLooseToAMoose commented 5 months ago

Hello everyone,

I struggle how to successfully convert the bag file into a new file with the right topic format. I see that I am supposed to run the bag file through the ouster_ros node. However, I struggle on how to do this exactly. When using the newest version of the ouster-ros Repository I can replay the bag file, however only the original topics get played. When I am trying to run the ouster_ros from the ouster_example repository with the linked tag in this Repos' ReadMe, I can not seem to get the replay running.

When I try to run:

roslaunch ouster_ros ouster.launch replay:=true metadata:=/home/gia/pcap_files/OS-1-128_122213002147_1024x10_20231220_145435.json

i get the following error:

WARNING: No data_format found. terminate called after throwing an instance of 'std::invalid_argument' what(): n_cols_of_lidar_mode [ERROR] [1716540121.173213767]: Calling config service failed

I assume they changed the metadata's content in recent versions? Or maybe I am doing something fundamentally wrong as I am no expert.

45671238 commented 5 months ago

Hello,

You are correct, they changed the metadata versions as well as the topic names of the lidar and IMU packets. I think that the old version of this repositorys ouster_ros does not support the new metadata format.

In order to use the new metadata format, you need to use a recent of the ouster_ros package. The new version expects the topic names to be /ouster/lidar_packets and /ouster/imu_packets while in this old version they are /os_node/lidar_packets and /os_node/imu_packets.

I think the easiest fix is to change the topic names in the src/pcap_to_bag.cpp file in lines 66-71 and create a rosbag with the renamed topics:

 if (payload.size() == lidar_payload_size) {
        bag.write("/ouster/lidar_packets", ros_time, msg);
        lidar_packets++;
      } else if (payload.size() == imu_payload_size) {
        bag.write("/ouster/imu_packets", ros_time, msg);
        imu_packets++;
      }

Then you are able to replay the rosbag with the most recent ouster_ros.

CantLooseToAMoose commented 5 months ago

Hey, thanks for the help. This works now, I have created a pull request for this if you want to.