节点都是各自独立的可执行文件,节点能够通过主题,服务或参数服务器与其他节点通信,ROS通过节点将代码和功能解耦,提高了系统的容错能力和可维护性。
roscore 是你在运行所有ROS程序前首先要运行的命令,为了保证节点能通讯,至少要有一个roscore在运行,roscore定义为master+parameter server+rosout
rosnode:
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
rosrun
rosrun [--prefix cmd] [--debug] PACKAGE EXECUTABLE [ARGS]
主题
rqt_graph能够创建一个显示当前系统运行情况的动态图形,我们借助它来学习主题和节点之间的关系,执行
rosrun rqt_graph rqt_graph
rostopic:
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 type
获取帮助:rostopic command -h
消息和服务
msg文件存放在package的msg目录下,srv文件则存放在srv目录下,实际上就是每行声明一个数据类型和变量名。可以使用的数据类型如下:
int8, int16, int32, int64 (plus uint*)
float32, float64
string
time, duration
other msg files(header)
variable-length array[] and fixed-length array[C]
创建和使用msg srv
rossrv/rosmsg:
rossrv/rosmsg show Show service/message description
rossrv/rosmsg list List all services/messages
rossrv/rosmsg md5 Display service/message md5sum
rossrv/rosmsg package List services/messages in a package
rossrv/rosmsg packages List packages that contain services/messages
服务
服务是节点之间通讯的另一种方式。服务允许节点发送请求(request) 并获得一个响应(response)
rosservice:
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
获取帮助:rosserverice command -h
与rossrv区别:provides information related to ROS service definitions
参数服务器
参数服务器能够存储整型、浮点、布尔、字符串、字典和列表等数据类型。rosparam使用YAML标记语言的
rosparam:
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 command -h