package documentation

Command-line utility for querying ROS services, along with library calls for similar functionality. The main benefit of the rosservice Python library over the rospy ServiceProxy library is that rosservice supports type-introspection on ROS Services. This allows for both introspecting information about services, as well as using this introspection to dynamically call services.

From __init__.py:

Exception ROSServiceException Base class for rosservice-related exceptions
Exception ROSServiceIOException rosservice related to network I/O failure
Function call_service Call the specified service_name @param service_name: fully-resolved name of service to call @type service_name: str @param service_args: args to pass to service @type service_args: [any] @param service_class: (optional) service type class...
Function get_service_args Implements 'get service args' @param service_name: name of service to get arguments for @type service_name: str @raise ROSServiceException: if call command cannot be executed
Function get_service_class_by_name Get the service class using the name of the service. NOTE: this call results in a probe call to the service. @param service_name: fully-resolved name of service to call @type service_name: str @return: service class @rtype: ServiceDefinition: service class @raise ROSServiceException: if service class cannot be retrieved...
Function get_service_headers Utility for connecting to a service and retrieving the TCPROS headers. Services currently do not declare their type with the master, so instead we probe the service for its headers. @param service_name: name of service @type service_name: str @param service_uri: ROSRPC URI of service @type service_uri: str @return: map of header fields @rtype: dict @raise ROSServiceException: if service has invalid information @raise ROSServiceIOException: if unable to communicate with service...
Function get_service_list Get the list of services @param node: Name of node to get services for or None to return all services @type node: str @param namespace: Namespace to scope services to or None @type namespace: str @param include_nodes: If True, return list will be [service_name, [node]] @type include_nodes: bool @return: if include_nodes, services is service_name, [node]...
Function get_service_node @return: name of node that implements service, or None @rtype: str
Function get_service_type Get the type of the specified service_name. May print errors to stderr.
Function get_service_uri Retrieve ROSRPC URI of service.
Function has_service_args Check if service requires arguments @param service_name: name of service being called @type service_name: str @param service_class: (optional) service type class. If this argument is provided, it saves a probe call against the service @type service_class: Message class @return: True if service_name has request arguments @rtype: bool...
Function rosservice_find Lookup services by service_type @param service_type: type of service to find @type service_type: str @return: list of service names that use service_type @rtype: [str]
Function rosservicemain main entry point for rosservice command-line tool
Constant NAME Undocumented
Function _fullusage Print generic usage for rosservice
Function _get_master Undocumented
Function _optparse_service_only Parse command-line arguments for commands that take a service name only. Will cause a system exit if command-line argument parsing fails. @param cmd: command name, e.g. 'type' @type cmd: str @param argv: command-line arguments @type argv: [str]...
Function _resource_name_package pkg/typeName -> pkg, typeName -> None
Function _rosservice_args Implements 'rosservice args' @param service_name: name of service to get arguments for @type service_name: str @raise ROSServiceException: if call command cannot be executed
Function _rosservice_call Implements 'rosservice call' @param service_name: name of service to call @type service_name: str @param service_args: arguments to call service with @type service_args: [args] @param verbose: if True, print extra output @type verbose: bool @param service_class Message class: (optional) service type class...
Function _rosservice_cmd_args Parse 'args' command arguments and run command. Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if args command cannot be executed...
Function _rosservice_cmd_call Parse 'call' command arguments and run command. Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if call command cannot be executed...
Function _rosservice_cmd_find Implements 'rosservice type'
Function _rosservice_cmd_info Parse 'info' command arguments and run command Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if list command cannot be executed...
Function _rosservice_cmd_list Parse 'list' command arguments and run command Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if list command cannot be executed...
Function _rosservice_cmd_node Parse 'node' command arguments and run command. Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if node command cannot be executed...
Function _rosservice_cmd_type Parse 'type' command arguments and run command Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if type command cannot be executed...
Function _rosservice_cmd_uri Parse 'uri' command arguments and run command. Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if uri command cannot be executed...
Function _rosservice_info Implements 'rosservice info'. Prints information about a service.
Function _rosservice_list Implements 'rosservice list' @param namespace: Namespace to limit listing to or None @type namespace: str @param print_nodes: If True, also print nodes providing service @type print_nodes: bool @raise ROSServiceIOException: if the I/O issues prevent retrieving service information...
Function _rosservice_node Implements rosservice node command. Will cause system exit with error if service is unknown.
Function _rosservice_type Implements 'type' command. Prints service type to stdout. Will system exit with error if service_name is unknown.
Function _rosservice_uri Implements rosservice uri command. Will cause system exit with error if service_name is unknown.
Function _stdin_yaml_arg @return: iterator for next set of service args on stdin. Iterator returns a list of args for each call. @rtype: iterator
Function _succeed Utility that raises a ROSServiceException if ROS XMLRPC command fails @param args: (code, msg, val) ROS XMLRPC call return args @type args: (int, str, XmlRpcValue) @return: value argument from ROS XMLRPC call (third arg of tuple) @rtype: XmlRpcLegal value @raise ROSServiceException: if XMLRPC command does not return a SUCCESS code...
NAME: str =

