Template Class Subscription

Inheritance Relationships

Base Type

  • public SubscriptionBase

Class Documentation

template<typename MessageT, typename AllocatorT = std::allocator<void>, typename SubscribedT = typename rclcpp::TypeAdapter<MessageT>::custom_type, typename ROSMessageT = typename rclcpp::TypeAdapter<MessageT>::ros_message_type, typename MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<ROSMessageT, AllocatorT>>
class Subscription : public SubscriptionBase

Subscription implementation, templated on the type of message this subscription receives.

Public Types

using SubscribedType = SubscribedT

Redeclare these here to use outside of the class.

using ROSMessageType = ROSMessageT
using MessageMemoryStrategyType = MessageMemoryStrategyT
using SubscribedTypeAllocatorTraits = allocator::AllocRebind<SubscribedType, AllocatorT>
using SubscribedTypeAllocator = typename SubscribedTypeAllocatorTraits::allocator_type
using SubscribedTypeDeleter = allocator::Deleter<SubscribedTypeAllocator, SubscribedType>
using ROSMessageTypeAllocatorTraits = allocator::AllocRebind<ROSMessageType, AllocatorT>
using ROSMessageTypeAllocator = typename ROSMessageTypeAllocatorTraits::allocator_type
using ROSMessageTypeDeleter = allocator::Deleter<ROSMessageTypeAllocator, ROSMessageType>
using MessageAllocatorTraits = ROSMessageTypeAllocatorTraits
using MessageAllocator = ROSMessageTypeAllocator
using MessageDeleter = ROSMessageTypeDeleter
using ConstMessageSharedPtr = std::shared_ptr<const ROSMessageType>
using MessageUniquePtr = std::unique_ptr<ROSMessageType, ROSMessageTypeDeleter>

Public Functions

inline Subscription(rclcpp::node_interfaces::NodeBaseInterface *node_base, const rosidl_message_type_support_t &type_support_handle, const std::string &topic_name, const rclcpp::QoS &qos, AnySubscriptionCallback<MessageT, AllocatorT> callback, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> &options, typename MessageMemoryStrategyT::SharedPtr message_memory_strategy, SubscriptionTopicStatisticsSharedPtr subscription_topic_statistics = nullptr)
inline void post_init_setup(rclcpp::node_interfaces::NodeBaseInterface *node_base, const rclcpp::QoS &qos, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> &options)

Called after construction to continue setup that requires shared_from_this().

inline bool take(ROSMessageType &message_out, rclcpp::MessageInfo &message_info_out)
template<typename TakeT>
inline std::enable_if_t<!rosidl_generator_traits::is_message<TakeT>::value && std::is_same_v<TakeT, SubscribedType>, bool> take(TakeT &message_out, rclcpp::MessageInfo &message_info_out)
inline std::shared_ptr<void> create_message() override
inline std::shared_ptr<rclcpp::SerializedMessage> create_serialized_message() override
template<typename T = MessageT>
inline std::enable_if<has_data_type<T>::value>::type handle_message(const typename T::_data_type &data)
inline void handle_message(MessageT &message)
inline void handle_message(std::shared_ptr<MessageT> message)
inline void handle_message(std::shared_ptr<void> &message, const rclcpp::MessageInfo &message_info) override
inline void handle_serialized_message(const std::shared_ptr<rclcpp::SerializedMessage> &serialized_message, const rclcpp::MessageInfo &message_info) override
inline void handle_loaned_message(void *loaned_message, const rclcpp::MessageInfo &message_info) override
inline void return_message(std::shared_ptr<void> &message) override
inline void return_serialized_message(std::shared_ptr<rclcpp::SerializedMessage> &message) override
inline bool use_take_shared_method() const
inline rclcpp::dynamic_typesupport::DynamicMessageType::SharedPtr get_shared_dynamic_message_type() override
inline rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr get_shared_dynamic_message() override
inline rclcpp::dynamic_typesupport::DynamicSerializationSupport::SharedPtr get_shared_dynamic_serialization_support() override
inline rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr create_dynamic_message() override
inline void return_dynamic_message(rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr &message) override
inline void handle_dynamic_message(const rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr &message, const rclcpp::MessageInfo &message_info) override

Friends

friend class rclcpp::node_interfaces::NodeTopicsInterface