org.ros.internal.node.xmlrpc
Class MasterXmlRpcEndpointImpl

java.lang.Object
  extended by org.ros.internal.node.xmlrpc.MasterXmlRpcEndpointImpl
All Implemented Interfaces:
MasterXmlRpcEndpoint, ParameterServerXmlRpcEndpoint, XmlRpcEndpoint

public class MasterXmlRpcEndpointImpl
extends java.lang.Object
implements MasterXmlRpcEndpoint, ParameterServerXmlRpcEndpoint

A combined XML-RPC endpoint for the master and parameter servers.


Constructor Summary
MasterXmlRpcEndpointImpl(MasterServer master)
           
 
Method Summary
 java.util.List<java.lang.Object> deleteParam(java.lang.String callerId, java.lang.String key)
          Deletes a parameter.
 java.util.List<java.lang.Object> getParam(java.lang.String callerId, java.lang.String key)
          Retrieve parameter value from server.
 java.util.List<java.lang.Object> getParamNames(java.lang.String callerId)
          Gets the list of all parameter names stored on this server.
 java.util.List<java.lang.Object> getPid(java.lang.String callerId)
          Get the PID for the master process.
 java.util.List<java.lang.Object> getPublishedTopics(java.lang.String callerId, java.lang.String subgraph)
          Get list of topics that can be subscribed to.
 java.util.List<java.lang.Object> getSystemState(java.lang.String callerId)
          Retrieve list representation of system state (i.e.
 java.util.List<java.lang.Object> getTopicTypes(java.lang.String callerId)
          Get a list of all topic types.
 java.util.List<java.lang.Object> getUri(java.lang.String callerId)
          Get the URI of the the master.
 java.util.List<java.lang.Object> hasParam(java.lang.String callerId, java.lang.String key)
          Check if parameter is stored on server.
 java.util.List<java.lang.Object> lookupNode(java.lang.String callerId, java.lang.String nodeName)
          Get the XML-RPC URI of the node with the associated name/caller_id.
 java.util.List<java.lang.Object> lookupService(java.lang.String callerId, java.lang.String serviceName)
          Lookup all provider of a particular service.
 java.util.List<java.lang.Object> registerPublisher(java.lang.String callerId, java.lang.String topicName, java.lang.String topicMessageType, java.lang.String callerSlaveUri)
          Register the caller as a publisher the topic.
 java.util.List<java.lang.Object> registerService(java.lang.String callerId, java.lang.String serviceName, java.lang.String serviceUri, java.lang.String callerSlaveUri)
          Register the caller as a provider of the specified service.
 java.util.List<java.lang.Object> registerSubscriber(java.lang.String callerId, java.lang.String topicName, java.lang.String topicMessageType, java.lang.String callerSlaveUri)
          Subscribe the caller to the specified topic.
 java.util.List<java.lang.Object> searchParam(java.lang.String callerId, java.lang.String key)
          Searches for a parameter key on the ParameterServer.
 java.util.List<java.lang.Object> setParam(java.lang.String callerId, java.lang.String key, java.lang.Boolean value)
          Sets a parameter.
 java.util.List<java.lang.Object> setParam(java.lang.String callerId, java.lang.String key, java.lang.Double value)
           
 java.util.List<java.lang.Object> setParam(java.lang.String callerId, java.lang.String key, java.lang.Integer value)
           
 java.util.List<java.lang.Object> setParam(java.lang.String callerId, java.lang.String key, java.util.List<?> value)
           
 java.util.List<java.lang.Object> setParam(java.lang.String callerId, java.lang.String key, java.util.Map<?,?> value)
           
 java.util.List<java.lang.Object> setParam(java.lang.String callerId, java.lang.String key, java.lang.String value)
           
 java.util.List<java.lang.Object> subscribeParam(java.lang.String callerId, java.lang.String callerSlaveUri, java.lang.String key)
          Retrieves the parameter value from server and subscribe to updates to that param.
 java.util.List<java.lang.Object> unregisterPublisher(java.lang.String callerId, java.lang.String topicName, java.lang.String callerSlaveUri)
          Unregister the caller as a publisher of the topic.
 java.util.List<java.lang.Object> unregisterService(java.lang.String callerId, java.lang.String serviceName, java.lang.String serviceUri)
          Unregister the caller as a provider of the specified service.
 java.util.List<java.lang.Object> unregisterSubscriber(java.lang.String callerId, java.lang.String topicName, java.lang.String callerSlaveUri)
          Unregister the caller as a publisher of the topic.
 java.util.List<java.lang.Object> unsubscribeParam(java.lang.String callerId, java.lang.String callerSlaveUri, java.lang.String key)
          Unsubscribes from updates to the specified param.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MasterXmlRpcEndpointImpl

public MasterXmlRpcEndpointImpl(MasterServer master)
Method Detail

getPid

public java.util.List<java.lang.Object> getPid(java.lang.String callerId)
Description copied from interface: MasterXmlRpcEndpoint
Get the PID for the master process.

Specified by:
getPid in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
Returns:
The pid of the process.

getPublishedTopics

public java.util.List<java.lang.Object> getPublishedTopics(java.lang.String callerId,
                                                           java.lang.String subgraph)
Description copied from interface: MasterXmlRpcEndpoint
Get list of topics that can be subscribed to. This does not return topics that have no publishers. See getSystemState() to get more comprehensive list.

Specified by:
getPublishedTopics in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
subgraph - Restrict topic names to match within the specified subgraph. Subgraph namespace is resolved relative to the caller's namespace. Use empty string to specify all names.
Returns:
Topics is in list representation [[topic, message type], [topic, message type] ...]

getTopicTypes

public java.util.List<java.lang.Object> getTopicTypes(java.lang.String callerId)
Description copied from interface: MasterXmlRpcEndpoint
Get a list of all topic types.

Specified by:
getTopicTypes in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
Returns:
The types are in the list representation [[topic, message type], [topic, message type] ...]

getSystemState

public java.util.List<java.lang.Object> getSystemState(java.lang.String callerId)
Description copied from interface: MasterXmlRpcEndpoint
Retrieve list representation of system state (i.e. publishers, subscribers, and services).

Specified by:
getSystemState in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
Returns:
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]] ... ]

