Welcome to YDLIDAR 4ROS LiDAR repository
19.Topic message recording and playback
19.Topic message recording and playback
ros provides the rosbag tool for recording and playing data. It records the data in the specified rostopic into a data package with a .bag suffix, which facilitates offline analysis and processing of the data.
19.1. rosbag command
The commands of rosbag are as follows:

Commonly used ones are record and play, which are recording messages and playing messages respectively.
19.1.2 record recording message
The command format of rosbag record recording message is,
rosbag record /topic_nameAmong them, /topic_name is the name of the topic where the message needs to be recorded. If the parameter -a is provided, for example,
xxxxxxxxxxrosbag record -aWith the parameter -a, it means recording all current topic data without specifying a certain topic. Of course, you can also record multiple topics that you are interested in, for example,
xxxxxxxxxxrosbag record /topic_name1 /topic_name2 When you want to stop recording, press ctrl c to stop. The data packet will be named after the current time, with the suffix .bag, and saved in the terminal directory where the recording command is run. If you want to specify the name of the generated data packet, add the parameter -O on the command line, for example,
xxxxxxxxxxrosbag record -O save_topic.bag /topic_name
19.1.3 View packet information
The command format of rosbag info to view packet information is,
xxxxxxxxxxrosbag info file_name.bag
Open the terminal in the folder where the data package is located, and then enter the above command to see the information of the data package, including topic name, size, data type, etc., for example,

You can also use the parameter -y to convert it into YAML format for viewing.
xxxxxxxxxxrosbag info -y file_name.bag
for example,

19.1.4. Play data packets
The command format of rosbag play to play data packets is,