class documentation

class Master(object):

Constructor: Master(caller_id, master_uri)

View In Hierarchy

API for interacting with the ROS master. Although the Master is relatively simple to interact with using the XMLRPC API, this abstraction layer provides protection against future updates. It also provides a streamlined API with builtin return code checking and caller_id passing.

Method __init__ No summary
Method deleteParam Parameter Server: delete parameter @param key: parameter name @type key: str @return: 0 @rtype: int
Method getParam Retrieve parameter value from server. @param key: parameter to lookup. If key is a namespace, getParam() will return a parameter tree. @type key: str getParam() will return a parameter tree.
Method getParamNames Get list of all parameter names stored on this server. This does not adjust parameter names for caller's scope.
Method getPid Get the PID of this server @return: serverProcessPID @rtype: int @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.
Method getPublishedTopics Get list of topics that can be subscribed to. This does not return topics that have no publishers. See L{getSystemState()} to get more comprehensive list. @param subgraph: Restrict topic names to match within the specified subgraph...
Method getSystemState Retrieve list representation of system state (i.e. publishers, subscribers, and services). @rtype: [[str,[str]], [str,[str]], [str,[str]]] @return: systemState
Method getTopicTypes Retrieve list topic names and their types.
Method getUri Get the URI of this Master @return: masterUri @rtype: str @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.
Method hasParam Check if parameter is stored on server. @param key: parameter to check @type key: str @return: [code, statusMessage, hasParam] @rtype: [int, str, bool]
Method is_online Check if Master is online.
Method lookupNode Get the XML-RPC URI of the node with the associated name/caller_id. This API is for looking information about publishers and subscribers. Use lookupService instead to lookup ROS-RPC URIs. @param node: name of node to lookup @type node: str @return: URI @rtype: str @raise rosgraph...
Method lookupService Lookup all provider of a particular service. @param service: fully-qualified name of service to lookup. @type: service: str @return (int, str, str): (code, message, serviceUrl). service URL is provides...
Method registerPublisher Register the caller as a publisher the topic. @param topic: Fully-qualified name of topic to register. @type topic: str @param topic_type: Datatype for topic. Must be a package-resource name, i.e. the...
Method registerService Register the caller as a provider of the specified service. @param service str: Fully-qualified name of service @param service_api str: Service URI @param caller_api str: XML-RPC URI of caller node @return: ignore @rtype: int @raise rosgraph...
Method registerSubscriber Subscribe the caller to the specified topic. In addition to receiving a list of current publishers, the subscriber will also receive notifications of new publishers via the publisherUpdate API. @param topic str: Fully-qualified name of topic to subscribe to...
Method searchParam Search for parameter key on parameter server. Search starts in caller's namespace and proceeds upwards through parent namespaces until Parameter Server finds a matching key.
Method setParam Parameter Server: set parameter. NOTE: if value is a dictionary it will be treated as a parameter tree, where key is the parameter namespace. For example::
Method subscribeParam Retrieve parameter value from server and subscribe to updates to that param. See paramUpdate() in the Node API. @param key: parameter to lookup. @type key: str @param caller_api: API URI for paramUpdate callbacks...
Method unregisterPublisher Unregister the caller as a publisher of the topic. @param topic: Fully-qualified name of topic to unregister. @type topic: str @param caller_api str: API URI of service to
Method unregisterService Unregister the caller as a provider of the specified service. @param service: Fully-qualified name of service @type service: str @param service_api: API URI of service to unregister. Unregistration will only occur if current...
Method unregisterSubscriber Unregister the caller as a publisher of the topic. @param topic: Fully-qualified name of topic to unregister. @type topic: str @param caller_api: API URI of service to unregister. Unregistration will only occur if current @type caller_api: str...
Method unsubscribeParam Retrieve parameter value from server and subscribe to updates to that param. See paramUpdate() in the Node API. @param key: parameter to lookup. @type key: str @param caller_api: API URI for paramUpdate callbacks...
Instance Variable caller_id Undocumented
Instance Variable handle Undocumented
Instance Variable master_uri Undocumented
Method _reinit Internal API for reinitializing this handle to be a new master
Method _succeed Check master return code and return the value field.
def __init__(self, caller_id, master_uri=None):
Parameters
caller_idname of node to use in calls to master, str
master_uri(optional) override default ROS master URI, str
Raises
Unknown exceptionValueError If ROS master uri not set properly
def deleteParam(self, key):

