ROS入门学习8:常用命令与工具

记录ROS常用命令与工具使用

常用命令

ROS shell命令
roscd [功能包名称]
rosls [功能包名称]
rosed [功能包名称] [文件名称]
ROS 执行命令
roscore [选项]
rosrun [功能包名称] [节点名称]
roslaunch [功能包名称] [launch文件名]
rosclean [选项]

注意:
当运行roscore时,如果显示以下警告信息,则意味着日志文件超过1GB,如果用户觉得会让系统不堪重负,请使用rosclean命令将其删除。
$ WARNING: disk usage in log directory [/xxx/.ros/log] is over 1GB.
$ rosclean check 检查日志使用情况
$ rosclean purge 删除ROS日志存储库

ROS信息命令
ROS catkin命令
catkin_create_pkg [功能包名称] [依赖性功能包1] [依赖性功能包2] ...
catkin_make [选项]
catkin_find [功能包名称]
ROS功能包命令
rospack [选项] [功能包名称]
rosdep [选项]
roslocate [选项] [功能包名称]

ROS消息命令

rosnode

1
2
3
4
5
6
7
8
9
10
11
12
tao@ubuntu:~$ rosnode -h
rosnode is a command-line tool for printing information about ROS Nodes.

Commands:
rosnode ping test connectivity to node
rosnode list list active nodes
rosnode info print information about node
rosnode machine list nodes running on a particular machine or list machines
rosnode kill kill a running node
rosnode cleanup purge registration information of unreachable nodes

Type rosnode <command> -h for more detailed usage, e.g. 'rosnode ping -h'
rosnode list 查看活动的节点列表
rosnode ping [节点名称] 与指定的节点进行连接测试
rosnode info [节点名称] 查看指定节点的信息
rosnode machine [PC名称或IP] 查看该PC中运行的节点列表
rosnode kill [节点名称] 停止指定节点的运行
rosnode cleanup 删除失连节点的注册信息

rostopic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
tao@ubuntu:~$ rostopic -h
rostopic is a command-line tool for printing information about ROS Topics.

Commands:
rostopic bw display bandwidth used by topic
rostopic delay display delay of topic from timestamp in header
rostopic echo print messages to screen
rostopic find find topics by type
rostopic hz display publishing rate of topic
rostopic info print information about active topic
rostopic list list active topics
rostopic pub publish data to topic
rostopic type print topic or field type

Type rostopic <command> -h for more detailed usage, e.g. 'rostopic echo -h'
rostopic list 显示活动的话题目录
rostopic echo [话题名称] 实时显示指定话题的消息内容
rostopic find [类型名称] 显示使用指定类型的消息的话题
rostopic type [话题名称] 显示指定话题的消息类型
rostopic bw [话题名称] 显示指定话题的消息带宽(bandwidth)
rostopic hz [话题名称] 显示指定话题的消息数据发布周期
rostopic info [话题名称] 显示指定话题的信息
rostopic pub [话题名称] [消息类型] [参数] 用指定的话题名称发布消息

rosservice

1
2
3
4
5
6
7
8
9
10
11
12
tao@ubuntu:~$ rosservice -h

Commands:
rosservice args print service arguments
rosservice call call the service with the provided args
rosservice find find services by service type
rosservice info print information about service
rosservice list list active services
rosservice type print service type
rosservice uri print service ROSRPC uri

Type rosservice <command> -h for more detailed usage, e.g. 'rosservice call -h'
rosservice list 显示活动的服务信息
rosservice info [服务名称] 显示指定服务的信息
rosservice type [服务名称] 显示服务类型
rosservice find [服务类型] 查找指定服务类型的服务
rosservice uri [服务名称] 显示ROSRPC URI服务
rosservice args [服务名称] 显示服务参数
rosservice call [服务名称] [参数] 用输入的参数请求服务

rosparam

  rosparam使得我们能够存储并操作ROS 参数服务器(Parameter Server)上的数据。参数服务器能够存储整型、浮点、布尔、字符串、字典和列表等数据类型。
  rosparam使用YAML标记语言的语法。一般而言,YAML的表述很自然:1 是整型, 1.0 是浮点型, one是字符串, true是布尔, [1, 2, 3]是整型列表, {a: b, c: d}是字典. rosparam有很多指令可以用来操作参数,如下所示:

1
2
3
4
5
6
7
8
9
10
tao@ubuntu:~$ rosparam -h
rosparam is a command-line tool for getting, setting, and deleting parameters from the ROS Parameter Server.

Commands:
rosparam set set parameter
rosparam get get parameter
rosparam load load parameters from file
rosparam dump dump parameters to file
rosparam delete delete parameter
rosparam list list parameter names
rosparam list 查看参数列表
rosparam get [参数名称] 获取参数值
rosparam set [参数名称] 设置参数值
rosparam dump [文件名称] 将参数保存到指定文件
rosparam load [文件名称] 获取保存在指定文件中的参数
rosparam delete [参数名称] 删除参数

rosmsg

1
2
3
4
5
6
7
8
9
10
11
12
tao@ubuntu:~$ rosmsg -h
rosmsg is a command-line tool for displaying information about ROS Message types.

Commands:
rosmsg show Show message description
rosmsg info Alias for rosmsg show
rosmsg list List all messages
rosmsg md5 Display message md5sum
rosmsg package List messages in a package
rosmsg packages List packages that contain messages

Type rosmsg <command> -h for more detailed usage
rosmsg list 显示所有消息
rosmsg show [消息名称] 显示指定消息
rosmsg md5 [消息名称] 显示md5sum
rosmsg package [功能包名称] 显示用于指定功能包的所有消息
rosmsg packages 显示使用消息的所有功能包

rossrv

1
2
3
4
5
6
7
8
9
10
11
12
tao@ubuntu:~$ rossrv -h
rossrv is a command-line tool for displaying information about ROS Service types.

Commands:
rossrv show Show service description
rossrv info Alias for rossrv show
rossrv list List all services
rossrv md5 Display service md5sum
rossrv package List services in a package
rossrv packages List packages that contain services

Type rossrv <command> -h for more detailed usage
rossrv list 显示所有服务
rossrv show [服务名称] 显示指定的服务信息
rossrv md5 [服务名称] 显示md5sum
rossrv package [功能包名称] 显示指定的功能包中用到的所有服务
rossrv packages 显示使用服务的所有功能包

rosbag

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
tao@ubuntu:~$ 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.
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://wiki.ros.org/rosbag
rosbag record [选项] [话题名称] 将指定话题的消息记录到bag文件
rosbag info [文件名称] 查看bag文件的信息
rosbag play [文件名称] 回放指定的bag文件
rosbag compress [文件名称] 压缩指定的bag文件
rosbag decompress [文件名称] 解压指定的bag文件
rosbag filter [输入文件] [输出文件] [选项] 生成一个删除了指定内容的新的bag文件
rosbag reindex bag [文件名称] 刷新索引
rosbag check bag [文件名称] 检查指定的bag文件是否能在当前系统中回放
rosbag fix [输入文件] [输出文件] [选项] 将由于版本不同而无法回放的bag文件修改成可以回放的文件

QT工具箱

  ROS提供一个qt架构的后台图形化工具套件rqt_common_plugins,便于可视化调试和分析。

安装QT工具箱

$ sudo apt-get install ros-kinetic-rqt
$ sudo apt-get install ros-kinetic-rqt-common-plugins

常用QT工具

+