Generate ROS2 Bag

Convert data recorded by Hammerhead into ROS2 bag format for analysis and replay.

Build

cd hammerhead_ros2
colcon build --packages-up-to generate_rosbag2

Available Tools

xyz - Point Cloud Only

Generates a bag containing only sensor_msgs/PointCloud2 messages with points containing x,y,z and r,g,b attributes.

everything - Complete Dataset

Generates a bag containing the aforementioned point clouds as well as:

  • Raw left and right camera images
  • Rectified left camera image

Prerequisites

You need data recorded by Hammerhead in the following format:

20230208-133746/
    disparity/
        000000000.tiff
        000000001.tiff
        ...
    details/
        000000000.csv
        000000001.csv
        ...

Usage

# Source the workspace
source install/setup.bash

# Generate point cloud only bag
ros2 run generate_rosbag2 xyz <recorded_data_directory>

# Generate complete dataset bag
ros2 run generate_rosbag2 everything <recorded_data_directory>

Examples

# Generate complete bag from recorded data
ros2 run generate_rosbag2 everything 20230208-133746

# Save bag to custom location
ros2 run generate_rosbag2 everything 20230208-133746 ~/Downloads/my_bag

Output

The tool generates a ROS2 bag in the specified directory:

20230208-133746/
    bag/
        bag_0.db3  
        metadata.yaml
    disparity/
        000000000.tiff
        ...
    details/
        000000000.csv
        ...

Generated Topics

Point Cloud Topics

  • /nodar/point_cloud - Generated 3D point cloud data

Image Topics (with everything mode)

  • /nodar/left/image_raw - Raw left camera images
  • /nodar/right/image_raw - Raw right camera images
  • /nodar/left/image_rect - Rectified left camera images

Features

  • Converts disparity data to 3D point clouds using standard stereo reconstruction
  • Preserves timestamps from the original recording
  • Generates standard ROS2 message types
  • Configurable output location

Troubleshooting

  • Memory issues: Use xyz mode for large datasets to reduce memory usage
  • Invalid path: Check that the recorded data directory exists and contains the expected structure
  • Build errors: Ensure all dependencies are installed and workspace is sourced