Class MasterServer

java.lang.Object
org.ros.internal.node.server.XmlRpcServer
org.ros.internal.node.server.master.MasterServer
All Implemented Interfaces:
MasterRegistrationListener

public class MasterServer extends XmlRpcServer implements 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 Details

  • Constructor Details

  • Method Details

    • start

      public void start()
      Start the MasterServer.
    • registerService

      public void registerService(GraphName nodeName, URI nodeSlaveUri, GraphName serviceName, URI serviceUri)
      Register a service with the master.
      Parameters:
      nodeName - the GraphName of the Node offering the service
      nodeSlaveUri - the URI of the Node's SlaveServer
      serviceName - the GraphName of the service
      serviceUri - the URI of the service
    • unregisterService

      public boolean unregisterService(GraphName nodeName, GraphName serviceName, URI serviceUri)
      Unregister a service from the master.
      Parameters:
      nodeName - the GraphName of the Node offering the service
      serviceName - the GraphName of the service
      serviceUri - the URI of the service
      Returns:
      true if the service was registered
    • 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 - the GraphName of the Node offering the service
      nodeSlaveUri - the URI of the Node's SlaveServer
      topicName - the GraphName of the subscribed TopicParticipant
      topicMessageType - the message type of the topic
      Returns:
      A List of XMLRPC API URIs for nodes currently publishing the specified topic
    • unregisterSubscriber

      public boolean unregisterSubscriber(GraphName nodeName, GraphName topicName)
      Unregister a Subscriber.
      Parameters:
      nodeName - the GraphName of the Node offering the service
      topicName - the GraphName of the subscribed TopicParticipant
      Returns:
      true if the Subscriber was registered
    • registerPublisher

      public List<URI> registerPublisher(GraphName nodeName, URI nodeSlaveUri, GraphName topicName, String topicMessageType)
      Register the caller as a Publisher of the specified topic.
      Parameters:
      nodeName - the GraphName of the Node offering the service
      nodeSlaveUri - the URI of the Node's SlaveServer
      topicName - the GraphName of the subscribed TopicParticipant
      topicMessageType - the message type of the topic
      Returns:
      a List of the current Subscribers to the Publisher's TopicSystemState in the form of XML-RPC URIs for each Subscriber's SlaveServer
    • 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 contact
      topicName - the name of the topic whose publisher URIs are being updated
      publisherUris - the new list of publisher URIs to be sent to the subscriber
    • unregisterPublisher

      public boolean unregisterPublisher(GraphName nodeName, GraphName topicName)
      Unregister a Publisher.
      Parameters:
      nodeName - the GraphName of the Node offering the service
      topicName - the GraphName of the subscribed TopicParticipant
      Returns:
      true if the Publisher was unregistered
    • lookupNode

      public URI lookupNode(GraphName nodeName)
      Returns a NodeIdentifier for the Node with the given name. This API is for looking information about Publishers and Subscribers. Use lookupService(GraphName) instead to lookup ROS-RPC URIs for ServiceServers.
      Parameters:
      nodeName - name of Node to lookup
      Returns:
      the URI for the Node slave server with the given name, or null if there is no Node with the given name
    • getTopicTypes

      public List<List<String>> getTopicTypes(GraphName calledId)
      Get a List of all TopicSystemState message types.
      Parameters:
      calledId - the Node name of the caller
      Returns:
      a list of the form [[topic 1 name, topic 1 message type], [topic 2 name, topic 2 message type], ...]
    • getSystemState

      public List<Object> getSystemState()
      Get the state of the ROS graph.

      This includes information about publishers, subscribers, and services.

      Returns:
      TODO(keith): Fill in.
    • lookupService

      public URI lookupService(GraphName serviceName)
      Lookup the provider of a particular service.
      Parameters:
      serviceName - name of service
      Returns:
      URI of the SlaveServer with the provided name, or null if there is no such service.
    • getPublishedTopics

      public List<Object> getPublishedTopics(GraphName caller, GraphName subgraph)
      Get a list of all topics published for the give subgraph.
      Parameters:
      caller - name of the caller
      subgraph - subgraph containing the requested TopicSystemStates, relative to caller
      Returns:
      a List of Lists where the nested Lists contain, in order, the TopicSystemState name and TopicSystemState message type
    • onNodeReplacement

      public void onNodeReplacement(NodeRegistrationInfo nodeInfo)
      Description copied from interface: MasterRegistrationListener
      A node is being replaced.

      The information object is about to be trashed, so it should not be hung onto.

      Specified by:
      onNodeReplacement in interface MasterRegistrationListener
      Parameters:
      nodeInfo - the node being replaced