Undocumented

Value
'rosservice'
def _get_master():

Undocumented

def _succeed(args):

Utility that raises a ROSServiceException if ROS XMLRPC command fails @param args: (code, msg, val) ROS XMLRPC call return args @type args: (int, str, XmlRpcValue) @return: value argument from ROS XMLRPC call (third arg of tuple) @rtype: XmlRpcLegal value @raise ROSServiceException: if XMLRPC command does not return a SUCCESS code

def get_service_headers(service_name, service_uri):

Utility for connecting to a service and retrieving the TCPROS headers. Services currently do not declare their type with the master, so instead we probe the service for its headers. @param service_name: name of service @type service_name: str @param service_uri: ROSRPC URI of service @type service_uri: str @return: map of header fields @rtype: dict @raise ROSServiceException: if service has invalid information @raise ROSServiceIOException: if unable to communicate with service

def get_service_type(service_name):

Get the type of the specified service_name. May print errors to stderr.

Parameters
service_namename of service, str
Returns
type of service or None, str
Raises
Unknown exceptionROSServiceIOException If unable to communicate with service
def _rosservice_type(service_name):

Implements 'type' command. Prints service type to stdout. Will system exit with error if service_name is unknown.

Parameters
service_namename of service, str
def get_service_uri(service_name):

Retrieve ROSRPC URI of service.

Parameters
service_namename of service to lookup, str
Returns
ROSRPC URI for service_name, str
def _rosservice_uri(service_name):

Implements rosservice uri command. Will cause system exit with error if service_name is unknown.

Parameters
service_namename of service to lookup, str
Raises
Unknown exceptionROSServiceIOException If the I/O issues prevent retrieving service information
def get_service_node(service_name):

@return: name of node that implements service, or None @rtype: str

def _rosservice_node(service_name):

Implements rosservice node command. Will cause system exit with error if service is unknown.

@param service_name: name of service to lookup @type service_name: str @raise ROSServiceIOException: if the I/O issues prevent retrieving service information

def get_service_list(node=None, namespace=None, include_nodes=False):

Get the list of services @param node: Name of node to get services for or None to return all services @type node: str @param namespace: Namespace to scope services to or None @type namespace: str @param include_nodes: If True, return list will be [service_name, [node]] @type include_nodes: bool @return: if include_nodes, services is service_name, [node]. Otherwise, it is just the service_name @rtype: [services] @raise ROSServiceIOException: if the I/O issues prevent retrieving service information

def _rosservice_list(namespace=None, print_nodes=False):

Implements 'rosservice list' @param namespace: Namespace to limit listing to or None @type namespace: str @param print_nodes: If True, also print nodes providing service @type print_nodes: bool @raise ROSServiceIOException: if the I/O issues prevent retrieving service information

