ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc > Class Template Reference
Inheritance diagram for rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >:
Collaboration graph
[legend]

Public Types

using MessageAllocTraits = typename SubscriptionIntraProcessBufferT::SubscribedTypeAllocatorTraits
 
using MessageAlloc = typename SubscriptionIntraProcessBufferT::SubscribedTypeAllocator
 
using ConstMessageSharedPtr = typename SubscriptionIntraProcessBufferT::ConstDataSharedPtr
 
using MessageUniquePtr = typename SubscriptionIntraProcessBufferT::SubscribedTypeUniquePtr
 
using BufferUniquePtr = typename SubscriptionIntraProcessBufferT::BufferUniquePtr
 
- Public Types inherited from rclcpp::experimental::SubscriptionIntraProcessBuffer< SubscribedType, std::allocator< SubscribedType >, std::default_delete< SubscribedType >, SubscribedType >
using SubscribedTypeAllocatorTraits = allocator::AllocRebind< SubscribedType, std::allocator< SubscribedType > >
 
using SubscribedTypeAllocator = typename SubscribedTypeAllocatorTraits::allocator_type
 
using SubscribedTypeDeleter = allocator::Deleter< SubscribedTypeAllocator, SubscribedType >
 
using ROSMessageTypeAllocatorTraits = allocator::AllocRebind< SubscribedType, std::allocator< SubscribedType > >
 
using ROSMessageTypeAllocator = typename ROSMessageTypeAllocatorTraits::allocator_type
 
using ROSMessageTypeDeleter = allocator::Deleter< ROSMessageTypeAllocator, SubscribedType >
 
using ConstMessageSharedPtr = std::shared_ptr< const SubscribedType >
 
using MessageUniquePtr = std::unique_ptr< SubscribedType, ROSMessageTypeDeleter >
 
using ConstDataSharedPtr = std::shared_ptr< const SubscribedType >
 
using SubscribedTypeUniquePtr = std::unique_ptr< SubscribedType, SubscribedTypeDeleter >
 
using BufferUniquePtr = typename rclcpp::experimental::buffers::IntraProcessBuffer< SubscribedType, std::allocator< SubscribedType >, SubscribedTypeDeleter >::UniquePtr
 
- Public Types inherited from rclcpp::experimental::SubscriptionROSMsgIntraProcessBuffer< SubscribedType, allocator::AllocRebind< SubscribedType, std::allocator< SubscribedType > >::allocator_type, allocator::Deleter< allocator::AllocRebind< SubscribedType, std::allocator< SubscribedType > >::allocator_type, SubscribedType > >
using ROSMessageTypeAllocatorTraits = allocator::AllocRebind< SubscribedType, allocator::AllocRebind< SubscribedType, std::allocator< SubscribedType > >::allocator_type >
 
using ROSMessageTypeAllocator = typename ROSMessageTypeAllocatorTraits::allocator_type
 
using ROSMessageTypeDeleter = allocator::Deleter< ROSMessageTypeAllocator, SubscribedType >
 
using ConstMessageSharedPtr = std::shared_ptr< const SubscribedType >
 
using MessageUniquePtr = std::unique_ptr< SubscribedType, ROSMessageTypeDeleter >
 
- Public Types inherited from rclcpp::experimental::SubscriptionIntraProcessBase
enum class  EntityType : std::size_t { Subscription }
 

Public Member Functions

 SubscriptionIntraProcess (AnySubscriptionCallback< MessageT, Alloc > callback, std::shared_ptr< Alloc > allocator, rclcpp::Context::SharedPtr context, const std::string &topic_name, const rclcpp::QoS &qos_profile, rclcpp::IntraProcessBufferType buffer_type)
 
void add_to_wait_set (rcl_wait_set_t &wait_set) override
 Add the Waitable to a wait set. More...
 
std::shared_ptr< void > take_data () override
 Take the data so that it can be consumed with execute. More...
 
void execute (const std::shared_ptr< void > &data) override
 Execute data that is passed in. More...
 
- Public Member Functions inherited from rclcpp::experimental::SubscriptionIntraProcessBuffer< SubscribedType, std::allocator< SubscribedType >, std::default_delete< SubscribedType >, SubscribedType >
 SubscriptionIntraProcessBuffer (std::shared_ptr< std::allocator< SubscribedType > > allocator, rclcpp::Context::SharedPtr context, const std::string &topic_name, const rclcpp::QoS &qos_profile, rclcpp::IntraProcessBufferType buffer_type)
 