getUri

public java.util.List<java.lang.Object> getUri(java.lang.String callerId)
Description copied from interface: MasterXmlRpcEndpoint
Get the URI of the the master.

Specified by:
getUri in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
Returns:
URI of the the master

lookupNode

public java.util.List<java.lang.Object> lookupNode(java.lang.String callerId,
                                                   java.lang.String nodeName)
Description copied from interface: MasterXmlRpcEndpoint
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.

Specified by:
lookupNode in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
nodeName - Name of node to lookup
Returns:
URI of the node

registerPublisher

public java.util.List<java.lang.Object> registerPublisher(java.lang.String callerId,
                                                          java.lang.String topicName,
                                                          java.lang.String topicMessageType,
                                                          java.lang.String callerSlaveUri)
Description copied from interface: MasterXmlRpcEndpoint
Register the caller as a publisher the topic.

Specified by:
registerPublisher in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
topicName - fully-qualified name of topic to register
topicMessageType - topic type, must be a package-resource name, i.e. the .msg name.
callerSlaveUri - API URI of publisher to register
Returns:
list of current subscribers of topic in the form of XML-RPC URIs

unregisterPublisher

public java.util.List<java.lang.Object> unregisterPublisher(java.lang.String callerId,
                                                            java.lang.String topicName,
                                                            java.lang.String callerSlaveUri)
Description copied from interface: MasterXmlRpcEndpoint
Unregister the caller as a publisher of the topic.

Specified by:
unregisterPublisher in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
topicName - Fully-qualified name of topic.
callerSlaveUri - API URI of publisher to unregister. Unregistration will only occur if current registration matches.
Returns:
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.

registerSubscriber

public java.util.List<java.lang.Object> registerSubscriber(java.lang.String callerId,
                                                           java.lang.String topicName,
                                                           java.lang.String topicMessageType,
                                                           java.lang.String callerSlaveUri)
Description copied from interface: MasterXmlRpcEndpoint
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.

Specified by:
registerSubscriber in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
topicName - Fully-qualified name of topic
topicMessageType - topic type, must be a package-resource name, i.e. the .msg name
callerSlaveUri - API URI of subscriber to register. Will be used for new publisher notifications
Returns:
publishers as a list of XMLRPC API URIs for nodes currently publishing the specified topic

unregisterSubscriber

public java.util.List<java.lang.Object> unregisterSubscriber(java.lang.String callerId,
                                                             java.lang.String topicName,
                                                             java.lang.String callerSlaveUri)
Description copied from interface: MasterXmlRpcEndpoint
Unregister the caller as a publisher of the topic.

Specified by:
unregisterSubscriber in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
topicName - Fully-qualified name of topic.
callerSlaveUri - API URI of service to unregister. Unregistration will only occur if current registration matches.
Returns:
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.

lookupService

public java.util.List<java.lang.Object> lookupService(java.lang.String callerId,
                                                      java.lang.String serviceName)
Description copied from interface: MasterXmlRpcEndpoint
Lookup all provider of a particular service.

Specified by:
lookupService in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
serviceName - Fully-qualified name of service
Returns:
service URL is provides address and port of the service. Fails if there is no provider.

registerService

public java.util.List<java.lang.Object> registerService(java.lang.String callerId,
                                                        java.lang.String serviceName,
                                                        java.lang.String serviceUri,
                                                        java.lang.String callerSlaveUri)
Description copied from interface: MasterXmlRpcEndpoint
Register the caller as a provider of the specified service.

Specified by:
registerService in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
serviceName - Fully-qualified name of service
serviceUri - XML-RPC URI of caller node
Returns:
ignore

unregisterService

public java.util.List<java.lang.Object> unregisterService(java.lang.String callerId,
                                                          java.lang.String serviceName,
                                                          java.lang.String serviceUri)
