rosbag record录包(ROS入门学习笔记五)

1.rosbag record命令

rosbag record命令是用于在ros系统中录取系统中其他ros节点发出来的topic的message。录取的的包可以使用rosbag play命令来回放,订阅这些消息的node节点就可以收到这些消息,进而执行对应的程序。这样的话,就可以将自动驾驶汽车或者无人机、机器人等自动化机器在室外一些环境下遇到的问题,通过录包的方法拿到办公室来仔细研究解决。

rosbag record命令在终端下显示完整命令参数如下:

kitty@kitty-TM1705:~$ rosbag record -help
Usage: rosbag record TOPIC1 [TOPIC2 TOPIC3 ...]

Record a bag file with the contents of specified topics.

Options:
  -h, --help            show this help message and exit
  -a, --all             record all topics
  -e, --regex           match topics using regular expressions
  -x EXCLUDE_REGEX, --exclude=EXCLUDE_REGEX
                        exclude topics matching the follow regular expression
                        (subtracts from -a or regex)
  -q, --quiet           suppress console output
  -o PREFIX, --output-prefix=PREFIX
                        prepend PREFIX to beginning of bag name (name will
                        always end with date stamp)
  -O NAME, --output-name=NAME
                        record to bag with name NAME.bag
  --split               split the bag when maximum size or duration is reached
  --max-splits=MAX_SPLITS
                        Keep a maximum of N bag files, when reaching the
                        maximum erase the oldest one to keep a constant number
                        of files.
  --size=SIZE           record a bag of maximum size SIZE MB. (Default:
                        infinite)
  --duration=DURATION   record a bag of maximum duration DURATION in seconds,
                        unless 'm', or 'h' is appended.
  -b SIZE, --buffsize=SIZE
                        use an internal buffer of SIZE MB (Default: 256, 0 =
                        infinite)
  --chunksize=SIZE      Advanced. Record to chunks of SIZE KB (Default: 768)
  -l NUM, --limit=NUM   only record NUM messages on each topic
  --node=NODE           record all topics subscribed to by a specific node
  -j, --bz2             use BZ2 compression
  --lz4                 use LZ4 compression
  --tcpnodelay          Use the TCP_NODELAY transport hint when subscribing to
                        topics.
  --udp                 Use the UDP transport hint when subscribing to topics.

rosbag record TOPIC1 [TOPIC2 TOPIC3 ...] 这是最简单的使用方法是。比如录取message_1的命令:rosbag record message_1;

通常的使用都是根据需求和可选的参数配合使用的,比如要录所有的topic,使用rosbag record -a命令。

2.录取过滤掉某个topic的其他topic

写个脚本来录取过滤掉某个topic之外的其他topic,并对录取的包名进行设置。

脚本recordbag.sh内容如下:

#!/bin/bash

rosbag record -a -O $1 -x "/monitor/(.*)"

