rclcpp
master
C++ ROS Client Library API
|
Subscription implementation, templated on the type of message this subscription receives. More...
#include <subscription.hpp>
Public Types | |
using | MessageAllocTraits = allocator::AllocRebind< CallbackMessageT, Alloc > |
using | MessageAlloc = typename MessageAllocTraits::allocator_type |
using | MessageDeleter = allocator::Deleter< MessageAlloc, CallbackMessageT > |
using | ConstMessageSharedPtr = std::shared_ptr< const CallbackMessageT > |
using | MessageUniquePtr = std::unique_ptr< CallbackMessageT, MessageDeleter > |
Public Types inherited from rclcpp::SubscriptionBase | |
using | IntraProcessManagerWeakPtr = std::weak_ptr< rclcpp::intra_process_manager::IntraProcessManager > |
Public Member Functions | |
Subscription (std::shared_ptr< rcl_node_t > node_handle, const rosidl_message_type_support_t &type_support_handle, const std::string &topic_name, const rcl_subscription_options_t &subscription_options, AnySubscriptionCallback< CallbackMessageT, Alloc > callback, const SubscriptionEventCallbacks &event_callbacks, typename message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, Alloc >::SharedPtr memory_strategy=message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, Alloc >::create_default()) | |
Default constructor. More... | |
void | set_message_memory_strategy (typename message_memory_strategy::MessageMemoryStrategy< CallbackMessageT, Alloc >::SharedPtr message_memory_strategy) |
Support dynamically setting the message memory strategy. More... | |
std::shared_ptr< void > | create_message () |
Borrow a new message. More... | |
std::shared_ptr< rcl_serialized_message_t > | create_serialized_message () |
Borrow a new serialized message. More... | |
void | handle_message (std::shared_ptr< void > &message, const rmw_message_info_t &message_info) |
Check if we need to handle the message, and execute the callback if we do. More... | |
void | return_message (std::shared_ptr< void > &message) |
Return the loaned message. More... | |
void | return_serialized_message (std::shared_ptr< rcl_serialized_message_t > &message) |
Return the message borrowed in create_serialized_message. More... | |
void | handle_intra_process_message (rcl_interfaces::msg::IntraProcessMessage &ipm, const rmw_message_info_t &message_info) |
const std::shared_ptr< rcl_subscription_t > | get_intra_process_subscription_handle () const |
Implemenation detail. More... | |
Public Member Functions inherited from rclcpp::SubscriptionBase | |
SubscriptionBase (std::shared_ptr< rcl_node_t > node_handle, const rosidl_message_type_support_t &type_support_handle, const std::string &topic_name, const rcl_subscription_options_t &subscription_options, bool is_serialized=false) | |
Default constructor. More... | |
virtual | ~SubscriptionBase () |
Default destructor. More... | |
const char * | get_topic_name () const |
Get the topic that this subscription is subscribed on. More... | |
std::shared_ptr< rcl_subscription_t > | get_subscription_handle () |
const std::shared_ptr< rcl_subscription_t > | get_subscription_handle () const |
const std::vector< std::shared_ptr< rclcpp::QOSEventHandlerBase > > & | get_event_handlers () const |
Get all the QoS event handlers associated with this subscription. More... | |
const rosidl_message_type_support_t & | get_message_type_support_handle () const |
bool | is_serialized () const |
size_t | get_publisher_count () const |
Get matching publisher count. More... | |
void | setup_intra_process (uint64_t intra_process_subscription_id, IntraProcessManagerWeakPtr weak_ipm, const rcl_subscription_options_t &intra_process_options) |
Implemenation detail. More... | |
Friends | |
class | rclcpp::node_interfaces::NodeTopicsInterface |
Additional Inherited Members | |
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) |
Protected Attributes inherited from rclcpp::SubscriptionBase | |
std::shared_ptr< rcl_node_t > | node_handle_ |
std::shared_ptr< rcl_subscription_t > | subscription_handle_ |
std::shared_ptr< rcl_subscription_t > | intra_process_subscription_handle_ |
std::vector< std::shared_ptr< rclcpp::QOSEventHandlerBase > > | event_handlers_ |
bool | use_intra_process_ |
IntraProcessManagerWeakPtr | weak_ipm_ |
uint64_t | intra_process_subscription_id_ |
Subscription implementation, templated on the type of message this subscription receives.
using rclcpp::Subscription< CallbackMessageT, Alloc >::MessageAllocTraits = allocator::AllocRebind<CallbackMessageT, Alloc> |
using rclcpp::Subscription< CallbackMessageT, Alloc >::MessageAlloc = typename MessageAllocTraits::allocator_type |
using rclcpp::Subscription< CallbackMessageT, Alloc >::MessageDeleter = allocator::Deleter<MessageAlloc, CallbackMessageT> |
using rclcpp::Subscription< CallbackMessageT, Alloc >::ConstMessageSharedPtr = std::shared_ptr<const CallbackMessageT> |
using rclcpp::Subscription< CallbackMessageT, Alloc >::MessageUniquePtr = std::unique_ptr<CallbackMessageT, MessageDeleter> |
|
inline |
Default constructor.
The constructor for a subscription is almost never called directly. Instead, subscriptions should be instantiated through Node::create_subscription.
[in] | node_handle | rcl representation of the node that owns this subscription. |
[in] | type_support_handle | rosidl type support struct, for the Message type of the topic. |
[in] | topic_name | Name of the topic to subscribe to. |
[in] | subscription_options | options for the subscription. |
[in] | callback | User defined callback to call when a message is received. |
[in] | memory_strategy | The memory strategy to be used for managing message memory. |
|
inline |
Support dynamically setting the message memory strategy.
Behavior may be undefined if called while the subscription could be executing.
[in] | message_memory_strategy | Shared pointer to the memory strategy to set. |
|
inlinevirtual |
Borrow a new message.
Implements rclcpp::SubscriptionBase.
|
inlinevirtual |
Borrow a new serialized message.
Implements rclcpp::SubscriptionBase.
|
inlinevirtual |
Check if we need to handle the message, and execute the callback if we do.
[in] | message | Shared pointer to the message to handle. |
[in] | message_info | Metadata associated with this message. |
Implements rclcpp::SubscriptionBase.
|
inlinevirtual |
Return the loaned message.
message | message to be returned |
Implements rclcpp::SubscriptionBase.
|
inlinevirtual |
Return the message borrowed in create_serialized_message.
[in] | message | Shared pointer to the returned message. |
Implements rclcpp::SubscriptionBase.
|
inlinevirtual |
Implements rclcpp::SubscriptionBase.
|
inlinevirtual |
Implemenation detail.
Reimplemented from rclcpp::SubscriptionBase.
|
friend |