1.先执行如下命令(分别在三个Terminal运行):
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
执行完后,在第三个命令的Terminal里按几次方向键。
2.接下来执行如下命令将当前所有Topic都记录到bag里:
mkdir ~/ros/bagfiles
cd ~/ros/bagfiles/
rosbag record -a
执行完后,按CTRL+c中断。
3.执行如下命令查看保存的.bag文件的信息:
rosbag info 2017-06-18-20-48-49.bag
执行后有如下内容打印输出:
path: 2017-06-18-20-48-49.bag
version: 2.0
duration: 26.9s
start: Jun 18 2017 20:48:49.72 (1497790129.72)
end: Jun 18 2017 20:49:16.59 (1497790156.59)
size: 242.0 KB
messages: 3358
compression: none [1/1 chunks]
types: geometry_msgs/Twist [9f195f881246fdfa2798d1d3eebca84a]
rosgraph_msgs/Log [acffd30cd6b6de30f120938c17c593fb]
turtlesim/Color [353891e354491c51aabe32df673fb446]
turtlesim/Pose [863b248d5016ca62ea2e895ae5265cf9]
topics: /rosout 7 msgs : rosgraph_msgs/Log (2 connections)
/turtle1/cmd_vel 8 msgs : geometry_msgs/Twist
/turtle1/color_sensor 1673 msgs : turtlesim/Color
/turtle1/pose 1670 msgs : turtlesim/Pose
4.执行如下命令将保存的.bag文件加载进来(相当于之前的Topic操作记录下来后重新播放执行):
rosbag play 2017-06-18-20-48-49.bag
5.部分记录
rosbag record -O subset /turtle1/cmd_vel /turtle1/pose
6.参考网址:http://wiki.ros.org/ROS/Tutorials/Recording%20and%20playing%20back%20data
网友评论