Manages afferent processing in robotic nodes, including message handling, subscriptions, and modes for processing serialized data.
More...
#include <Afferent.hpp>
|
| Afferent (rclcpp_lifecycle::LifecycleNode::SharedPtr parent) |
| Constructor for the Afferent class.
|
|
virtual bool | configure ()=0 |
| Configures the afferent component; intended for subclass implementation.
|
|
size_t | get_max_queue_size () |
| Gets the maximum queue size.
|
|
EfferentProcessMode | get_mode () |
| Gets the current processing mode.
|
|
template<class MessageT> |
std::unique_ptr< MessageT > | get_msg () |
| Retrieves the next message from the queue, if available.
|
|
template<class MessageT> |
std::unique_ptr< MessageT > | get_msg (std::unique_ptr< rclcpp::SerializedMessage > msg) |
| Converts a serialized message to a typed message.
|
|
void | set_max_queue_size (size_t size) |
| Sets the maximum queue size for storing messages.
|
|
void | set_mode (EfferentProcessMode mode, std::function< void(std::unique_ptr< rclcpp::SerializedMessage >)> cb=nullptr) |
| Sets the processing mode and an optional callback function.
|
|
|
bool | create_subscriber (const std::string &topic, const std::string &type) |
| Creates a subscriber for a specific topic and message type.
|
|
Manages afferent processing in robotic nodes, including message handling, subscriptions, and modes for processing serialized data.
◆ EfferentProcessMode
Defines processing modes for serialized message handling.
Enumerator |
---|
CALLBACK | |
ONDEMAND | |
◆ Afferent()
Afferent |
( |
rclcpp_lifecycle::LifecycleNode::SharedPtr | parent | ) |
|
|
explicit |
Constructor for the Afferent class.
- Parameters
-
parent | Shared pointer to the lifecycle node managing this instance. |
parent | Shared pointer to the lifecycle node that owns this Afferent instance. |
◆ configure()
virtual bool configure |
( |
| ) |
|
|
pure virtual |
Configures the afferent component; intended for subclass implementation.
- Returns
- True if configuration is successful.
Implemented in SimpleImageInput.
◆ create_subscriber()
bool create_subscriber |
( |
const std::string & | topic, |
|
|
const std::string & | type ) |
|
protected |
Creates a subscriber for a specific topic and message type.
Creates a subscription to a specified topic and type.
- Parameters
-
topic | Topic to subscribe to. |
type | Type of message for the subscription. |
- Returns
- True if the subscriber was created successfully.
This method sets up a subscription to receive messages on a given topic with a specified message type. The received messages are either processed through a callback (if set) or stored in an internal message queue.
- Parameters
-
topic | The topic name to subscribe to. |
type | The type of messages expected on the topic. |
- Returns
- True if the subscription was created successfully.
◆ get_max_queue_size()
size_t get_max_queue_size |
( |
| ) |
|
Gets the maximum queue size.
- Returns
- The maximum queue size.
◆ get_mode()
◆ get_msg() [1/2]
template<class MessageT>
std::unique_ptr< MessageT > get_msg |
( |
| ) |
|
Retrieves the next message from the queue, if available.
- Template Parameters
-
MessageT | Type of message to retrieve. |
- Returns
- A unique pointer to the next message, or nullptr if the queue is empty.
◆ get_msg() [2/2]
template<class MessageT>
std::unique_ptr< MessageT > get_msg |
( |
std::unique_ptr< rclcpp::SerializedMessage > | msg | ) |
|
Converts a serialized message to a typed message.
- Template Parameters
-
MessageT | Type of the message to deserialize. |
- Parameters
-
msg | Serialized message to convert. |
- Returns
- A unique pointer to the deserialized message.
◆ set_max_queue_size()
void set_max_queue_size |
( |
size_t | size | ) |
|
Sets the maximum queue size for storing messages.
- Parameters
-
size | Maximum number of messages the queue can hold. |
◆ set_mode()
void set_mode |
( |
EfferentProcessMode | mode, |
|
|
std::function< void(std::unique_ptr< rclcpp::SerializedMessage >)> | cb = nullptr ) |
Sets the processing mode and an optional callback function.
Sets the operation mode and an optional callback function.
- Parameters
-
mode | Processing mode for handling messages. |
cb | Optional callback function for handling serialized messages in CALLBACK mode. |
This function allows configuring the Afferent object with a specific processing mode and an optional callback to handle serialized messages.
- Parameters
-
mode | The processing mode for the Afferent object. |
cb | A callback function to process serialized messages, used if the mode is CALLBACK. |
◆ callback_
std::function<void(std::unique_ptr<rclcpp::SerializedMessage>)> callback_ |
|
protected |
Callback for serialized messages.
◆ MAX_DEFAULT_QUEUE_SIZE
const size_t MAX_DEFAULT_QUEUE_SIZE = 100 |
|
protected |
Default maximum queue size.
◆ max_queue_size_
◆ mode_
◆ msg_queue_
std::queue<std::unique_ptr<rclcpp::SerializedMessage> > msg_queue_ |
|
protected |
Queue for serialized messages.
◆ parent_
rclcpp_lifecycle::LifecycleNode::SharedPtr parent_ |
|
protected |
Shared pointer to the parent node.
◆ subs_
std::vector<std::shared_ptr<rclcpp::GenericSubscription> > subs_ |
|
protected |
The documentation for this class was generated from the following files: