Rosbag

Recording rosbags are super useful for playback.

Some rosbags

https://github.com/ros2/rosbag2

Rosbags come into two formats, .db3 or .mcap. It seems that Foxglove invented / standardized mcap https://foxglove.dev/blog/introducing-the-mcap-file-format

── sensors_2023-01-03_12-46-13_-0500/
	β”œβ”€ sensors_2023-01-03_12-46-13_-0500_0.db3
	β”œβ”€ sensors_2023-01-03_12-46-13_-0500_1.db3
	β”œβ”€ sensors_2023-01-03_12-46-13_-0500_2.db3
	β”œβ”€ sensors_2023-01-03_12-46-13_-0500_3.db3
	β”œβ”€ ...
	└──  metadata.yaml

Why was MCAP invented?

The main reason is that ROS messages are not self-contained. One does not know the format of these messages. It is difficult for third-party tools to read. https://foxglove.dev/blog/introducing-the-mcap-file-format https://github.com/ros2/rosbag2/issues/782

MCAP files are alsoΒ completely self-contained – message schemas are embedded in the file, and no additional dependencies are required for decoding.

Recording Rosbags

To record the F1TENTH topics that I am interested in, to debug RRT:

ros2 bag record <topic_name>

To record all topics

ros2 bag record -o <bag_name> -a

ros2 bag record -o 0.9x_e7_floor5 -a The -a flag tells ros to record all topics.

To record a specific topic

ros2 bag record <topic_name>

Playing Rosbags

To play a bag, run

ros2 bag play <bag_name>

To loop forever, run

ros2 bag play -l <bag_name>

To play a bag at a slower speed, run

ros2 bag play -r 0.3 <bag_name>
  • though you can simply use the up and down arrows afterwards to speed up / slow down

If you want to know more commands, you can do

ros2 bag play --help

This is how I figured out how to play a specific topic

ros2 bag play <bag_name> --topics <topic_name>
  • add the --clock at the end, idk if that sometimes fixes the issue

ROS1 to ROS2 Bag

Use https://gitlab.com/ternaris/rosbags