|
ROS 2 rclcpp + rcl - jazzy
jazzy
ROS 2 C++ Client Library with ROS Client Library
|
Subscription for serialized messages whose type is not known at compile time. More...
#include <rclcpp/generic_subscription.hpp>


Public Member Functions | |
| template<typename AllocatorT = std::allocator<void>> | |
| GenericSubscription (rclcpp::node_interfaces::NodeBaseInterface *node_base, const std::shared_ptr< rcpputils::SharedLibrary > ts_lib, const std::string &topic_name, const std::string &topic_type, const rclcpp::QoS &qos, AnySubscriptionCallback< rclcpp::SerializedMessage, AllocatorT > callback, const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &options) | |
| Constructor. More... | |
| RCLCPP_PUBLIC std::shared_ptr< void > | create_message () override |
| Borrow a new message. More... | |
| RCLCPP_PUBLIC std::shared_ptr< rclcpp::SerializedMessage > | create_serialized_message () override |
| Borrow a new serialized message. More... | |
| RCLCPP_PUBLIC void | handle_message (std::shared_ptr< void > &message, const rclcpp::MessageInfo &message_info) override |
| Cast the message to a rclcpp::SerializedMessage and call the callback. | |
| RCLCPP_PUBLIC void | handle_serialized_message (const std::shared_ptr< rclcpp::SerializedMessage > &serialized_message, const rclcpp::MessageInfo &message_info) override |
| Handle dispatching rclcpp::SerializedMessage to user callback. | |
| RCLCPP_PUBLIC void | handle_loaned_message (void *loaned_message, const rclcpp::MessageInfo &message_info) override |
| This function is currently not implemented. | |
| RCLCPP_PUBLIC void | return_message (std::shared_ptr< void > &message) override |
| Return the message borrowed in create_message. More... | |
| RCLCPP_PUBLIC void | return_serialized_message (std::shared_ptr< rclcpp::SerializedMessage > &message) override |
| Return the message borrowed in create_serialized_message. More... | |
| RCLCPP_PUBLIC rclcpp::dynamic_typesupport::DynamicMessageType::SharedPtr | get_shared_dynamic_message_type () override |
| RCLCPP_PUBLIC rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr | get_shared_dynamic_message () override |
| RCLCPP_PUBLIC rclcpp::dynamic_typesupport::DynamicSerializationSupport::SharedPtr | get_shared_dynamic_serialization_support () override |
| RCLCPP_PUBLIC rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr | create_dynamic_message () override |
| Borrow a new serialized message (this clones!) More... | |
| RCLCPP_PUBLIC void | return_dynamic_message (rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr &message) override |
| RCLCPP_PUBLIC void | handle_dynamic_message (const rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr &message, const rclcpp::MessageInfo &message_info) override |
Public Member Functions inherited from rclcpp::SubscriptionBase | |
| RCLCPP_PUBLIC | SubscriptionBase (rclcpp::node_interfaces::NodeBaseInterface *node_base, const rosidl_message_type_support_t &type_support_handle, const std::string &topic_name, const rcl_subscription_options_t &subscription_options, const SubscriptionEventCallbacks &event_callbacks, bool use_default_callbacks, DeliveredMessageKind delivered_message_kind=DeliveredMessageKind::ROS_MESSAGE) |
| Constructor. More... | |
| virtual RCLCPP_PUBLIC | ~SubscriptionBase () |
| Destructor. | |
| RCLCPP_PUBLIC void | bind_event_callbacks (const SubscriptionEventCallbacks &event_callbacks, bool use_default_callbacks) |
| Add event handlers for passed in event_callbacks. | |
| RCLCPP_PUBLIC const char * | get_topic_name () const |
| Get the topic that this subscription is subscribed on. | |
| RCLCPP_PUBLIC std::shared_ptr< rcl_subscription_t > | get_subscription_handle () |
| RCLCPP_PUBLIC std::shared_ptr< const rcl_subscription_t > | get_subscription_handle () const |
| RCLCPP_PUBLIC const std::unordered_map< rcl_subscription_event_type_t, std::shared_ptr< rclcpp::EventHandlerBase > > & | get_event_handlers () const |
| Get all the QoS event handlers associated with this subscription. More... | |
| RCLCPP_PUBLIC rclcpp::QoS | get_actual_qos () const |
| Get the actual QoS settings, after the defaults have been determined. More... | |
| RCLCPP_PUBLIC bool | take_type_erased (void *message_out, rclcpp::MessageInfo &message_info_out) |
| Take the next inter-process message from the subscription as a type erased pointer. More... | |
| RCLCPP_PUBLIC bool | take_serialized (rclcpp::SerializedMessage &message_out, rclcpp::MessageInfo &message_info_out) |
| Take the next inter-process message, in its serialized form, from the subscription. More... | |
| RCLCPP_PUBLIC const rosidl_message_type_support_t & | get_message_type_support_handle () const |
| RCLCPP_PUBLIC bool | is_serialized () const |
| Return if the subscription is serialized. More... | |
| RCLCPP_PUBLIC DeliveredMessageKind | get_delivered_message_kind () const |
| Return the delivered message kind. More... | |
| RCLCPP_PUBLIC size_t | get_publisher_count () const |
| Get matching publisher count. More... | |
| RCLCPP_PUBLIC bool | can_loan_messages () const |
| Check if subscription instance can loan messages. More... | |
| RCLCPP_PUBLIC void | setup_intra_process (uint64_t intra_process_subscription_id, IntraProcessManagerWeakPtr weak_ipm) |
| Implemenation detail. | |
| RCLCPP_PUBLIC rclcpp::Waitable::SharedPtr | get_intra_process_waitable () const |
| Return the waitable for intra-process. More... | |
| RCLCPP_PUBLIC bool | exchange_in_use_by_wait_set_state (void *pointer_to_subscription_part, bool in_use_state) |
| Exchange state of whether or not a part of the subscription is used by a wait set. More... | |
| RCLCPP_PUBLIC std::vector< rclcpp::NetworkFlowEndpoint > | get_network_flow_endpoints () const |
| Get network flow endpoints. More... | |
| void | set_on_new_message_callback (std::function< void(size_t)> callback) |
| Set a callback to be called when each new message is received. More... | |
| void | clear_on_new_message_callback () |
| Unset the callback registered for new messages, if any. | |
| void | set_on_new_intra_process_message_callback (std::function< void(size_t)> callback) |
| Set a callback to be called when each new intra-process message is received. More... | |
| void | clear_on_new_intra_process_message_callback () |
| Unset the callback registered for new intra-process messages, if any. | |
| void | set_on_new_qos_event_callback (std::function< void(size_t)> callback, rcl_subscription_event_type_t event_type) |
| Set a callback to be called when each new qos event instance occurs. More... | |
| void | clear_on_new_qos_event_callback (rcl_subscription_event_type_t event_type) |
| Unset the callback registered for new qos events, if any. | |
| RCLCPP_PUBLIC bool | is_cft_enabled () const |
| Check if content filtered topic feature of the subscription instance is enabled. More... | |
| RCLCPP_PUBLIC void | set_content_filter (const std::string &filter_expression, const std::vector< std::string > &expression_parameters={}) |
| Set the filter expression and expression parameters for the subscription. More... | |
| RCLCPP_PUBLIC rclcpp::ContentFilterOptions | get_content_filter () const |
| Get the filter expression and expression parameters for the subscription. More... | |
| RCLCPP_PUBLIC bool | take_dynamic_message (rclcpp::dynamic_typesupport::DynamicMessage &message_out, rclcpp::MessageInfo &message_info_out) |
Additional Inherited Members | |
Public Types inherited from rclcpp::SubscriptionBase | |
| using | IntraProcessManagerWeakPtr = std::weak_ptr< rclcpp::experimental::IntraProcessManager > |
Protected Member Functions inherited from rclcpp::SubscriptionBase | |
| template<typename EventCallbackT > | |
| void | add_event_handler (const EventCallbackT &callback, const rcl_subscription_event_type_t event_type) |
| RCLCPP_PUBLIC void | default_incompatible_qos_callback (QOSRequestedIncompatibleQoSInfo &info) const |
| RCLCPP_PUBLIC void | default_incompatible_type_callback (IncompatibleTypeInfo &info) const |
| RCLCPP_PUBLIC bool | matches_any_intra_process_publishers (const rmw_gid_t *sender_gid) const |
| RCLCPP_PUBLIC void | set_on_new_message_callback (rcl_event_callback_t callback, const void *user_data) |
Protected Attributes inherited from rclcpp::SubscriptionBase | |
| rclcpp::node_interfaces::NodeBaseInterface *const | node_base_ |
| std::shared_ptr< rcl_node_t > | node_handle_ |
| std::recursive_mutex | callback_mutex_ |
| std::function< void(size_t)> | on_new_message_callback_ {nullptr} |
| std::shared_ptr< rcl_subscription_t > | subscription_handle_ |
| std::shared_ptr< rcl_subscription_t > | intra_process_subscription_handle_ |
| rclcpp::Logger | node_logger_ |
| std::unordered_map< rcl_subscription_event_type_t, std::shared_ptr< rclcpp::EventHandlerBase > > | event_handlers_ |
| bool | use_intra_process_ |
| IntraProcessManagerWeakPtr | weak_ipm_ |
| uint64_t | intra_process_subscription_id_ |
| std::shared_ptr< rclcpp::experimental::SubscriptionIntraProcessBase > | subscription_intra_process_ |
| const SubscriptionEventCallbacks | event_callbacks_ |
Subscription for serialized messages whose type is not known at compile time.
Since the type is not known at compile time, this is not a template, and the dynamic library containing type support information has to be identified and loaded based on the type name.
It does not support intra-process handling.
Definition at line 45 of file generic_subscription.hpp.
|
inline |
Constructor.
In order to properly subscribe to a topic, this subscription needs to be added to the node_topic_interface of the node passed into this constructor.
| node_base | Pointer to parent node's NodeBaseInterface |
| ts_lib | Type support library, needs to correspond to topic_type |
| topic_name | Topic name |
| topic_type | Topic type |
| qos | QoS settings |
| callback | Callback for new messages of serialized form |
| options | Subscription options. Not all subscription options are currently respected, the only relevant options for this subscription are event_callbacks, use_default_callbacks, ignore_local_publications, and callback_group. |
Definition at line 71 of file generic_subscription.hpp.
|
overridevirtual |
Borrow a new serialized message (this clones!)
Implements rclcpp::SubscriptionBase.
Definition at line 106 of file generic_subscription.cpp.
|
overridevirtual |
Borrow a new message.
Implements rclcpp::SubscriptionBase.
Definition at line 29 of file generic_subscription.cpp.
References create_serialized_message().

|
overridevirtual |
Borrow a new serialized message.
Implements rclcpp::SubscriptionBase.
Definition at line 35 of file generic_subscription.cpp.
Referenced by create_message().

|
overridevirtual |
Return the message borrowed in create_message.
| [in] | message | Shared pointer to the returned message. |
Implements rclcpp::SubscriptionBase.
Definition at line 68 of file generic_subscription.cpp.
References return_serialized_message().

|
overridevirtual |
Return the message borrowed in create_serialized_message.
| [in] | message | Shared pointer to the returned message. |
Implements rclcpp::SubscriptionBase.
Definition at line 75 of file generic_subscription.cpp.
Referenced by return_message().
