15 #ifndef RCLCPP__EXPERIMENTAL__EXECUTORS__EVENTS_EXECUTOR__EVENTS_EXECUTOR_HPP_
16 #define RCLCPP__EXPERIMENTAL__EXECUTORS__EVENTS_EXECUTOR__EVENTS_EXECUTOR_HPP_
23 #include "rclcpp/executor.hpp"
24 #include "rclcpp/executors/executor_entities_collection.hpp"
25 #include "rclcpp/executors/executor_entities_collector.hpp"
26 #include "rclcpp/experimental/executors/events_executor/events_executor_event_types.hpp"
27 #include "rclcpp/experimental/executors/events_executor/events_queue.hpp"
28 #include "rclcpp/experimental/executors/events_executor/simple_events_queue.hpp"
29 #include "rclcpp/experimental/timers_manager.hpp"
30 #include "rclcpp/node.hpp"
34 namespace experimental
62 friend class EventsExecutorEntitiesCollector;
76 rclcpp::experimental::executors::EventsQueue::UniquePtr events_queue = std::make_unique<
78 bool execute_timers_separate_thread =
false,
111 spin_some(std::chrono::nanoseconds max_duration = std::chrono::nanoseconds(0))
override;
129 spin_all(std::chrono::nanoseconds max_duration)
override;
138 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
139 bool notify =
true)
override;
147 add_node(std::shared_ptr<rclcpp::Node> node_ptr,
bool notify =
true)
override;
156 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
157 bool notify =
true)
override;
165 remove_node(std::shared_ptr<rclcpp::Node> node_ptr,
bool notify =
true)
override;
174 rclcpp::CallbackGroup::SharedPtr group_ptr,
175 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
176 bool notify =
true)
override;
185 rclcpp::CallbackGroup::SharedPtr group_ptr,
186 bool notify =
true)
override;
193 std::vector<rclcpp::CallbackGroup::WeakPtr>
201 std::vector<rclcpp::CallbackGroup::WeakPtr>
209 std::vector<rclcpp::CallbackGroup::WeakPtr>
221 spin_some_impl(std::chrono::nanoseconds max_duration,
bool exhaustive);
232 refresh_current_collection_from_callback_groups();
239 std::function<void(
size_t)>
240 create_entity_callback(
void * entity_key, ExecutorEventType type);
243 std::function<void(
size_t,
int)>
248 add_notify_waitable_to_collection(
252 template<
typename CollectionType>
253 typename CollectionType::EntitySharedPtr
254 retrieve_entity(
typename CollectionType::Key entity_id, CollectionType & collection)
257 auto it = collection.find(entity_id);
258 if (it == collection.end()) {
264 auto entity = it->second.entity.lock();
266 collection.erase(it);
274 rclcpp::experimental::executors::EventsQueue::UniquePtr events_queue_;
276 std::shared_ptr<rclcpp::executors::ExecutorEntitiesCollector> entities_collector_;
277 std::shared_ptr<rclcpp::executors::ExecutorNotifyWaitable> notify_waitable_;
280 std::recursive_mutex collection_mutex_;
281 std::shared_ptr<rclcpp::executors::ExecutorEntitiesCollection> current_entities_collection_;
284 std::atomic<bool> notify_waitable_event_pushed_ {
false};
287 std::shared_ptr<rclcpp::experimental::TimersManager> timers_manager_;
Coordinate the order and timing of available communication tasks.
Events executor implementation.
RCLCPP_PUBLIC void remove_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr, bool notify=true) override
Remove callback group from the executor.
RCLCPP_PUBLIC void spin_once_impl(std::chrono::nanoseconds timeout) override
Internal implementation of spin_once.
RCLCPP_PUBLIC void spin() override
Events executor implementation of spin.
RCLCPP_PUBLIC std::vector< rclcpp::CallbackGroup::WeakPtr > get_all_callback_groups() override
Get callback groups that belong to executor.
virtual RCLCPP_PUBLIC ~EventsExecutor()
Default destructor.
RCLCPP_PUBLIC void add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true) override
Add a node to the executor.
RCLCPP_PUBLIC void remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true) override
Remove a node from the executor.
RCLCPP_PUBLIC void spin_some_impl(std::chrono::nanoseconds max_duration, bool exhaustive)
Internal implementation of spin_some.
RCLCPP_PUBLIC void add_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr, rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true) override
Add a callback group to an executor.
RCLCPP_PUBLIC EventsExecutor(rclcpp::experimental::executors::EventsQueue::UniquePtr events_queue=std::make_unique< rclcpp::experimental::executors::SimpleEventsQueue >(), bool execute_timers_separate_thread=false, const rclcpp::ExecutorOptions &options=rclcpp::ExecutorOptions())
Default constructor. See the default constructor for Executor.
RCLCPP_PUBLIC std::vector< rclcpp::CallbackGroup::WeakPtr > get_automatically_added_callback_groups_from_nodes() override
Get callback groups that belong to executor.
RCLCPP_PUBLIC void spin_all(std::chrono::nanoseconds max_duration) override
Events executor implementation of spin all.
RCLCPP_PUBLIC std::vector< rclcpp::CallbackGroup::WeakPtr > get_manually_added_callback_groups() override
Get callback groups that belong to executor.
RCLCPP_PUBLIC void spin_some(std::chrono::nanoseconds max_duration=std::chrono::nanoseconds(0)) override
Events executor implementation of spin some.
This class implements an EventsQueue as a simple wrapper around a std::queue. It does not perform any...
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
Options to be passed to the executor constructor.
Represent the total set of entities for a single executor.