Learning ROS: Recording and playing back data
阅读原文时间:2023年07月12日阅读:1

本文主要部分来源于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.

making a temporary directory to record data and then running rosbag record with the option -a

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(真实历史)时不完全一样,因为:

  • rosbag是通过记录topics来回放模拟历史msgs信息。
  • 仿真的轨迹与 初始状态有关系。
  • 考虑到系统调度的复杂性,难以保证时间完全精确, 仿真的轨迹与 微小的时间差 也有关系。

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章