void add_to_wait_set (rcl_wait_set_t &wait_set) override
 Add the Waitable to a wait set. More...
 
bool is_ready ([[maybe_unused]] const rcl_wait_set_t &wait_set) override
 
SubscribedTypeUniquePtr convert_ros_message_to_subscribed_type_unique_ptr (const SubscribedType &msg)
 
void provide_intra_process_message (ConstMessageSharedPtr message) override
 
void provide_intra_process_message (MessageUniquePtr message) override
 
void provide_intra_process_data (ConstDataSharedPtr message)
 
void provide_intra_process_data (SubscribedTypeUniquePtr message)
 
bool use_take_shared_method () const override
 
size_t available_capacity () const override
 
- Public Member Functions inherited from rclcpp::experimental::SubscriptionROSMsgIntraProcessBuffer< SubscribedType, allocator::AllocRebind< SubscribedType, std::allocator< SubscribedType > >::allocator_type, allocator::Deleter< allocator::AllocRebind< SubscribedType, std::allocator< SubscribedType > >::allocator_type, SubscribedType > >
 SubscriptionROSMsgIntraProcessBuffer (rclcpp::Context::SharedPtr context, const std::string &topic_name, const rclcpp::QoS &qos_profile)
 
- Public Member Functions inherited from rclcpp::experimental::SubscriptionIntraProcessBase
RCLCPP_PUBLIC SubscriptionIntraProcessBase (rclcpp::Context::SharedPtr context, const std::string &topic_name, const rclcpp::QoS &qos_profile)
 
RCLCPP_PUBLIC size_t get_number_of_ready_guard_conditions () override
 Get the number of ready guard_conditions. More...
 
RCLCPP_PUBLIC bool is_durability_transient_local () const
 
bool is_ready (const rcl_wait_set_t &wait_set) override=0
 Check if the Waitable is ready. More...
 
std::shared_ptr< void > take_data_by_entity_id ([[maybe_unused]] size_t id) override
 
RCLCPP_PUBLIC const char * get_topic_name () const
 
RCLCPP_PUBLIC QoS get_actual_qos () const
 
void set_on_ready_callback (std::function< void(size_t, int)> callback) override
 Set a callback to be called when each new message arrives. More...
 
void clear_on_ready_callback () override
 Unset the callback registered for new messages, if any.
 
RCLCPP_PUBLIC std::vector< std::shared_ptr< rclcpp::TimerBase > > get_timers () const override
 Returns all timers used by this waitable. More...
 
- Public Member Functions inherited from rclcpp::Waitable
virtual RCLCPP_PUBLIC size_t get_number_of_ready_subscriptions ()
 Get the number of ready subscriptions. More...
 
virtual RCLCPP_PUBLIC size_t get_number_of_ready_timers ()
 Get the number of ready timers. More...
 
virtual RCLCPP_PUBLIC size_t get_number_of_ready_clients ()
 Get the number of ready clients. More...
 
virtual RCLCPP_PUBLIC size_t get_number_of_ready_events ()
 Get the number of ready events. More...
 
virtual RCLCPP_PUBLIC size_t get_number_of_ready_services ()
 Get the number of ready services. More...
 
virtual RCLCPP_PUBLIC std::shared_ptr< void > take_data_by_entity_id (size_t id)=0
 Take the data so that it can be consumed with execute. More...
 
RCLCPP_PUBLIC bool exchange_in_use_by_wait_set_state (bool in_use_state)
 Exchange the "in use by wait set" state for this timer. More...
 

Protected Member Functions

template<typename T >
std::enable_if< std::is_same< T, rcl_serialized_message_t >::value, void >::type execute_impl (const std::shared_ptr< void > &)
 
template<class T >
std::enable_if<!std::is_same< T, rcl_serialized_message_t >::value, void >::type execute_impl (const std::shared_ptr< void > &data)
 
- Protected Member Functions inherited from rclcpp::experimental::SubscriptionIntraProcessBuffer< SubscribedType, std::allocator< SubscribedType >, std::default_delete< SubscribedType >, SubscribedType >
void trigger_guard_condition () override
 
- Protected Member Functions inherited from rclcpp::experimental::SubscriptionIntraProcessBase
void invoke_on_new_message ()
 

Protected Attributes

AnySubscriptionCallback< MessageT, Alloc > any_callback_
 
- Protected Attributes inherited from rclcpp::experimental::SubscriptionIntraProcessBuffer< SubscribedType, std::allocator< SubscribedType >, std::default_delete< SubscribedType >, SubscribedType >
BufferUniquePtr buffer_
 