执行该脚本:./recordbag.sh demo.bag   该脚本用于记录过滤掉/monitor/*之外的其他topic,并将记录的bag文件命名为demo.bag。

3.查看录包信息

kitty@kitty-TM1705:~/data/planing$ rosbag info trace9.bag 
path:        trace9.bag
version:     2.0
duration:    59.1s
start:       Jan 30 2019 17:45:47.95 (1548841547.95)
end:         Jan 30 2019 17:46:47.05 (1548841607.05)
size:        134.3 MB
messages:    151969
compression: none [163/163 chunks]
types:       dw_msg_center/ACU_IDS_MSG200            [6fca19ff04082b9b91134bf3c809b87d]
             dw_msg_center/ACU_IDS_MSG201            [f8c45d9c251631b5629150dc575a3faf]
             dw_msg_center/ACU_IDS_MSG202            [dada98444e4f6c228ef5f75bd811681d]
             dw_msg_center/ACU_IDS_MSG203            [84bb83386abd723dabf6df98f30e77f3]
             dw_msg_center/ACU_IDS_MSG204            [b0c14ebf8df5b3709a401af8572cde17]
             dw_msg_center/ACU_IDS_MSG205            [17726d19199f3bf4527372d0e750c771]
             dw_msg_center/ACU_IDS_MSG206            [093c5d6cda2583b7e8c90d1d76a7c022]
             dw_msg_center/ACU_IDS_MSG207            [c7d2ee979f0f53a4fc9f58047de0fd1a]
             dw_msg_center/ACU_IDS_MSGPKG            [56d0b3757a7249d85db835f851c15cab]
             dw_msg_center/Controller_LatticeMonitor [864285cebdf9b6d1d6d747e27ce03c7e]
             dw_msg_center/IDS_ACU_MSG100            [9092cd5255e954dbdef885474019b322]
             dw_msg_center/IDS_ACU_MSG101            [aca127ea13744b15f310195f098ae113]
             dw_msg_center/IDS_ACU_MSG102            [d1c71b254c504e45c5a44960619ddb85]
             dw_msg_center/IDS_ACU_MSG103            [0e63d4137dc1af190a150fd97a3f6a13]
             dw_msg_center/Imu_ImuInfo               [8c2618ce9c8ebb8e6af8e0db1894586a]
             dw_msg_center/Planner_LatticeMonitor    [a79314be0a00cb53a169977db794efe3]
             dw_msg_center/Radar_Center              [42b3d4965d672f2edc5aadbca336ff0f]
             dw_msg_center/Radar_Corner              [0d4f524a91be8edf20ad79bcc296fa9a]
             dw_msg_center/Radar_SensorTechCorner    [83ae891674f92197b7f2cc0bc3a5bf15]
             jsk_rviz_plugins/OverlayText            [7efc1ed34881f913afcee6ba02aa1242]
             nav_msgs/Odometry                       [cd5e73d190d741a2f92e81eda573aca7]
             nav_msgs/Path                           [6227e2b7e9cce15051f669a5e197bbf7]
             rosgraph_msgs/Log                       [acffd30cd6b6de30f120938c17c593fb]
             std_msgs/Float32                        [73fcbf46b49191e672908e50842a83d4]
             std_msgs/Int16                          [8524586e34fbd7cb1c08c5f5f1ca0e57]
             std_msgs/String                         [992ce8a1687cec8c8bd883ec73ca41d1]
             tf2_msgs/TFMessage                      [94810edda583a504dfda3829e70d7eec]
             visualization_msgs/MarkerArray          [d155b9ce5188fbaf89745847fd5882d7]
topics:      /Monitor_Controller               165 msgs    : dw_msg_center/Controller_LatticeMonitor
             /acu_ids_msg200                  5794 msgs    : dw_msg_center/ACU_IDS_MSG200           
             /acu_ids_msg201                  5794 msgs    : dw_msg_center/ACU_IDS_MSG201           
             /acu_ids_msg202                  5804 msgs    : dw_msg_center/ACU_IDS_MSG202           
             /acu_ids_msg203                  5794 msgs    : dw_msg_center/ACU_IDS_MSG203           
             /acu_ids_msg204                  5784 msgs    : dw_msg_center/ACU_IDS_MSG204           
             /acu_ids_msg205                  5784 msgs    : dw_msg_center/ACU_IDS_MSG205           
             /acu_ids_msg206                  5794 msgs    : dw_msg_center/ACU_IDS_MSG206           
             /acu_ids_msg207                  5793 msgs    : dw_msg_center/ACU_IDS_MSG207           
             /acu_ids_msgpkg                  5741 msgs    : dw_msg_center/ACU_IDS_MSGPKG           
             /ids_acu_msg100                   178 msgs    : dw_msg_center/IDS_ACU_MSG100           
             /ids_acu_msg101                   179 msgs    : dw_msg_center/IDS_ACU_MSG101           
             /ids_acu_msg102                   177 msgs    : dw_msg_center/IDS_ACU_MSG102           
             /ids_acu_msg103                   178 msgs    : dw_msg_center/IDS_ACU_MSG103           
             /imu/imu_msg                     1196 msgs    : dw_msg_center/Imu_ImuInfo              
             /monitor/acc_ped_value           5784 msgs    : std_msgs/Float32                       
             /monitor/brk_ped_value           5805 msgs    : std_msgs/Float32                       
             /monitor/control_mode            5834 msgs    : jsk_rviz_plugins/OverlayText           
             /monitor/control_mode_value      5741 msgs    : std_msgs/String                        
             /monitor/front_left_radar        5815 msgs    : visualization_msgs/MarkerArray         
             /monitor/front_middle_radar      5835 msgs    : visualization_msgs/MarkerArray         
             /monitor/front_right_radar       5772 msgs    : visualization_msgs/MarkerArray         
             /monitor/global_plan               30 msgs    : nav_msgs/Path                          
             /monitor/gps_pose                1186 msgs    : nav_msgs/Odometry                      
             /monitor/gps_quality_indicator   1196 msgs    : jsk_rviz_plugins/OverlayText           
             /monitor/gps_quality_value       1180 msgs    : std_msgs/Int16                         
             /monitor/local_plan               165 msgs    : nav_msgs/Path                          
             /monitor/rear_left_radar         5835 msgs    : visualization_msgs/MarkerArray         
             /monitor/rear_right_radar        5751 msgs    : visualization_msgs/MarkerArray         
             /monitor/speed_value             5741 msgs    : std_msgs/Float32                       
             /monitor/steering_value          5825 msgs    : std_msgs/Float32                       
             /monitor_lattice                  165 msgs    : dw_msg_center/Planner_LatticeMonitor   
             /radar/dw_radar_front_center     5835 msgs    : dw_msg_center/Radar_Center             
             /radar/dw_radar_front_left       5825 msgs    : dw_msg_center/Radar_SensorTechCorner   
             /radar/dw_radar_front_right      5751 msgs    : dw_msg_center/Radar_SensorTechCorner   
             /radar/dw_radar_rear_left        5741 msgs    : dw_msg_center/Radar_Corner             
             /radar/dw_radar_rear_right       5761 msgs    : dw_msg_center/Radar_Corner             
             /rosout                            24 msgs    : rosgraph_msgs/Log                       (5 connections)
             /rosout_agg                        33 msgs    : rosgraph_msgs/Log                      
             /tf                              1183 msgs    : tf2_msgs/TFMessage                     
             /tf_static                          1 msg     : tf2_msgs/TFMessage
发布了72 篇原创文章 · 获赞 190 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/moyu123456789/article/details/97283335