Skip to content

Data Collection for Imitation Learning

Overview

Gather synchronized sensor streams and control commands while manually driving the racecar. This dataset will fuel supervised learning experiments in the next tutorial.

Prerequisites

  • Completed Rule-Based Lane Following
  • Car inspected, batteries charged, and mechanical brakes tested
  • Operator comfortable with remote or onboard driving controls
  • Storage space ≥ 20 GB on the car or attached SSD

Learning Objectives

  • Students can collect a dataset of expert driving demonstrations suitable for training a policy.
  • Configure rosbag2 to capture high-bandwidth camera, lidar, and control topics
  • Execute a consistent driving protocol across multiple laps
  • Annotate datasets with metadata for reproducibility

Tutorial Steps

1. Plan the Recording Session

  • Choose a track layout with clear lane markers.
  • Decide on driving modes (e.g., clockwise, counter-clockwise) and durations.
  • Prepare a checklist for weather, lighting, and surface conditions.

2. Configure Collection Launch File

  1. Create fri_data_collection/launch/record.launch.py with important topics:
    from launch import LaunchDescription
    from launch_ros.actions import Node
    
    def generate_launch_description():
        return LaunchDescription([
            Node(
                package='rosbag2_transport',
                executable='rb2_record',
                name='rosbag_record',
                parameters=[{
                    'storage_id': 'mcap',
                    'all': False,
                    'topics': [
                        '/camera/image_rect',
                        '/scan',
                        '/imu/data',
                        '/drive',
                        '/tf',
                        '/tf_static'
                    ]
                }]
            )
        ])
    
  2. Add compression (zstd) if disk bandwidth allows.

3. Warm Up the Sensors

  • Power the car and let sensors stabilize for 2–3 minutes.
  • Verify data streams in Foxglove.
  • Run the lane follower briefly to confirm calibration, then disable autonomy.

4. Execute the Drive

  1. Start recording:
    ros2 launch fri_data_collection record.launch.py bag_name:=2025-10-22-track-a
    
  2. Drive 5–10 laps at varied speeds. Include recovery maneuvers (stops, reversals) to diversify data.
  3. Verbally call out timestamps for notable events (e.g., sun glare) while an assistant logs them.
  4. End the recording with Ctrl+C and allow rosbag2 to finalize the metadata.

5. Annotate and Backup

  • Populate metadata.yaml describing track, conditions, drivers, anomalies.
  • Copy the bag to network storage:
    rsync -avh /data/bags/2025-10-22-track-a fri-archive:/archive/track_a/
    
  • Validate integrity with ros2 bag info.

6. Quality Checks

  • Plot steering vs. lane error to ensure sufficient variation.
  • Confirm camera frame drops < 2% and lidar spin count consistent.
  • Note any sections requiring manual labels (e.g., obstacles).

Wrap-Up

Publish a short write-up summarizing the session, then prep the dataset for the upcoming training pipeline.

Next Tutorial: Proceed to Train and Deploy an MLP Steering Policy.