Parameter Server: delete parameter @param key: parameter name @type key: str @return: 0 @rtype: int

def getParam(self, key):

Retrieve parameter value from server. @param key: parameter to lookup. If key is a namespace, getParam() will return a parameter tree. @type key: str getParam() will return a parameter tree.

@return: parameterValue. If key is a namespace,
the return value will be a dictionary, where each key is a parameter in that namespace. Sub-namespaces are also represented as dictionaries.

@rtype: XMLRPCLegalValue

def getParamNames(self):

Get list of all parameter names stored on this server. This does not adjust parameter names for caller's scope.

@return: [code, statusMessage, parameterNameList] @rtype: [int, str, [str]]

def getPid(self):

Get the PID of this server @return: serverProcessPID @rtype: int @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def getPublishedTopics(self, subgraph):

Get list of topics that can be subscribed to. This does not return topics that have no publishers. See L{getSystemState()} to get more comprehensive list. @param subgraph: Restrict topic names to match within the specified subgraph. Subgraph namespace

is resolved relative to the caller's namespace. Use '' to specify all names.

@type subgraph: str @return: [[topic1, type1]...[topicN, typeN]] @rtype: [[str, str],] @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def getSystemState(self):

Retrieve list representation of system state (i.e. publishers, subscribers, and services). @rtype: [[str,[str]], [str,[str]], [str,[str]]] @return: systemState

System state is in list representation::
[publishers, subscribers, services].
publishers is of the form::
[ [topic1, [topic1Publisher1...topic1PublisherN]] ... ]
subscribers is of the form::
[ [topic1, [topic1Subscriber1...topic1SubscriberN]] ... ]
services is of the form::
[ [service1, [service1Provider1...service1ProviderN]] ... ]

@raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def getTopicTypes(self):

Retrieve list topic names and their types.

New in ROS 1.2.

@rtype: (int, str, [[str,str]] ) @return: (code, statusMessage, topicTypes). topicTypes is a list of [topicName, topicType] pairs.

def getUri(self):

Get the URI of this Master @return: masterUri @rtype: str @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def hasParam(self, key):

Check if parameter is stored on server. @param key: parameter to check @type key: str @return: [code, statusMessage, hasParam] @rtype: [int, str, bool]

def is_online(self):

Check if Master is online.

NOTE: this is not part of the actual Master API. This is a convenience function.

@param master_uri: (optional) override environment's ROS_MASTER_URI @type master_uri: str @return: True if Master is available

def lookupNode(self, node_name):

Get the XML-RPC URI of the node with the associated name/caller_id. This API is for looking information about publishers and subscribers. Use lookupService instead to lookup ROS-RPC URIs. @param node: name of node to lookup @type node: str @return: URI @rtype: str @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def lookupService(self, service):

Lookup all provider of a particular service. @param service: fully-qualified name of service to lookup. @type: service: str @return (int, str, str): (code, message, serviceUrl). service URL is provides

and address and port of the service. Fails if there is no provider.

@raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def registerPublisher(self, topic, topic_type, caller_api):

Register the caller as a publisher the topic. @param topic: Fully-qualified name of topic to register. @type topic: str @param topic_type: Datatype for topic. Must be a package-resource name, i.e. the .msg name. @type topic_type: str @param caller_api str: ROS caller XML-RPC API URI @type caller_api: str @return: subscriberApis. List of current subscribers of topic in the form of XMLRPC URIs. @rtype: [str] @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def registerService(self, service, service_api, caller_api):

Register the caller as a provider of the specified service. @param service str: Fully-qualified name of service @param service_api str: Service URI @param caller_api str: XML-RPC URI of caller node @return: ignore @rtype: int @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def registerSubscriber(self, topic, topic_type, caller_api):

Subscribe the caller to the specified topic. In addition to receiving a list of current publishers, the subscriber will also receive notifications of new publishers via the publisherUpdate API. @param topic str: Fully-qualified name of topic to subscribe to. @param topic_type: Datatype for topic. Must be a package-resource name, i.e. the .msg name. @type topic_type: str @param caller_api: XML-RPC URI of caller node for new publisher notifications @type caller_api: str @return: (code, message, publishers). Publishers is a list of XMLRPC API URIs

