ROS 2 rclcpp + rcl - rolling
rolling-a919a6e5
ROS 2 C++ Client Library with ROS Client Library
|
Public Member Functions | |
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 size_t | get_number_of_ready_guard_conditions () |
Get the number of ready guard_conditions. More... | |
virtual RCLCPP_PUBLIC void | add_to_wait_set (rcl_wait_set_t &wait_set)=0 |
Add the Waitable to a wait set. More... | |
virtual RCLCPP_PUBLIC bool | is_ready (const rcl_wait_set_t &wait_set)=0 |
Check if the Waitable is ready. More... | |
virtual RCLCPP_PUBLIC std::shared_ptr< void > | take_data ()=0 |
Take the data so that it can be consumed with execute . 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... | |
virtual RCLCPP_PUBLIC void | execute (const std::shared_ptr< void > &data)=0 |
Execute data that is passed in. 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... | |
virtual RCLCPP_PUBLIC void | set_on_ready_callback (std::function< void(size_t, int)> callback)=0 |
Set a callback to be called whenever the waitable becomes ready. More... | |
virtual RCLCPP_PUBLIC void | clear_on_ready_callback ()=0 |
Unset any callback registered via set_on_ready_callback. More... | |
virtual RCLCPP_PUBLIC std::vector< std::shared_ptr< rclcpp::TimerBase > > | get_timers () const =0 |
Returns all timers used by this waitable. More... | |
Definition at line 33 of file waitable.hpp.
|
pure virtual |
Add the Waitable to a wait set.
[in] | wait_set | A handle to the wait set to add the Waitable to. |
rclcpp::execptions::RCLError | from rcl_wait_set_add_*() |
Implemented in rclcpp::experimental::SubscriptionIntraProcessBuffer< SubscribedType, Alloc, Deleter, ROSMessageType >, rclcpp::experimental::SubscriptionIntraProcessBuffer< SubscribedType, std::allocator< SubscribedType >, std::default_delete< SubscribedType >, SubscribedType >, rclcpp::experimental::SubscriptionIntraProcessBase, rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >, rclcpp::executors::ExecutorNotifyWaitable, and rclcpp::EventHandlerBase.
|
pure virtual |
Unset any callback registered via set_on_ready_callback.
Note: this function must be overridden with a proper implementation by the custom classes who inherit from rclcpp::Waitable if they want to use it.
Implemented in rclcpp::experimental::SubscriptionIntraProcessBase, rclcpp::executors::ExecutorNotifyWaitable, and rclcpp::EventHandlerBase.
bool Waitable::exchange_in_use_by_wait_set_state | ( | bool | in_use_state | ) |
Exchange the "in use by wait set" state for this timer.
This is used to ensure this timer is not used by multiple wait sets at the same time.
[in] | in_use_state | the new state to exchange into the state, true indicates it is now in use by a wait set, and false is that it is no longer in use by a wait set. |
Definition at line 58 of file waitable.cpp.
|
pure virtual |
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:
Implemented in rclcpp::experimental::SubscriptionIntraProcessBase, rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >, rclcpp::executors::ExecutorNotifyWaitable, and rclcpp::EventHandler< EventCallbackT, ParentHandleT >.
|
virtual |
Get the number of ready clients.
Returns a value of 0 by default. This should be overridden if the Waitable contains one or more clients.
Definition at line 34 of file waitable.cpp.
|
virtual |
Get the number of ready events.
Returns a value of 0 by default. This should be overridden if the Waitable contains one or more events.
Reimplemented in rclcpp::EventHandlerBase.
Definition at line 40 of file waitable.cpp.
|
virtual |
Get the number of ready guard_conditions.
Returns a value of 0 by default. This should be overridden if the Waitable contains one or more guard_conditions.
Reimplemented in rclcpp::experimental::SubscriptionIntraProcessBase, and rclcpp::executors::ExecutorNotifyWaitable.
Definition at line 52 of file waitable.cpp.
|
virtual |
Get the number of ready services.
Returns a value of 0 by default. This should be overridden if the Waitable contains one or more services.
Definition at line 46 of file waitable.cpp.
|
virtual |
Get the number of ready subscriptions.
Returns a value of 0 by default. This should be overridden if the Waitable contains one or more subscriptions.
Definition at line 22 of file waitable.cpp.
|
virtual |
Get the number of ready timers.
Returns a value of 0 by default. This should be overridden if the Waitable contains one or more timers.
Definition at line 28 of file waitable.cpp.
|
pure virtual |
Returns all timers used by this waitable.
Must return all timers used within the waitable. Note, it is not supported, that timers are added or removed over the lifetime of the waitable.
Implemented in rclcpp::experimental::SubscriptionIntraProcessBase, rclcpp::executors::ExecutorNotifyWaitable, and rclcpp::EventHandlerBase.
|
pure virtual |
Check if the Waitable is ready.
The input wait set should be the same that was used in a previously call to add_to_wait_set()
. The wait set should also have been previously waited on with rcl_wait()
.
[in] | wait_set | A handle to the wait set the Waitable was previously added to and that has been waited on. |
true
if the Waitable is ready, false
otherwise. Implemented in rclcpp::experimental::SubscriptionIntraProcessBase, rclcpp::executors::ExecutorNotifyWaitable, and rclcpp::EventHandlerBase.
|
pure virtual |
Set a callback to be called whenever the waitable becomes ready.
The callback receives a size_t which is the number of times the waitable was ready since the last time this callback was called. Normally this is 1, but can be > 1 if waitable was triggered before any callback was set.
The callback also receives an int identifier argument. This is needed because a Waitable may be composed of several distinct entities, such as subscriptions, services, etc. The application should provide a generic callback function that will be then forwarded by the waitable to all of its entities. Before forwarding, a different value for the identifier argument will be bond to the function. This implies that the provided callback can use the identifier to behave differently depending on which entity triggered the waitable to become ready.
Note: this function must be overridden with a proper implementation by the custom classes who inherit from rclcpp::Waitable if they want to use it.
[in] | callback | functor to be called when the waitable becomes ready |
Implemented in rclcpp::experimental::SubscriptionIntraProcessBase, rclcpp::executors::ExecutorNotifyWaitable, and rclcpp::EventHandlerBase.
|
pure virtual |
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:
Implemented in rclcpp::experimental::SubscriptionIntraProcessBase, rclcpp::experimental::SubscriptionIntraProcess< MessageT, SubscribedType, SubscribedTypeAlloc, SubscribedTypeDeleter, ROSMessageType, Alloc >, rclcpp::executors::ExecutorNotifyWaitable, and rclcpp::EventHandler< EventCallbackT, ParentHandleT >.
|
pure virtual |
Take the data so that it can be consumed with execute
.
This function allows to specify an entity ID to take the data from. Entity IDs are identifiers that can be defined by waitable-derived classes that are composed of several distinct entities. The main use-case is in conjunction with the listener APIs.
[in] | id | the id of the entity from which to take |
Implemented in rclcpp::executors::ExecutorNotifyWaitable.