Package org.ros.node.topic
Interface Subscriber<T>
- Type Parameters:
T- theSubscribermay only subscribe to messages of this type
- All Superinterfaces:
TopicParticipant
- All Known Implementing Classes:
DefaultSubscriber
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe message type given when aSubscriberchooses not to commit to a specific message type. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessageListener(org.ros.message.MessageListener<T> messageListener) Adds aMessageListenerwith a limit of 1.voidaddMessageListener(org.ros.message.MessageListener<T> messageListener, int limit) Adds aMessageListenerto be called when new messages are received.voidaddSubscriberListener(SubscriberListener<T> listener) Add a new lifecycle listener to the subscriber.booleanvoidRemoves all registeredMessageListeners.booleanremoveMessageListener(org.ros.message.MessageListener<T> messageListener) Removes a previously addedMessageListener.voidshutdown()Shuts down and unregisters theSubscriberusing the default timeout forSubscriberListener.onShutdown(Subscriber)callbacks.voidShuts down and unregisters theSubscriber.Methods inherited from interface org.ros.internal.node.topic.TopicParticipant
getTopicMessageType, getTopicName
-
Field Details
-
TOPIC_MESSAGE_TYPE_WILDCARD
The message type given when aSubscriberchooses not to commit to a specific message type.- See Also:
-
-
Method Details
-
addMessageListener
Adds aMessageListenerto be called when new messages are received.The
MessageListenerwill be executed serially in its own thread. If theMessageListenerprocesses 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- thisMessageListenerwill be called when new messages are receivedlimit- the maximum number of messages to buffer
-
addMessageListener
Adds aMessageListenerwith a limit of 1.- See Also:
-
removeMessageListener
Removes a previously addedMessageListener.- Parameters:
messageListener-MessageListenerto remove.- Returns:
- True if the listener was removed, false if it wasn't registered before.
-
removeAllMessageListeners
void removeAllMessageListeners()Removes all registeredMessageListeners. -
shutdown
Shuts down and unregisters theSubscriber. using the default timeout Shutdown is delayed by at most the specified timeout to allowSubscriberListener.onShutdown(Subscriber)callbacks to complete.SubscriberListener.onShutdown(Subscriber)callbacks are executed in separate threads. -
shutdown
void shutdown()Shuts down and unregisters theSubscriberusing the default timeout forSubscriberListener.onShutdown(Subscriber)callbacks.SubscriberListener.onShutdown(Subscriber)callbacks are executed in separate threads.- See Also:
-
addSubscriberListener
Add a new lifecycle listener to the subscriber.- Parameters:
listener- The listener to add.
-
getLatchMode
boolean getLatchMode()- Returns:
trueif thePublisherof thisSubscriber's topic is latched,falseotherwise
-