|
| | Subscriber (const SubscriberOptions &options, std::string_view topic_name, MessageCallback callback) |
| | Construct a Subscriber with the specified callback.
|
| | Subscriber (const SubscriberOptions &options, std::string_view topic_name, MessageCoroCallback callback) |
| | Construct a Subscriber with the specified coroutine callback.
|
| | Subscriber (const SubscriberOptions &options, std::string_view topic_name, PolledSubscriberTag tag) |
| | Construct a Subscriber without any callback.
|
| std::optional< std::shared_ptr< const MessageType > > | get_message () |
| | Get the latest received message, if there is one.
|
| std::optional< std::shared_ptr< const MessageType > > | get_new_message () |
| | Get the latest new message, if there is one.
|
| std::optional< std::shared_ptr< const MessageType > > | peek_message () const |
| | Get the latest received message, if there is one.
|
| std::optional< std::shared_ptr< const MessageType > > | peek_new_message () const |
| | Get the latest new message, if there is one.
|
| rclcpp::Time | get_last_message_time () const |
| | Returns time of the last received message on the topic, handled by this Subscriber.
|
| std::string | get_topic_name () const |
| | Returns the resolved (full) name of the topic handled by this Subscriber.
|
| std::string | get_unresolved_topic_name () const |
| | Returns the unresolved name of the topic handled by this Subscriber.
|
| uint32_t | get_publisher_count () const |
| | Returns number of publishers registered at the topic.
|
template<typename MessageType>
class mrs_lib::Subscriber< MessageType >
Wrapper for rclcpp::Subscription with callback and polling interface.
- Template Parameters
-
| MessageType | Type of the message to subscribe to. |
template<typename MessageType>
| std::optional< std::shared_ptr< const MessageType > > mrs_lib::Subscriber< MessageType >::get_new_message |
( |
| ) |
|
|
nodiscard |
Get the latest new message, if there is one.
- Returns
- The latest new message, if there is any, nullopt otherwise.
A new message is a message that was not yet used. A message is always marked as used if there is a callback associated with the subscriber. Additionally, it is marked as used by obtaining it using get_*message.
Calling this function marks the message as used.
template<typename MessageType>
| std::optional< std::shared_ptr< const MessageType > > mrs_lib::Subscriber< MessageType >::peek_new_message |
( |
| ) |
const |
|
nodiscard |
Get the latest new message, if there is one.
- Returns
- The latest new message, if there is any, nullopt otherwise.
A new message is a message that was not yet used. A message is always marked as used if there is a callback associated with the subscriber. Additionally, it is marked as used by obtaining it using get_*message.
Calling this function does NOT mark the message as used.