turtlebot3-burger_150.png
turtlebot3-waffle-pi_150.png
turtlebot3-arm_150.png
walking-y2_150.png
turbot3-multi_150.png
turbot3-dl-ros1_150.png
turbot3-ai.png
turbot3-dl-ros2_150.png
turbot3-slam_150.png
turbot3-arm_150.png
turtlebot4-lite_150.png
turtlebot4-pro_150.png
turbot4-dl_150.png
turbot4-ai_150.png
aidriving-racebot_150.png
aidriving-autodrive_150.png
turtlebot-arm_150.png
openmanipulator-x_150.png
Home » walking机器人仿真教程_视频版 » walking机器人仿真教程-rosbag录制和播放

walking机器人仿真教程-rosbag录制和播放

纠错,疑问,交流: 请进入讨论区请点击进入页面,扫码加入微信群或Q群进行交流

获取最新文章: 扫一扫加入“创客智造”公众号

walking机器人仿真教程-rosbag录制和回放

说明:

相关设备:

步骤:

  • 新建包保存目录
mkdir ~/bag_files
  • 新终端, 启动仿真
ros2 launch walking_gazebo world.launch.py
  • 新终端, 查看话题
$ ros2 topic list
/active
/clock
/cmd_vel
/cmd_vel_mux/input/default
/cmd_vel_mux/input/joystick
/cmd_vel_mux/input/keyop
/cmd_vel_mux/input/navigation
/cmd_vel_mux/input/remote
/cmd_vel_mux/input/webapp
/depth_camera/camera_info
/depth_camera/depth/camera_info
/depth_camera/depth/image_raw
/depth_camera/depth/image_raw/compressed
/depth_camera/depth/image_raw/compressedDepth
/depth_camera/depth/image_raw/theora
/depth_camera/image_raw
/depth_camera/image_raw/compressed
/depth_camera/image_raw/compressedDepth
/depth_camera/image_raw/theora
/depth_camera/points
/imu
/joint_states
/odom
/parameter_events
/performance_metrics
/rgb_camera/camera_info
/rgb_camera/image_raw
/rgb_camera/image_raw/compressed
/rgb_camera/image_raw/compressedDepth
/rgb_camera/image_raw/theora
/robot_description
/rosout
/scan
/tf
/tf_static
  • 录制全部包
cd ~/bag_files
ros2 bag record -a
  • 录制指定包
$ cd ~/bag_files
$ ros2 bag record /odom
[INFO] [1649295753.205135530] [rosbag2_storage]: Opened database 'rosbag2_2022_04_07-09_42_33/rosbag2_2022_04_07-09_42_33_0.db3' for READ_WRITE.
[INFO] [1649295753.205372136] [rosbag2_recorder]: Listening for topics...
[INFO] [1649295753.211060000] [rosbag2_recorder]: Subscribed to topic '/odom'
[INFO] [1649295753.211652769] [rosbag2_recorder]: All requested topics are subscribed. Stopping discovery...
  • 按ctrl + C 中止
  • 会自动建立一个类似rosbag2_2022_04_07-09_42_33目录,并包含metadata.yaml和rosbag2_2022_04_07-09_42_33_0.db3
  • 录制指定包,并制定保存目录名
$ cd ~/bag_files
$ ros2 bag record -o subset /odom /imu
[INFO] [1649293844.111371681] [rosbag2_storage]: Opened database 'subset/subset_0.db3' for READ_WRITE.
[INFO] [1649293844.111521646] [rosbag2_recorder]: Listening for topics...
[INFO] [1649293844.117199109] [rosbag2_recorder]: Subscribed to topic '/odom'
[INFO] [1649293844.121867832] [rosbag2_recorder]: Subscribed to topic '/imu'
[INFO] [1649293844.122657320] [rosbag2_recorder]: All requested topics are subscribed. Stopping discovery...
^C[INFO] [1649294458.114834481] [rclcpp]: signal_handler(signal_value=2)
[INFO] [1649294458.118055898] [rosbag2_cpp]: Writing remaining messages from cache to the bag. It may take a while
  • 会自动建立一个类似subset目录,并包含metadata.yaml subset_0.db3
  • 查看rosbag信息
$ ros2 bag info subset 

Files:             subset_0.db3
Bag size:          35.1 MiB
Storage id:        sqlite3
Duration:          613.990s
Start:             Apr  7 2022 09:10:44.122 (1649293844.122)
End:               Apr  7 2022 09:20:58.113 (1649294458.113)
Messages:          75864
Topic information: Topic: /imu | Type: sensor_msgs/msg/Imu | Count: 58622 | Serialization Format: cdr
                   Topic: /odom | Type: nav_msgs/msg/Odometry | Count: 17242 | Serialization Format: cdr
  • 回放rosbag包
$ ros2 bag play subset
[INFO] [1649295908.026950105] [rosbag2_storage]: Opened database 'subset/subset_0.db3' for READ_ONLY.
[INFO] [1649295908.036916415] [rosbag2_storage]: Opened database 'subset/subset_0.db3' for READ_ONLY.
  • 查看话题
$ ros2 topic list
/imu
/odom
/parameter_events
/rosout

演示视频

<iframe height=498 width=100% src="//player.bilibili.com/player.html?aid=768413456&bvid=BV1vr4y1J7tV&cid=582827270&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

纠错,疑问,交流: 请进入讨论区请点击进入页面,扫码加入微信群或Q群进行交流

获取最新文章: 扫一扫加入“创客智造”公众号


标签: walking机器人仿真教程