上一节完成了对nodes, Topic的理解,再深入一步: Services and Parameters
-----------------以下是我作的关于ROS Service的总结-------------------
关于ROS Service的总结:
-
什么是ROS Service: 在wiki/tutorials/1.7 中,有“Understanding ROS Services and Parameters”一节, 我不理解为何要把service与parameter放在一起介绍。
[概念concepts] ROS Service: Another way that Nodes communicate with nodes. A_node send a request to B_node, and B_node give a response.
[命令Commands] sorservice list/call/type/find/uri & rossrv - this command is mainly for the .srv files operations
- 什么定义了ROS Service: *.srv file - srv文件: 在 wiki/tutorials/1.10 中,有“Creating Msg & Srv” 一节,我还是没理解为何要把srv文件和msg文件放在一起介绍。
The function of srv file: Discribe/define the data type for a service. The data type of Req. & Resp. divided by '---'
the srv file typically stored under ../workspace/src/package_name/srv/ path.
[Create the srv file]: step1. echo "..." ./srv/filename.srv step2. uncomment "gen_srv()" in CMakeList.txt file.
[Use the srv file]: $rossrv show filename.srv , rossrv -- info of service definitions
- 什么程序实现了ROS Servie: 在 wiki/tutorials/1.14 中,有“Writing a simpleService and Client(C++)” 一节, 其中详细介绍了Service_node & Client_node的程序实现。
-----------------以上是我作的关于ROS Service的总结-------------------
-----------------以下是我最初学习它的时候的手记-----------------
- Understanding ROS Services and Parameters
This tutorial introduces ROS services, and parameters as well as using therosservice androsparam commandline tools.
Description: This tutorial introduces ROS services, and parameters as well as using the rosservice and rosparam commandline tools.
ROS Services
Services are another way that nodes can communicate with each other. Services allow nodes to send a request and receive a response.
Using rosservice
*rosservice* can easily attach to ROS's client/service framework with services. rosservice has many commands that can be used on topics, as shown below:
Usage:
rosservice list print information about active services
rosservice call call the service with the provided args
rosservice type print service type
rosservice find find services by service type
rosservice uri print service ROSRPC uri
list
type
call
Using 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:
Usage:
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
list
set/get
dump/load
Stack, Package, Nodes/Messages/Services/Libraries/Tools, 关系复习图如下: