Interface Subscriber<T>

Type Parameters:
T - the Subscriber may only subscribe to messages of this type
All Superinterfaces:
TopicParticipant
All Known Implementing Classes:
DefaultSubscriber

public interface Subscriber<T> extends TopicParticipant
Subscribes to messages of a given type on a given ROS topic.
Author:
ethan.rublee@gmail.com (Ethan Rublee), damonkohler@google.com (Damon Kohler)
  • Field Details

    • TOPIC_MESSAGE_TYPE_WILDCARD

      static final String TOPIC_MESSAGE_TYPE_WILDCARD
      The message type given when a Subscriber chooses not to commit to a specific message type.
      See Also:
  • Method Details

    • addMessageListener

      void addMessageListener(org.ros.message.MessageListener<T> messageListener, int limit)
      Adds a MessageListener to be called when new messages are received.

      The MessageListener will be executed serially in its own thread. If the MessageListener processes new messages slower than they arrive, new messages will be queued up to the specified limit. Older messages are removed from the buffer when the buffer limit is exceeded.

      Parameters:
      messageListener - this MessageListener will be called when new messages are received
      limit - the maximum number of messages to buffer
    • addMessageListener

      void addMessageListener(org.ros.message.MessageListener<T> messageListener)
      Adds a MessageListener with a limit of 1.
      See Also:
    • removeMessageListener

      boolean removeMessageListener(org.ros.message.MessageListener<T> messageListener)
      Removes a previously added MessageListener.
      Parameters:
      messageListener - MessageListener to remove.
      Returns:
      True if the listener was removed, false if it wasn't registered before.
    • removeAllMessageListeners

      void removeAllMessageListeners()
      Removes all registered MessageListeners.
    • shutdown

      void shutdown(long timeout, TimeUnit unit)
      Shuts down and unregisters the Subscriber. using the default timeout Shutdown is delayed by at most the specified timeout to allow SubscriberListener.onShutdown(Subscriber) callbacks to complete.

      SubscriberListener.onShutdown(Subscriber) callbacks are executed in separate threads.

    • shutdown

      void shutdown()
      Shuts down and unregisters the Subscriber using the default timeout for SubscriberListener.onShutdown(Subscriber) callbacks.

      SubscriberListener.onShutdown(Subscriber) callbacks are executed in separate threads.

      See Also:
    • addSubscriberListener

      void addSubscriberListener(SubscriberListener<T> listener)
      Add a new lifecycle listener to the subscriber.
      Parameters:
      listener - The listener to add.
    • getLatchMode

      boolean getLatchMode()
      Returns:
      true if the Publisher of this Subscriber's topic is latched, false otherwise