Understanding ROS Services and Parameters

service是nodes之间通信的一种方式,允许nodes send a request and recieve a response。

  • rosservice
  • rosparam

roservice

rosservice list         print information about active services   #展示有哪些service
rosservice call call the service with the provided args #rosservice call [service] [args]
rosservice type print service type #rosservice type [service]
rosservice find find services by service type
rosservice uri print service ROSRPC uri

rosparam

rosparam allows you to store and manipulate data on the ROS Parameter Server. The Parameter Server can store integers, floats, boolean, dictionaries, and lists. rosparam uses the YAML markup language for syntax. In simple cases, YAML looks very natural: 1 is an integer, 1.0 is a float, one is a string, true is a boolean, [1, 2, 3] is a list of integers, and {a: b, c: d} is a dictionary. rosparam has many commands that can be used on parameters, as shown below:

rosparam set            set parameter       # rosparam set /background_r 150
rosparam get get parameter # rosparam get /background_g
rosparam load load parameters from file
rosparam dump dump parameters to file
rosparam delete delete parameter
rosparam list list parameter names

dump load用法举例

rosparam dump [file_name] [namespace]
rosparam load [file_name] [namespace] rosparam dump params.yaml #把所有的参数写入params.yaml
rosparam load params.yaml copy #加载param.yaml的参数到新的namespace(新的namespace名字为copy)
rosparam get /copy/background_b #获取上一步中的新的namespace中的参数信息

在set parameter以后必须调用rosservice call /clear使其生效

This changes the parameter value, now we have to call the clear service for the parameter change to take effect:

rosservice call /clear

rosparam用来存储及操作位于Parameter Server的数据.

上一篇:wpf,离线状态下部分功能不可用。


下一篇:[原创]EnterpriseDB测试key申请方法