(六)ROS服务和参数理解
来源:互联网 发布:你呀上瘾了网络剧资源 编辑:程序博客网 时间:2024/06/08 10:34
参考网址:
调用 $ rosservice call clear
$ rosparam getbackground_g
http://www.ros.org/wiki/ROS/Tutorials/UnderstandingServicesParams
1,ROS服务
服务是节点通信之间的另外一种方式,服务允许节点发送请求和接受响应。采用rosservice命令
(1) $rosservice
得到结果:
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 formore detailed usage, e.g. 'rosservice call -h'
之后为各个命令参数的解释:
I, $rosservice list
这个命令显示(比如小海龟例子)turtlesim节点提供的服务:
/clear/kill /reset /rosout/get_loggers /rosout/set_logger_level/spawn新的终端打开鼠标控制终端 $ rosrun turtle /turtle1/set_pen/turtle1/teleport_absolute /turtle1/teleport_relative/turtlesim/get_loggers /turtlesim/set_logger_level
II, $ rosservice type [service]
查看服务类型的详细情况:
比如$rosservice type clear
得到结果:std_srvs/Empty--表示当服务call时,没有任何参数(发送请求是没有数据,接受响应时也没有数据)
III, $ rosservice call [service][args]
比如小海龟运行的例子,运行轨迹如下:
调用 $ rosservice call clear
得到结果:
IV,当服务有参数的情况,
$ rosservice type spawn | rossrv show--显示服务描述
得到结果:
float32x float32 y float32 theta string name --- string name
$ rosservice call spawn 2 2 0.2 ""---创建新的小海龟,给定参数x,y,theta,name(这里name为空)他自动返回name:turtle2
(2),$ rosparam
该命令允许在ROS服务里存储和修改数据,这些参数包括integers,floats, boolean, dictionaries和lists。此命令用YAML标记,比如 1 isan integer, 1.0 isa float, one isa string, true isa boolean, [1, 2, 3] isa list of integers, and {a: b, c: d} isa dictionary
得到结果:
rosparamis a command-line tool for getting, setting, and deletingparameters from the ROS Parameter Server. Commands: rosparam setset parameter rosparam get get parameter rosparam load loadparameters from file rosparam dump dump parameters to file rosparamdelete delete parameter rosparam list list parameternames
I,$ rosparam list
对于小海龟的例子,turtlesim节点有3个参数表示背景颜色
得到结果:
/background_b/background_g /background_r/roslaunch/uris/host_jason_desktop__54527 /run_id
II,rosparam 设置和获取参数
用法:
$ rosparam set [param_name]
$ rosparam get [param_name]
例如,对于小海龟例子:
$ rosparam set background_r 150
得到如下结果:
$ rosparam getbackground_g
得到结果:
86
我们也可以得到所有的参数
$ rosparam get /
得到结果:
background_b:255 background_g: 86 background_r: 150 roslaunch: uris:{host_jason_desktop__54527: 'http://jason-desktop:54527/'} run_id:5421a332-1df1-11e0-ad25-0025116338f1
III,rosparam dump 和 rosparamload
$ rosparam dump [file_name]---将得到的参数进行存储到一个文件中
比如小海龟的例子:
$ rosparam dump params.yaml---将参数存储到params.yaml文件中
$ rosparam load [file_name] [namespace]---重载参数文件,并写入新的命名空间
比如小海龟的例子:
$ rosparam load params.yaml copy---将params.yaml 写入copy文件夹或者命名空间内
$ rosparam get copy/background_b---查看获取background_b参数的值
得到结果:
255
0 0
- (六)ROS服务和参数理解
- ROS学习笔记六:理解ROS服务和参数
- 理解ROS服务和参数(七)
- ROS学习--(七)理解ROS服务和参数
- ROS教程(七):理解ROS服务和参数
- ros:(4)理解ROS服务和参数
- ROS7—理解ROS服务和参数
- ROS入门_1.10 理解ROS服务和参数
- ROS入门_1.10 理解ROS服务和参数
- ROS)服务和参数
- ROS服务和参数
- ROS学习--(六)理解ROS节点和话题
- ROS学习(基于Ubuntu 15.04 和ROS Jade)第三章 ROS核心教程 之 7 理解ROS服务和参数
- ROS教程(六):理解ROS话题
- rosparam和ROS参数服务
- 理解ROS话题(六)
- ROS Learning-009 beginner_Tutorials ROS服务 和 ROS参数
- ROS服务和参数的分析
- js 导出table并保存为excel文件
- Java EE7和Maven工程入门---- 一个简单Maven工程的结构
- 将5350 i2c clk设置为gpio 中断模式的方法
- (五)ROS主题理解
- HDU-4568-Hunter
- (六)ROS服务和参数理解
- “4K”时代将来临!标准/技术一网打尽
- 20140717
- 获取事件对象
- 关于MAVEN找不到JDK的那点事
- 关于什么样的用户权限可以把计算机加入windows domain的辩论
- CRC32算法详细推导(3)
- 黑马程序员-ARC,Block与protocol
- Ubuntu 12.04中文输入法的安装