|
Modulo 5.0.0
|
The SubscriptionHandler handles different types of ROS subscriptions to receive data from those subscriptions. More...
#include <SubscriptionHandler.hpp>
Public Member Functions | |
| SubscriptionHandler (std::shared_ptr< MessagePairInterface > message_pair=nullptr, const rclcpp::Logger &logger=rclcpp::get_logger("SubscriptionHandler")) | |
| Constructor with the message pair. | |
| ~SubscriptionHandler () override | |
| Destructor to explicitly reset the subscription pointer. | |
| std::shared_ptr< rclcpp::Subscription< MsgT > > | get_subscription () const |
| Getter of the ROS subscription. | |
| void | set_subscription (const std::shared_ptr< rclcpp::Subscription< MsgT > > &subscription) |
| Setter of the ROS subscription. | |
| void | set_user_callback (const std::function< void()> &user_callback) |
| Setter of a user callback function to be executed after the subscription callback. | |
| std::function< void(const std::shared_ptr< MsgT >)> | get_callback () |
| Get a callback function that will be associated with the ROS subscription to receive and translate messages. | |
| std::function< void(const std::shared_ptr< MsgT >)> | get_callback (const std::function< void()> &user_callback) |
| Get a callback function that will be associated with the ROS subscription to receive and translate messages. | |
| std::shared_ptr< SubscriptionInterface > | create_subscription_interface (const std::shared_ptr< rclcpp::Subscription< MsgT > > &subscription) |
| Create a SubscriptionInterface pointer through an instance of a SubscriptionHandler by providing a ROS subscription. | |
Public Member Functions inherited from modulo_core::communication::SubscriptionInterface | |
| SubscriptionInterface (std::shared_ptr< MessagePairInterface > message_pair=nullptr) | |
| Constructor with the message pair. | |
| SubscriptionInterface (const SubscriptionInterface &subscription)=default | |
| Copy constructor from another SubscriptionInterface. | |
| virtual | ~SubscriptionInterface ()=default |
| Default virtual destructor. | |
| template<typename MsgT > | |
| std::shared_ptr< SubscriptionHandler< MsgT > > | get_handler (bool validate_pointer=true) |
| Get a pointer to a derived SubscriptionHandler instance from a SubscriptionInterface pointer. | |
| std::shared_ptr< MessagePairInterface > | get_message_pair () const |
| Get the pointer to the message pair of the SubscriptionInterface. | |
| void | set_message_pair (const std::shared_ptr< MessagePairInterface > &message_pair) |
| Set the pointer to the message pair of the SubscriptionInterface. | |
Additional Inherited Members | |
Protected Attributes inherited from modulo_core::communication::SubscriptionInterface | |
| std::shared_ptr< MessagePairInterface > | message_pair_ |
| The pointer to the stored MessagePair instance. | |
The SubscriptionHandler handles different types of ROS subscriptions to receive data from those subscriptions.
| MsgT | The ROS message type of the ROS subscription |
Definition at line 12 of file SubscriptionInterface.hpp.
|
explicit |
Constructor with the message pair.
| message_pair | The pointer to the message pair with the data that should be updated through the subscription |
| logger | An optional ROS logger to do logging from the subscription callback |
Definition at line 102 of file SubscriptionHandler.hpp.
|
override |
Destructor to explicitly reset the subscription pointer.
Definition at line 107 of file SubscriptionHandler.hpp.
| std::shared_ptr< SubscriptionInterface > modulo_core::communication::SubscriptionHandler< MsgT >::create_subscription_interface | ( | const std::shared_ptr< rclcpp::Subscription< MsgT > > & | subscription | ) |
Create a SubscriptionInterface pointer through an instance of a SubscriptionHandler by providing a ROS subscription.
This throws a NullPointerException if the ROS subscription is null.
| subscription | The ROS subscription |
Definition at line 168 of file SubscriptionHandler.hpp.
|
inline |
Get a callback function that will be associated with the ROS subscription to receive and translate messages.
Definition at line 125 of file SubscriptionHandler.hpp.
| std::function< void(const std::shared_ptr< MsgT >)> modulo_core::communication::SubscriptionHandler< MsgT >::get_callback | ( | const std::function< void()> & | user_callback | ) |
Get a callback function that will be associated with the ROS subscription to receive and translate messages.
This variant also takes a user callback function to execute after the message is received and translated.
| user_callback | Void callback function for additional logic after the message is received and translated. |
Definition at line 162 of file SubscriptionHandler.hpp.
|
nodiscard |
Getter of the ROS subscription.
Definition at line 112 of file SubscriptionHandler.hpp.
| void modulo_core::communication::SubscriptionHandler< MsgT >::set_subscription | ( | const std::shared_ptr< rclcpp::Subscription< MsgT > > & | subscription | ) |
Setter of the ROS subscription.
| subscription | The ROS subscription |
| modulo_core::exceptions::NullPointerException | if the provided subscription pointer is null |
Definition at line 117 of file SubscriptionHandler.hpp.
| void modulo_core::communication::SubscriptionHandler< MsgT >::set_user_callback | ( | const std::function< void()> & | user_callback | ) |
Setter of a user callback function to be executed after the subscription callback.
| user_callback | The ser callback function |
Definition at line 156 of file SubscriptionHandler.hpp.