本文主要部分来源于ROS官网的Tutorials.
Description: This tutorial will teach you how to record data from a running ROS system into a .bag file, and then to play back the data to produce similar behavior in a running system.
roscore &
rosrun turtlesim turtlesim_node &
rosrun turtlesim turtle_teleop_key
rostopic list -v # examine the full list of topics that are currently being published in the running system.
mkdir ~/bagfiles
cd ~/bagfiles
rosbag record -a # Now all published topics will be accumulated in a bag file.
现在可以用方向键控制乌龟运动,所有Topics都会被记录到*.bag文件,本例文件名是当前时间。
接下来回放:
rosbag play
可以看到乌龟根据回放的message运动。
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
rosbag record -O subset /turtle1/cmd_vel /turtle1/pose # 只记录感兴趣的topics, 记录到subset.bag中
play(回放模拟)的效果可能和record(真实历史)时不完全一样,因为:
手机扫一扫
移动阅读更方便
你可能感兴趣的文章