SubscriberInterface Class Template
One-shot subscriber interface that receives a single message from a topic, then cleans up. More...
Declaration
class moveit_pro::behaviors::SubscriberInterface<MessageT> { ... }
Included Headers
Derived Classes
| class | RclcppSubscriberInterface<MessageT> |
|
rclcpp implementation of the one-shot subscriber interface. More... | |
Public Destructor Index
template <typename MessageT> | |
| ~SubscriberInterface ()=default | |
Public Member Functions Index
template <typename MessageT> | |
| auto | initialize (const std::string &topic_name, const std::chrono::duration< double > &wait_for_message_timeout, const std::chrono::duration< double > &wait_for_publisher_timeout, bool bypass_qos_negotiation=false)=0 -> tl::expected< void, std::string > |
|
Initialize the subscriber interface. More... | |
template <typename MessageT> | |
| auto | getNextMessage ()=0 -> std::future< tl::expected< MessageT, std::string > > |
|
Get a future for the next message through the subscriber interface. More... | |
template <typename MessageT> | |
| auto | syncGetNextMessage ()=0 -> tl::expected< MessageT, std::string > |
|
Get the next message through the subscriber interface (blocking). More... | |
template <typename MessageT> | |
| void | halt ()=0 |
|
Called to stop any long running processes. More... | |
Description
One-shot subscriber interface that receives a single message from a topic, then cleans up.
Lifecycle:
- initialize() — creates the subscription and optionally waits for a publisher.
- syncGetNextMessage() — blocks until the subscription callback fires (or times out). Returns the message.
- On message receipt, the subscription is destroyed to avoid processing further messages.
Thread safety: initialize() and syncGetNextMessage() must be called synchronously from the same thread. halt() can be called from a separate thread (e.g., the Behavior Tree executor) to cancel a blocking wait.
This interface can be easily mocked for testing to avoid needing to spin ROS nodes in tests.
- Template Parameters
-
MessageT ROS message type used to specialize this interface.
Definition at line 42 of file subscriber_interface.hpp.
Public Destructor
~SubscriberInterface()
| virtual default |
Definition at line 45 of file subscriber_interface.hpp.
Public Member Functions
getNextMessage()
|
Get a future for the next message through the subscriber interface.
- Returns
A future that will contain the message when it's received, or an error result if the message could not be received.
Definition at line 65 of file subscriber_interface.hpp.
halt()
|
Called to stop any long running processes.
Definition at line 76 of file subscriber_interface.hpp.
initialize()
|
Initialize the subscriber interface.
- Parameters
-
topic_name Name of the topic to use in the subscriber interface.
wait_for_message_timeout Message timeout duration to use in the subscriber interface.
wait_for_publisher_timeout Publisher timeout duration to use in the subscriber interface.
bypass_qos_negotiation If true, use default QoS instead of negotiating with publisher.
- Returns
Void if the subscriber interface was initialized successfully, or an error result if it could not be initialized successfully.
Definition at line 56 of file subscriber_interface.hpp.
syncGetNextMessage()
|
Get the next message through the subscriber interface (blocking).
- Returns
The message, if it was successfully received, or an error result if the message could not be received.
Definition at line 71 of file subscriber_interface.hpp.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.