歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

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-
Copyright © Linux教程網 All Rights Reserved