SubscribedTypeAllocator subscribed_type_allocator_
 
SubscribedTypeDeleter subscribed_type_deleter_
 
- Protected Attributes inherited from rclcpp::experimental::SubscriptionIntraProcessBase
std::recursive_mutex callback_mutex_
 
std::function< void(size_t)> on_new_message_callback_ {nullptr}
 
size_t unread_count_ {0}
 
rclcpp::GuardCondition gc_
 

Detailed Description

template<typename MessageT, typename SubscribedType, typename SubscribedTypeAlloc = std::allocator<SubscribedType>, typename SubscribedTypeDeleter = std::default_delete<SubscribedType>, typename ROSMessageType = SubscribedType, typename Alloc = std::allocator<void>>
class rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >

Definition at line 49 of file subscription_intra_process.hpp.

Member Function Documentation

◆ add_to_wait_set()

template<typename MessageT , typename SubscribedType , typename SubscribedTypeAlloc = std::allocator<SubscribedType>, typename SubscribedTypeDeleter = std::default_delete<SubscribedType>, typename ROSMessageType = SubscribedType, typename Alloc = std::allocator<void>>
void rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >::add_to_wait_set ( rcl_wait_set_t wait_set)
inlineoverridevirtual

Add the Waitable to a wait set.

Parameters
[in]wait_setA handle to the wait set to add the Waitable to.
Exceptions
rclcpp::execptions::RCLErrorfrom rcl_wait_set_add_*()

Implements rclcpp::Waitable.

Definition at line 105 of file subscription_intra_process.hpp.

References rclcpp::experimental::SubscriptionIntraProcessBuffer< SubscribedType, Alloc, Deleter, ROSMessageType >::add_to_wait_set().

Here is the call graph for this function:

◆ execute()

template<typename MessageT , typename SubscribedType , typename SubscribedTypeAlloc = std::allocator<SubscribedType>, typename SubscribedTypeDeleter = std::default_delete<SubscribedType>, typename ROSMessageType = SubscribedType, typename Alloc = std::allocator<void>>
void rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >::execute ( const std::shared_ptr< void > &  data)
inlineoverridevirtual

Execute data that is passed in.

Before calling this method, the Waitable should be added to a wait set, waited on, and then updated - and the take_data method should be called.

Example usage:

// ... create a wait set and a Waitable
// Add the Waitable to the wait set
waitable.add_to_wait_set(wait_set);
// Wait
rcl_ret_t wait_ret = rcl_wait(wait_set);
// ... error handling
// Update the Waitable
waitable.update(wait_set);
// Execute any entities of the Waitable that may be ready
std::shared_ptr<void> data = waitable.take_data();
waitable.execute(data);
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:24
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait(rcl_wait_set_t *wait_set, int64_t timeout)
Block until the wait set is ready or until the timeout has been exceeded.
Definition: wait.c:509

Implements rclcpp::experimental::SubscriptionIntraProcessBase.

Definition at line 152 of file subscription_intra_process.hpp.

◆ take_data()

template<typename MessageT , typename SubscribedType , typename SubscribedTypeAlloc = std::allocator<SubscribedType>, typename SubscribedTypeDeleter = std::default_delete<SubscribedType>, typename ROSMessageType = SubscribedType, typename Alloc = std::allocator<void>>
std::shared_ptr<void> rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >::take_data ( )
inlineoverridevirtual

Take the data so that it can be consumed with execute.

NOTE: take_data is a partial fix to a larger design issue with the multithreaded executor. This method is likely to be removed when a more permanent fix is implemented. A longterm fix is currently being discussed here: https://github.com/ros2/rclcpp/pull/1276

This method takes the data from the underlying data structure and writes it to the void shared pointer data that is passed into the method. The data can then be executed with the execute method.

Before calling this method, the Waitable should be added to a wait set, waited on, and then updated.

Example usage:

// ... create a wait set and a Waitable
// Add the Waitable to the wait set
waitable.add_to_wait_set(wait_set);
// Wait
rcl_ret_t wait_ret = rcl_wait(wait_set);
// ... error handling
// Update the Waitable
waitable.update(wait_set);
// Execute any entities of the Waitable that may be ready
std::shared_ptr<void> data = waitable.take_data();

Implements rclcpp::experimental::SubscriptionIntraProcessBase.

Definition at line 122 of file subscription_intra_process.hpp.


The documentation for this class was generated from the following file: