1、运行下面命令
roscore rosrun turtlesim turtlesim_node rosrun turtlesim turtle_teleop_key
rostopic list -vdisplay:
Published topics:
* /turtle1/color_sensor [turtlesim/Color] 1 publisher
* /rosout [rosgraph_msgs/Log] 3 publishers
* /rosout_agg [rosgraph_msgs/Log] 1 publisher
* /turtle1/cmd_vel [geometry_msgs/Twist] 1 publisher
* /turtle1/pose [turtlesim/Pose] 1 publisher
Subscribed topics:
* /rosout [rosgraph_msgs/Log] 1 subscriber
* /chatter [std_msgs/String] 1 subscriber
* /turtle1/cmd_vel [geometry_msgs/Twist] 1 subscriber
3、创建一个裤袋文件bagfiles (ps: making a temporary directory to record data)
mkdir ~/bagfiles cd ~/bagfiles rosbag record -a # 生成begins with the year, data, and time and the suffix .bag4、在~/bagfiles目录查看 .bag 文件
rosbag info <your bagfile>5、reproduce behavior in the running system重现行为:
we will see a list about: topic name主题名 、类型、每条主题包含的信息条数
This tells us topic names and types as well as the number (count) of each message topic contained in the bag file.
rosbag play <your bagfile>你会看到:
rosbag play <your bagfile>
6、记录数据的一个子集
线运行:rostopic list -v 查看 发布者和订阅着 选择你要记录的主题
rosbag record -O subset 主题1 主题2 主题3 ...
rosbag record -O subset /turtle1/cmd_vel /turtle1/pose