服务(services)是节点之间通讯的另一种方式。服务允许节点发送请求(request) 并获得一个响应(response)
rosservice list,列出当前的服务
rosservice type clear 查看clear服务的类型。
clear类型是std_srvs/Empty,这种表示clear不需要发送参数,也没有接收的响应。
rosservice call clear 调用clear命令,清除画板 如果正在运动过程中清除,会报一个异常
root@ben-virtual-machine:~# rosservice call clear
Unhandled exception in thread started by <bound method Thread.__bootstrap of <Thread(Thread-4, stopped daemon 140226454353664)>>
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 774, in __bootstrap
self.__bootstrap_inner()
File "/usr/lib/python2.7/threading.py", line 814, in __bootstrap_inner
(self.name, _format_exc()))
File "/usr/lib/python2.7/traceback.py", line 241, in format_exc
etype, value, tb = sys.exc_info()
AttributeError: 'NoneType' object has no attribute 'exc_info'
生成一个新乌龟,在对应的位置上,名字默认
rosservice call spawn 2 2 0.2 ""
rosparam使得我们能够存储并操作ROS 参数服务器(Parameter Server)上的数据。
参数服务器能够存储整型、浮点、布尔、字符串、字典和列表等数据类型。rosparam使用YAML标记语言的语法。一般而言,YAML的表述很自然:1 是整型, 1.0是浮点型, one是字符串, true是布尔, [1, 2, 3]是整型列表, {a: b, c: d}是字典. rosparam有很多指令可以用来操作参数,如下所示:
使用方法:
rosparam set 设置参数 rosparam get 获取参数 rosparam load 从文件读取参数 rosparam dump 向文件中写入参数 rosparam delete 删除参数 rosparam list 列出参数名
rosparam get / 可以显示所有参数 存储参数到yaml格式的文件中 rosparam dump params.yaml
你甚至可以将yaml文件重载入新的命名空间,比如说copy空间:
$ rosparam load params.yaml copy
来源:CSDN
作者:binbinyantai
链接:https://blog.csdn.net/wangbinyantai/article/details/104214560