public class MasterServer extends XmlRpcServer implements MasterRegistrationListener
MasterServer
provides naming and registration services to the
rest of the Node
s in the ROS system. It tracks Publisher
s and
Subscriber
s to TopicSystemState
s as well as
ServiceServer
s. The role of the MasterServer
is to enable
individual ROS Node
s to locate one another. Once these Node
s
have located each other they communicate with each other peer-to-peer.Modifier and Type | Field and Description |
---|---|
static int |
SYSTEM_STATE_PUBLISHERS
Position in the
getSystemState() for publisher information. |
static int |
SYSTEM_STATE_SERVICES
Position in the
getSystemState() for service information. |
static int |
SYSTEM_STATE_SUBSCRIBERS
Position in the
getSystemState() for subscriber information. |
Constructor and Description |
---|
MasterServer(BindAddress bindAddress,
AdvertiseAddress advertiseAddress) |
Modifier and Type | Method and Description |
---|---|
protected void |
contactSubscriberForPublisherUpdate(java.net.URI subscriberSlaveUri,
GraphName topicName,
java.util.List<java.net.URI> publisherUris)
Contact a subscriber and send it a publisher update.
|
java.util.List<java.lang.Object> |
getPublishedTopics(GraphName caller,
GraphName subgraph)
Get a list of all topics published for the give subgraph.
|
java.util.List<java.lang.Object> |
getSystemState()
Get the state of the ROS graph.
|
java.util.List<java.util.List<java.lang.String>> |
getTopicTypes(GraphName calledId)
Get a
List of all TopicSystemState message types. |
java.net.URI |
lookupNode(GraphName nodeName)
Returns a
NodeIdentifier for the Node with the given name. |
java.net.URI |
lookupService(GraphName serviceName)
Lookup the provider of a particular service.
|
void |
onNodeReplacement(NodeRegistrationInfo nodeInfo)
A node is being replaced.
|
java.util.List<java.net.URI> |
registerPublisher(GraphName nodeName,
java.net.URI nodeSlaveUri,
GraphName topicName,
java.lang.String topicMessageType)
Register the caller as a
Publisher of the specified topic. |
void |
registerService(GraphName nodeName,
java.net.URI nodeSlaveUri,
GraphName serviceName,
java.net.URI serviceUri)
Register a service with the master.
|
java.util.List<java.net.URI> |
registerSubscriber(GraphName nodeName,
java.net.URI nodeSlaveUri,
GraphName topicName,
java.lang.String topicMessageType)
Subscribe the caller to the specified topic.
|
void |
start()
Start the
MasterServer . |
boolean |
unregisterPublisher(GraphName nodeName,
GraphName topicName)
Unregister a
Publisher . |
boolean |
unregisterService(GraphName nodeName,
GraphName serviceName,
java.net.URI serviceUri)
Unregister a service from the master.
|
boolean |
unregisterSubscriber(GraphName nodeName,
GraphName topicName)
Unregister a
Subscriber . |
awaitStart, awaitStart, getAddress, getAdvertiseAddress, getPid, getUri, shutdown, start
public static final int SYSTEM_STATE_PUBLISHERS
getSystemState()
for publisher information.public static final int SYSTEM_STATE_SUBSCRIBERS
getSystemState()
for subscriber information.public static final int SYSTEM_STATE_SERVICES
getSystemState()
for service information.public MasterServer(BindAddress bindAddress, AdvertiseAddress advertiseAddress)
public void start()
MasterServer
.public void registerService(GraphName nodeName, java.net.URI nodeSlaveUri, GraphName serviceName, java.net.URI serviceUri)
nodeName
- the GraphName
of the Node
offering the servicenodeSlaveUri
- the URI
of the Node
's SlaveServer
serviceName
- the GraphName
of the serviceserviceUri
- the URI
of the servicepublic boolean unregisterService(GraphName nodeName, GraphName serviceName, java.net.URI serviceUri)
public java.util.List<java.net.URI> registerSubscriber(GraphName nodeName, java.net.URI nodeSlaveUri, GraphName topicName, java.lang.String topicMessageType)
nodeName
- the GraphName
of the Node
offering the servicenodeSlaveUri
- the URI
of the Node
's SlaveServer
topicName
- the GraphName
of the subscribed TopicParticipant
topicMessageType
- the message type of the topicList
of XMLRPC API URI
s for nodes currently
publishing the specified topicpublic boolean unregisterSubscriber(GraphName nodeName, GraphName topicName)
Subscriber
.nodeName
- the GraphName
of the Node
offering the servicetopicName
- the GraphName
of the subscribed TopicParticipant
true
if the Subscriber
was registeredpublic java.util.List<java.net.URI> registerPublisher(GraphName nodeName, java.net.URI nodeSlaveUri, GraphName topicName, java.lang.String topicMessageType)
Publisher
of the specified topic.nodeName
- the GraphName
of the Node
offering the servicenodeSlaveUri
- the URI
of the Node
's SlaveServer
topicName
- the GraphName
of the subscribed TopicParticipant
topicMessageType
- the message type of the topicList
of the current Subscriber
s to the
Publisher
's TopicSystemState
in the form of XML-RPC
URI
s for each Subscriber
's SlaveServer
protected void contactSubscriberForPublisherUpdate(java.net.URI subscriberSlaveUri, GraphName topicName, java.util.List<java.net.URI> publisherUris)
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 subscriberpublic boolean unregisterPublisher(GraphName nodeName, GraphName topicName)
Publisher
.nodeName
- the GraphName
of the Node
offering the servicetopicName
- the GraphName
of the subscribed TopicParticipant
true
if the Publisher
was unregisteredpublic java.net.URI lookupNode(GraphName nodeName)
NodeIdentifier
for the Node
with the given name.
This API is for looking information about Publisher
s and
Subscriber
s. Use lookupService(GraphName)
instead to
lookup ROS-RPC URI
s for ServiceServer
s.public java.util.List<java.util.List<java.lang.String>> getTopicTypes(GraphName calledId)
List
of all TopicSystemState
message types.calledId
- the Node
name of the callerpublic java.util.List<java.lang.Object> getSystemState()
This includes information about publishers, subscribers, and services.
public java.net.URI lookupService(GraphName serviceName)
serviceName
- name of serviceURI
of the SlaveServer
with the provided name, or
null
if there is no such service.public java.util.List<java.lang.Object> getPublishedTopics(GraphName caller, GraphName subgraph)
caller
- name of the callersubgraph
- subgraph containing the requested TopicSystemState
s,
relative to callerList
of List
s where the nested List
s
contain, in order, the TopicSystemState
name and
TopicSystemState
message typepublic void onNodeReplacement(NodeRegistrationInfo nodeInfo)
MasterRegistrationListener
The information object is about to be trashed, so it should not be hung onto.
onNodeReplacement
in interface MasterRegistrationListener
nodeInfo
- the node being replaced