繼續ROS的研究,今天的內容是rosbag包的回放。html
1:錄製rosbagnode
1 cd catkin_ws #進入工做空間 2 mkdir bagfile/ #建立bagfile文件夾 3 sudo chmod -R 777 ~/catkin_ws/bagfile/ #修改文件夾權限 4 cd bagfile/ #進入bagfile文件夾 5 rosbag record -a #記錄發佈的topics
2:啓動話題node,消息發佈器繼續用上一篇寫好的,有不清楚的能夠點這裏看消息發佈器和訂閱器spa
1 cd ~/catkin_ws #進入工做空間 2 rosrun pub_sub_test pub_string #啓動話題發佈
3:回放rosbagcode
1 rosbag info 2019-08-23-02-18-48.bag #查看回放信息
path: 2019-08-23-02-18-48.bag version: 2.0 duration: 21.4s start: Aug 23 2019 02:18:48.00 (1566551929.00) end: Aug 23 2019 02:19:10.41 (1566551950.41) size: 113.9 KB messages: 639 compression: none [1/1 chunks] types: rosgraph_msgs/Log [acffd30cd6b6de30f120938c17c593fb] std_msgs/String [992ce8a1687cec8c8bd883ec73ca41d1] topics: /chatter 212 msgs : std_msgs/String /rosout 215 msgs : rosgraph_msgs/Log (2 connections) /rosout_agg 212 msgs : rosgraph_msgs/Log
1 rosbag play 2019-08-23-02-18-48.bag #話題回放
以上就算完成了錄製和回放的最簡單功能,其餘複雜場景只能之後有空再慢慢折騰了......htm