for nodes currently publishing the specified topic.

@rtype: (int, str, list(str)) @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def searchParam(self, key):

Search for parameter key on parameter server. Search starts in caller's namespace and proceeds upwards through parent namespaces until Parameter Server finds a matching key.

searchParam's behavior is to search for the first partial match. For example, imagine that there are two 'robot_description' parameters:

/robot_description
  /robot_description/arm
  /robot_description/base
/pr2/robot_description
  /pr2/robot_description/base

If I start in the namespace /pr2/foo and search for 'robot_description', searchParam will match /pr2/robot_description. If I search for 'robot_description/arm' it will return /pr2/robot_description/arm, even though that parameter does not exist (yet).

@param key: parameter key to search for. @type key: str @return: foundKey @rtype: str

def setParam(self, key, value):

Parameter Server: set parameter. NOTE: if value is a dictionary it will be treated as a parameter tree, where key is the parameter namespace. For example::

{'x':1,'y':2,'sub':{'z':3}}

will set key/x=1, key/y=2, and key/sub/z=3. Furthermore, it will replace all existing parameters in the key parameter namespace with the parameters in value. You must set parameters individually if you wish to perform a union update.

@param key: parameter name @type key: str @param value: parameter value. @type value: XMLRPCLegalValue @return: 0 @rtype: int

def subscribeParam(self, caller_api, key):

Retrieve parameter value from server and subscribe to updates to that param. See paramUpdate() in the Node API. @param key: parameter to lookup. @type key: str @param caller_api: API URI for paramUpdate callbacks. @type caller_api: str @return: parameterValue. parameterValue is an empty dictionary if the parameter has not been set yet. @rtype: XMLRPCLegalValue

def unregisterPublisher(self, topic, caller_api):

Unregister the caller as a publisher of the topic. @param topic: Fully-qualified name of topic to unregister. @type topic: str @param caller_api str: API URI of service to

unregister. Unregistration will only occur if current registration matches.

@type caller_api: str @return: numUnregistered.

If numUnregistered is zero it means that the caller was not registered as a publisher. The call still succeeds as the intended final state is reached.

@rtype: int @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def unregisterService(self, service, service_api):

Unregister the caller as a provider of the specified service. @param service: Fully-qualified name of service @type service: str @param service_api: API URI of service to unregister. Unregistration will only occur if current

registration matches.

@type service_api: str @return: (code, message, numUnregistered). Number of unregistrations (either 0 or 1).

If this is zero it means that the caller was not registered as a service provider. The call still succeeds as the intended final state is reached.

@rtype: (int, str, int) @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def unregisterSubscriber(self, topic, caller_api):

Unregister the caller as a publisher of the topic. @param topic: Fully-qualified name of topic to unregister. @type topic: str @param caller_api: API URI of service to unregister. Unregistration will only occur if current @type caller_api: str

registration matches.
@return: (code, statusMessage, numUnsubscribed).
If numUnsubscribed is zero it means that the caller was not registered as a subscriber. The call still succeeds as the intended final state is reached.

@rtype: (int, str, int) @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.

def unsubscribeParam(self, caller_api, key):

Retrieve parameter value from server and subscribe to updates to that param. See paramUpdate() in the Node API. @param key: parameter to lookup. @type key: str @param caller_api: API URI for paramUpdate callbacks. @type caller_api: str @return: numUnsubscribed. If numUnsubscribed is zero it means that the caller was not subscribed to the parameter. @rtype: int

caller_id =

Undocumented

handle =

Undocumented

master_uri =

Undocumented

def _reinit(self, master_uri):

Internal API for reinitializing this handle to be a new master

Raises
Unknown exceptionValueError If ROS master uri not set
def _succeed(self, args):

Check master return code and return the value field.

@param args: master return value @type args: (int, str, XMLRPCLegalValue) @return: value field of args (master return value) @rtype: XMLRPCLegalValue @raise rosgraph.masterapi.Error: if Master returns ERROR. @raise rosgraph.masterapi.Failure: if Master returns FAILURE.