def _rosservice_info(service_name):

Implements 'rosservice info'. Prints information about a service.

@param service_name: name of service to get info for @type service_name: str @raise ROSServiceIOException: if the I/O issues prevent retrieving service information

def rosservice_find(service_type):

Lookup services by service_type @param service_type: type of service to find @type service_type: str @return: list of service names that use service_type @rtype: [str]

def _rosservice_cmd_find(argv=sys.argv):

Implements 'rosservice type'

@param argv: command-line args @type argv: [str]

def _resource_name_package(name):

pkg/typeName -> pkg, typeName -> None

Parameters
namepackage resource name, e.g. 'std_msgs/String', str
Returns
package name of resource, str
def get_service_class_by_name(service_name):

Get the service class using the name of the service. NOTE: this call results in a probe call to the service. @param service_name: fully-resolved name of service to call @type service_name: str @return: service class @rtype: ServiceDefinition: service class @raise ROSServiceException: if service class cannot be retrieved

def call_service(service_name, service_args, service_class=None):

Call the specified service_name @param service_name: fully-resolved name of service to call @type service_name: str @param service_args: args to pass to service @type service_args: [any] @param service_class: (optional) service type class. If this argument is provided, it saves a probe call against the service @type service_class: Message class @return: service request, service response @rtype: Message, Message @raise ROSServiceException: if call command cannot be executed

def _rosservice_call(service_name, service_args, verbose=False, service_class=None):

Implements 'rosservice call' @param service_name: name of service to call @type service_name: str @param service_args: arguments to call service with @type service_args: [args] @param verbose: if True, print extra output @type verbose: bool @param service_class Message class: (optional) service type class. If this argument is provided, it saves a probe call against the service @type service_class: Message class @raise ROSServiceException: if call command cannot be executed

def has_service_args(service_name, service_class=None):

Check if service requires arguments @param service_name: name of service being called @type service_name: str @param service_class: (optional) service type class. If this argument is provided, it saves a probe call against the service @type service_class: Message class @return: True if service_name has request arguments @rtype: bool

def _rosservice_args(service_name):

Implements 'rosservice args' @param service_name: name of service to get arguments for @type service_name: str @raise ROSServiceException: if call command cannot be executed

def get_service_args(service_name):

Implements 'get service args' @param service_name: name of service to get arguments for @type service_name: str @raise ROSServiceException: if call command cannot be executed

def _optparse_service_only(cmd, argv=sys.argv):

Parse command-line arguments for commands that take a service name only. Will cause a system exit if command-line argument parsing fails. @param cmd: command name, e.g. 'type' @type cmd: str @param argv: command-line arguments @type argv: [str]

def _rosservice_cmd_type(argv):

Parse 'type' command arguments and run command Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if type command cannot be executed

def _rosservice_cmd_uri(argv):

Parse 'uri' command arguments and run command. Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if uri command cannot be executed

def _rosservice_cmd_node(argv):

Parse 'node' command arguments and run command. Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if node command cannot be executed

def _rosservice_cmd_args(argv):

Parse 'args' command arguments and run command. Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if args command cannot be executed

def _rosservice_cmd_call(argv):

Parse 'call' command arguments and run command. Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if call command cannot be executed

def _stdin_yaml_arg():

@return: iterator for next set of service args on stdin. Iterator returns a list of args for each call. @rtype: iterator

def _rosservice_cmd_list(argv):

Parse 'list' command arguments and run command Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if list command cannot be executed

def _rosservice_cmd_info(argv):

Parse 'info' command arguments and run command Will cause a system exit if command-line argument parsing fails. @param argv: command-line arguments @type argv: [str] @raise ROSServiceException: if list command cannot be executed

def _fullusage():

Print generic usage for rosservice

def rosservicemain(argv=sys.argv):

main entry point for rosservice command-line tool

@param argv: command-line args @type argv: [str]