Class MasterServer
java.lang.Object
org.ros.internal.node.server.XmlRpcServer
org.ros.internal.node.server.master.MasterServer
- All Implemented Interfaces:
MasterRegistrationListener
The
MasterServer provides naming and registration services to the
rest of the Nodes in the ROS system. It tracks Publishers and
Subscribers to TopicSystemStates as well as
ServiceServers. The role of the MasterServer is to enable
individual ROS Nodes to locate one another. Once these Nodes
have located each other they communicate with each other peer-to-peer.- Author:
- damonkohler@google.com (Damon Kohler), khughes@google.com (Keith M. Hughes)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPosition in thegetSystemState()for publisher information.static final intPosition in thegetSystemState()for service information.static final intPosition in thegetSystemState()for subscriber information. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcontactSubscriberForPublisherUpdate(URI subscriberSlaveUri, GraphName topicName, List<URI> publisherUris) Contact a subscriber and send it a publisher update.getPublishedTopics(GraphName caller, GraphName subgraph) Get a list of all topics published for the give subgraph.Get the state of the ROS graph.getTopicTypes(GraphName calledId) Get aListof allTopicSystemStatemessage types.lookupNode(GraphName nodeName) Returns aNodeIdentifierfor theNodewith the given name.lookupService(GraphName serviceName) Lookup the provider of a particular service.voidonNodeReplacement(NodeRegistrationInfo nodeInfo) A node is being replaced.registerPublisher(GraphName nodeName, URI nodeSlaveUri, GraphName topicName, String topicMessageType) Register the caller as aPublisherof the specified topic.voidregisterService(GraphName nodeName, URI nodeSlaveUri, GraphName serviceName, URI serviceUri) Register a service with the master.registerSubscriber(GraphName nodeName, URI nodeSlaveUri, GraphName topicName, String topicMessageType) Subscribe the caller to the specified topic.voidstart()Start theMasterServer.booleanunregisterPublisher(GraphName nodeName, GraphName topicName) Unregister aPublisher.booleanunregisterService(GraphName nodeName, GraphName serviceName, URI serviceUri) Unregister a service from the master.booleanunregisterSubscriber(GraphName nodeName, GraphName topicName) Unregister aSubscriber.Methods inherited from class org.ros.internal.node.server.XmlRpcServer
awaitStart, awaitStart, getAddress, getAdvertiseAddress, getPid, getUri, shutdown, start
-
Field Details
-
SYSTEM_STATE_PUBLISHERS
public static final int SYSTEM_STATE_PUBLISHERSPosition in thegetSystemState()for publisher information.- See Also:
-
SYSTEM_STATE_SUBSCRIBERS
public static final int SYSTEM_STATE_SUBSCRIBERSPosition in thegetSystemState()for subscriber information.- See Also:
-
SYSTEM_STATE_SERVICES
public static final int SYSTEM_STATE_SERVICESPosition in thegetSystemState()for service information.- See Also:
-
-
Constructor Details
-
MasterServer
-
-
Method Details
-
start
public void start()Start theMasterServer. -
registerService
public void registerService(GraphName nodeName, URI nodeSlaveUri, GraphName serviceName, URI serviceUri) Register a service with the master. -
unregisterService
Unregister a service from the master. -
registerSubscriber
public List<URI> registerSubscriber(GraphName nodeName, URI nodeSlaveUri, GraphName topicName, String topicMessageType) 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.- Parameters:
nodeName- theGraphNameof theNodeoffering the servicenodeSlaveUri- theURIof theNode'sSlaveServertopicName- theGraphNameof the subscribedTopicParticipanttopicMessageType- the message type of the topic- Returns:
- A
Listof XMLRPC APIURIs for nodes currently publishing the specified topic
-
unregisterSubscriber
Unregister aSubscriber.- Parameters:
nodeName- theGraphNameof theNodeoffering the servicetopicName- theGraphNameof the subscribedTopicParticipant- Returns:
trueif theSubscriberwas registered
-
registerPublisher
public List<URI> registerPublisher(GraphName nodeName, URI nodeSlaveUri, GraphName topicName, String topicMessageType) Register the caller as aPublisherof the specified topic.- Parameters:
nodeName- theGraphNameof theNodeoffering the servicenodeSlaveUri- theURIof theNode'sSlaveServertopicName- theGraphNameof the subscribedTopicParticipanttopicMessageType- the message type of the topic- Returns:
- a
Listof the currentSubscribers to thePublisher'sTopicSystemStatein the form of XML-RPCURIs for eachSubscriber'sSlaveServer
-
contactSubscriberForPublisherUpdate
protected void contactSubscriberForPublisherUpdate(URI subscriberSlaveUri, GraphName topicName, List<URI> publisherUris) Contact a subscriber and send it a publisher update.- Parameters:
subscriberSlaveUri- the slave URI of the subscriber to contacttopicName- the name of the topic whose publisher URIs are being updatedpublisherUris- the new list of publisher URIs to be sent to the subscriber
-
unregisterPublisher
Unregister aPublisher.- Parameters:
nodeName- theGraphNameof theNodeoffering the servicetopicName- theGraphNameof the subscribedTopicParticipant- Returns:
trueif thePublisherwas unregistered
-
lookupNode
Returns aNodeIdentifierfor theNodewith the given name. This API is for looking information aboutPublishers andSubscribers. UselookupService(GraphName)instead to lookup ROS-RPCURIs forServiceServers. -
getTopicTypes
Get aListof allTopicSystemStatemessage types.- Parameters:
calledId- theNodename of the caller- Returns:
- a list of the form [[topic 1 name, topic 1 message type], [topic 2 name, topic 2 message type], ...]
-
getSystemState
Get the state of the ROS graph.This includes information about publishers, subscribers, and services.
- Returns:
- TODO(keith): Fill in.
-
lookupService
Lookup the provider of a particular service.- Parameters:
serviceName- name of service- Returns:
URIof theSlaveServerwith the provided name, ornullif there is no such service.
-
getPublishedTopics
Get a list of all topics published for the give subgraph.- Parameters:
caller- name of the callersubgraph- subgraph containing the requestedTopicSystemStates, relative to caller- Returns:
- a
ListofLists where the nestedLists contain, in order, theTopicSystemStatename andTopicSystemStatemessage type
-
onNodeReplacement
Description copied from interface:MasterRegistrationListenerA node is being replaced.The information object is about to be trashed, so it should not be hung onto.
- Specified by:
onNodeReplacementin interfaceMasterRegistrationListener- Parameters:
nodeInfo- the node being replaced
-