Description copied from interface: MasterXmlRpcEndpoint
Unregister the caller as a provider of the specified service.

Specified by:
unregisterService in interface MasterXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
serviceName - Fully-qualified name of service
serviceUri - API URI of service to unregister. Unregistration will only occur if current registration matches.
Returns:
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.

setParam

public java.util.List<java.lang.Object> setParam(java.lang.String callerId,
                                                 java.lang.String key,
                                                 java.lang.Boolean value)
Description copied from interface: ParameterServerXmlRpcEndpoint
Sets a 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.

Specified by:
setParam in interface ParameterServerXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
key - Parameter name.
value - Parameter value.
Returns:
void

setParam

public java.util.List<java.lang.Object> setParam(java.lang.String callerId,
                                                 java.lang.String key,
                                                 java.lang.Integer value)
Specified by:
setParam in interface ParameterServerXmlRpcEndpoint

setParam

public java.util.List<java.lang.Object> setParam(java.lang.String callerId,
                                                 java.lang.String key,
                                                 java.lang.Double value)
Specified by:
setParam in interface ParameterServerXmlRpcEndpoint

setParam

public java.util.List<java.lang.Object> setParam(java.lang.String callerId,
                                                 java.lang.String key,
                                                 java.lang.String value)
Specified by:
setParam in interface ParameterServerXmlRpcEndpoint

setParam

public java.util.List<java.lang.Object> setParam(java.lang.String callerId,
                                                 java.lang.String key,
                                                 java.util.List<?> value)
Specified by:
setParam in interface ParameterServerXmlRpcEndpoint

setParam

public java.util.List<java.lang.Object> setParam(java.lang.String callerId,
                                                 java.lang.String key,
                                                 java.util.Map<?,?> value)
Specified by:
setParam in interface ParameterServerXmlRpcEndpoint

getParam

public java.util.List<java.lang.Object> getParam(java.lang.String callerId,
                                                 java.lang.String key)
Description copied from interface: ParameterServerXmlRpcEndpoint
Retrieve parameter value from server.

If code is not 1, parameterValue should be ignored. 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.

Specified by:
getParam in interface ParameterServerXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
key - Parameter name. If key is a namespace, getParam() will return a parameter tree.
Returns:
the parameter value

searchParam

public java.util.List<java.lang.Object> searchParam(java.lang.String callerId,
                                                    java.lang.String key)
Description copied from interface: ParameterServerXmlRpcEndpoint
Searches for a parameter key on the ParameterServer.

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). If code is not 1, foundKey should be ignored.

Specified by:
searchParam in interface ParameterServerXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
key - Parameter name to search for.
Returns:
the found key

subscribeParam

public java.util.List<java.lang.Object> subscribeParam(java.lang.String callerId,
                                                       java.lang.String callerSlaveUri,
                                                       java.lang.String key)
Description copied from interface: ParameterServerXmlRpcEndpoint
Retrieves the parameter value from server and subscribe to updates to that param. See paramUpdate() in the Node API.

If code is not 1, parameterValue should be ignored. parameterValue is an empty dictionary if the parameter has not been set yet.

Specified by:
subscribeParam in interface ParameterServerXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
callerSlaveUri - Node API URI of subscriber for paramUpdate callbacks.
Returns:
the parameter value

unsubscribeParam

public java.util.List<java.lang.Object> unsubscribeParam(java.lang.String callerId,
                                                         java.lang.String callerSlaveUri,
                                                         java.lang.String key)
Description copied from interface: ParameterServerXmlRpcEndpoint
Unsubscribes from updates to the specified param. See paramUpdate() in the Node API.

A return value of zero means that the caller was not subscribed to the parameter.

Specified by:
unsubscribeParam in interface ParameterServerXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
callerSlaveUri - Node API URI of subscriber
key - Parameter name
Returns:
the number of parameters that were unsubscribed

deleteParam

public java.util.List<java.lang.Object> deleteParam(java.lang.String callerId,
                                                    java.lang.String key)
Description copied from interface: ParameterServerXmlRpcEndpoint
Deletes a parameter.

Specified by:
deleteParam in interface ParameterServerXmlRpcEndpoint
Parameters:
callerId - ROS caller ID
key - parameter name
Returns:
void

hasParam

public java.util.List<java.lang.Object> hasParam(java.lang.String callerId,
                                                 java.lang.String key)
Description copied from interface: ParameterServerXmlRpcEndpoint
Check if parameter is stored on server.

Specified by:
hasParam in interface ParameterServerXmlRpcEndpoint
Parameters:
callerId - ROS caller ID.
key - Parameter name.
Returns:
true if the parameter exists

getParamNames

public java.util.List<java.lang.Object> getParamNames(java.lang.String callerId)
Description copied from interface: ParameterServerXmlRpcEndpoint
Gets the list of all parameter names stored on this server.

Specified by:
getParamNames in interface ParameterServerXmlRpcEndpoint
Parameters:
callerId - ROS caller ID.
Returns:
a Collection of parameter names