how to record and play back data?ROS

本文介绍如何使用ROS(Robot Operating System)进行数据记录与回放。通过一系列命令操作,如启动ROS核心进程、运行海龟模拟节点、记录数据到.bag文件以及回放这些数据,帮助读者掌握ROS的基本使用技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、运行下面命令
roscore
rosrun turtlesim turtlesim_node 
rosrun turtlesim turtle_teleop_key


2、可有可无用于查看rostopic列表
rostopic list -v

display:
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 .bag
4、在~/bagfiles目录查看 .bag 文件
rosbag info <your bagfile>
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.
5、reproduce behavior in the running system重现行为:
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值