Services

When you need to communicate with nodes and receive a reply in an RPC fashion, you cannot do it with topics; you need to do it with services.

Services are developed by the user and standard services don't exist for nodes. The files with the source code of the services are stored in the srv folder.

Similar to topics, services have an associated service type that is the package resource name of the .srv file. As with other ROS filesystem-based types, the service type is the package name and the name of the .srv file. For example, the chapter2_tutorials/srv/chapter2_srv1.srv file has the chapter2_tutorials/chapter2_srv1 service type.

ROS has two command-line tools to work with services: rossrv and rosservice. With rossrv, we can see information about the services' data structure, and it has exactly the same usage as rosmsg.

With rosservice, we can list and query services. The supported commands are as follows:

  • rosservice call /service args: This calls the service with the arguments provided
  • rosservice find msg-type: This finds services by service type
  • rosservice info /service: This prints information about the service
  • rosservice list: This lists the active services
  • rosservice type /service: This prints the service type
  • rosservice uri /service: This prints the ROSRPC URI service
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.72.165