如何使用rosbag命令
以rosbag filter为例:过滤掉指定topic的数据。
test@XiaoXin:~/debug$ rosbag -h
Usage: rosbag <subcommand> [options] [args]
A bag is a file format in ROS for storing ROS message data. The rosbag command can record, replay and manipulate bags.
Available subcommands:
check Determine whether a bag is playable in the current system, or if it can be migrated.
compress Compress one or more bag files.
decompress Decompress one or more bag files.
decrypt Decrypt one or more bag files.
encrypt Encrypt one or more bag files.
filter Filter the contents of the bag.
fix Repair the messages in a bag file so that it can be played in the current system.
help
info Summarize the contents of one or more bag files.
play Play back the contents of one or more bag files in a time-synchronized fashion.
record Record a bag file with the contents of specified topics.
reindex Reindexes one or more bag files.
For additional information, see http:
test@XiaoXin:~/debug$ rosbag filter -h
Usage: rosbag filter [options] INBAG OUTBAG EXPRESSION
EXPRESSION can be any Python-legal expression.
The following variables are available:
* topic: name of topic
* m: message
* t: time of message (t.secs, t.nsecs)
Filter the contents of the bag.
Options:
-h, --help show this help message and exit
-p PRINT-EXPRESSION, --print=PRINT-EXPRESSION
Python expression to print for verbose debugging. Uses
same variables as filter-expression
test@XiaoXin:~/debug$
EXPRESSION可以是任何合法的Python表达式,意味着可使用Python关键字加上文支持的三个变量灵活地设置过滤条件。此外还可使用[-p PRINT-EXPRESSION]打印更详细调试信息。
命令实例如下
rosbag filter -p topic src.bag dest.bag "topic != '/Your topic name'"
总结
举一反三,linux下大多数库都可以使用-h命令查看支持的操作,遇到不明白之处,首先应访问官网查询技术手册,网上博客大多只是翻译官网文档罢了。
|