ROS_Kinetic_13 ROS数据录制与回放

ROS_Kinetic_13 ROS数据录制与回放

官网教程:http://wiki.ros.org/cn/ROS/Tutorials/Recording%20and%20playing%20back%20data

录制数据

~$ roscore

~$ rosrun turtlesim turtlesim_node

~$ rosrun turtlesim turtle_teleop_key

~$ rostopic list -v

Published topics:
 * /turtle1/color_sensor [turtlesim/Color] 1 publisher
 * /turtle1/cmd_vel [geometry_msgs/Twist] 1 publisher
 * /rosout [rosgraph_msgs/Log] 2 publishers
 * /rosout_agg [rosgraph_msgs/Log] 1 publisher
 * /turtle1/pose [turtlesim/Pose] 1 publisher

Subscribed topics:
 * /turtle1/cmd_vel [geometry_msgs/Twist] 1 subscriber
 * /rosout [rosgraph_msgs/Log] 1 subscriber

~$ mkdir tempbagfiles

~$ cd tempbagfiles

~/tempbagfiles$ rosbag record -a

[ INFO] [1464622786.642608299]: Recording to 2016-05-30-23-39-46.bag.
[ INFO] [1464622786.643371124]: Subscribing to /turtle1/color_sensor
[ INFO] [1464622786.650218953]: Subscribing to /turtle1/cmd_vel
[ INFO] [1464622786.657875320]: Subscribing to /rosout
[ INFO] [1464622786.664989967]: Subscribing to /rosout_agg
[ INFO] [1464622786.670321801]: Subscribing to /turtle1/pose

检查数据

~/tempbagfiles$ rosbag info 2016-05-30-23-39-46.bag

path:        2016-05-30-23-39-46.bag
version:     2.0
duration:    2:58s (178s)
start:       May 30 2016 23:39:46.68 (1464622786.68)
end:         May 30 2016 23:42:45.24 (1464622965.24)
size:        1.5 MB
messages:    22780
compression: none [2/2 chunks]
types:       geometry_msgs/Twist [9f195f881246fdfa2798d1d3eebca84a]
             rosgraph_msgs/Log   [acffd30cd6b6de30f120938c17c593fb]
             turtlesim/Color     [353891e354491c51aabe32df673fb446]
             turtlesim/Pose      [863b248d5016ca62ea2e895ae5265cf9]
topics:      /rosout                    11 msgs    : rosgraph_msgs/Log   (2 connections)
             /rosout_agg                 7 msgs    : rosgraph_msgs/Log  
             /turtle1/cmd_vel          589 msgs    : geometry_msgs/Twist
             /turtle1/color_sensor   11087 msgs    : turtlesim/Color    
             /turtle1/pose           11086 msgs    : turtlesim/Pose

回放数据

~/tempbagfiles$ rosbag play 2016-05-30-23-39-46.bag

[ INFO] [1464623082.857050437]: Opening 2016-05-30-23-39-46.bag

Waiting 0.2 seconds after advertising topics... done.

Hit space to toggle paused, or 's' to step.
 [RUNNING]  Bag Time: 1464622881.662740   Duration: 94.985623 / 178.560502

~/tempbagfiles$ rosbag play -r 20 2016-05-30-23-39-46.bag

[ INFO] [1464623266.773542306]: Opening 2016-05-30-23-39-46.bag

Waiting 0.2 seconds after advertising topics... done.

Hit space to toggle paused, or 's' to step.
 [RUNNING]  Bag Time: 1464622965.207398   Duration: 178.530281 / 178.560502     
Done.


录制数据子集

~/tempbagfiles$ rosbag record -O subset /turtle1/command_velocity /turtle1/pose

[ INFO] [1464623367.500278060]: Subscribing to /turtle1/command_velocity
[ INFO] [1464623367.505078209]: Subscribing to /turtle1/pose
[ INFO] [1464623367.509689375]: Recording to subset.bag.

~/tempbagfiles$ rosbag info subset.bag

path:        subset.bag
version:     2.0
duration:    52.9s
start:       May 30 2016 23:49:27.71 (1464623367.71)
end:         May 30 2016 23:50:20.61 (1464623420.61)
size:        255.9 KB
messages:    3297
compression: none [1/1 chunks]
types:       turtlesim/Pose [863b248d5016ca62ea2e895ae5265cf9]
topics:      /turtle1/pose   3297 msgs    : turtlesim/Pose

:~/tempbagfiles$ rosbag play -r 4 subset.bag

[ INFO] [1464623465.046134599]: Opening subset.bag

Waiting 0.2 seconds after advertising topics... done.

Hit space to toggle paused, or 's' to step.
 [RUNNING]  Bag Time: 1464623420.578935   Duration: 52.866810 / 52.898519     
Done.


-End-

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangrelay

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值