Start, pause, resume, and stop a recording session dynamically while messages are being published from multiple data sources. The publishing continues uninterrupted, and you can control recording manually or based on external conditions.
Create a node for a vehicle system that publishes telemetry, camera, and lidar data.
By default, the recorder captures all topics. In this example, you record topics using IncludeRegex and ExcludeTopics filters. It includes all topics matching /car* but excludes the back camera feed.
Set up message structures for telemetry, camera, and temperature data.
Publishing continues regardless of the recording state. The callback function sends telemetry, camera, and temperature messages at regular intervals until all messages are published or the script ends.
Create and start a timer to publish messages at a fixed rate.
You can pause, resume, or stop recording manually at any time or based on external conditions. These options enable you to control the recording during a live session.
After stopping the recording, inspect the recorded topics and message types.
NumMessages MessageType
___________ _______________
/car_telemetry 1 std_msgs/String
You can see that messages published when the recording was active are stored in the bag file, while those published when the recording was paused are not recorded.