15 #ifndef RCLCPP__EXECUTOR_HPP_ 16 #define RCLCPP__EXECUTOR_HPP_ 72 static inline ExecutorArgs create_default_executor_arguments()
119 add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
bool notify =
true);
135 remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
bool notify =
true);
149 template<
typename T = std::milli>
152 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
157 std::chrono::duration_cast<std::chrono::nanoseconds>(timeout)
162 template<
typename NodeT = rclcpp::Node,
typename T = std::milli>
169 node->get_node_base_interface(),
180 spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node);
212 template<
typename ResponseT,
typename TimeT = std::milli>
224 if (status == std::future_status::ready) {
232 end_time += timeout_ns;
241 if (status == std::future_status::ready) {
250 if (now >= end_time) {
281 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
295 rclcpp::SubscriptionBase::SharedPtr subscription);
300 rclcpp::SubscriptionBase::SharedPtr subscription);
319 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
323 rclcpp::callback_group::CallbackGroup::SharedPtr
331 AnyExecutable::SharedPtr
335 AnyExecutable::SharedPtr
359 #endif // RCLCPP__EXECUTOR_HPP_
static void execute_subscription(rclcpp::SubscriptionBase::SharedPtr subscription)
Definition: executor.hpp:66
static void execute_timer(rclcpp::TimerBase::SharedPtr timer)
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
virtual void spin_some()
Complete all available queued work without blocking.
void spin_node_once(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node, std::chrono::duration< int64_t, T > timeout=std::chrono::duration< int64_t, T >(-1))
Add a node to executor, execute the next available unit of work, and remove the node.
Definition: executor.hpp:151
void wait_for_work(std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Definition: allocator_common.hpp:24
T duration_cast(T... args)
std::ostream & operator<<(std::ostream &os, const FutureReturnCode &future_return_code)
void execute_any_executable(AnyExecutable::SharedPtr any_exec)
Find the next available executable and do the work associated with it.
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_by_group(rclcpp::callback_group::CallbackGroup::SharedPtr group)
rcl_wait_set_t rcl_get_zero_initialized_wait_set(void)
memory_strategy::MemoryStrategy::SharedPtr create_default_strategy()
rcl_guard_condition_t rcl_get_zero_initialized_guard_condition(void)
AnyExecutable::SharedPtr get_next_executable(std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
void spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node)
Add a node, complete all immediately available work, and remove the node.
void set_memory_strategy(memory_strategy::MemoryStrategy::SharedPtr memory_strategy)
Support dynamic switching of the memory strategy.
void spin_node_once_nanoseconds(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node, std::chrono::nanoseconds timeout)
std::string to_string(const FutureReturnCode &future_return_code)
void spin_node_once(std::shared_ptr< NodeT > node, std::chrono::duration< int64_t, T > timeout=std::chrono::duration< int64_t, T >(-1))
Convenience function which takes Node and forwards NodeBaseInterface.
Definition: executor.hpp:164
size_t max_conditions
Definition: executor.hpp:69
virtual void remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true)
Remove a node from the executor.
memory_strategy::MemoryStrategy::SharedPtr memory_strategy_
The memory strategy: an interface for handling user-defined memory allocation strategies.
Definition: executor.hpp:348
static void execute_service(rclcpp::ServiceBase::SharedPtr service)
virtual ~Executor()
Default destructor.
static void execute_client(rclcpp::ClientBase::SharedPtr client)
virtual void add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true)
Add a node to the executor.
Coordinate the order and timing of available communication tasks.
Definition: executor.hpp:90
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51
virtual void spin()=0
Do work periodically as it becomes available to us. Blocking call, may block indefinitely.
Executor(const ExecutorArgs &args=create_default_executor_arguments())
Default constructor.
FutureReturnCode
Return codes to be used with spin_until_future_complete.
Definition: executor.hpp:52
FutureReturnCode spin_until_future_complete(std::shared_future< ResponseT > &future, std::chrono::duration< int64_t, TimeT > timeout=std::chrono::duration< int64_t, TimeT >(-1))
Spin (blocking) until the future is complete, it times out waiting, or rclcpp is interrupted.
Definition: executor.hpp:214
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
bool ok()
Check rclcpp's status.
void get_next_timer(AnyExecutable::SharedPtr any_exec)
rclcpp::callback_group::CallbackGroup::SharedPtr get_group_by_timer(rclcpp::TimerBase::SharedPtr timer)
void cancel()
Cancel any running spin* function, causing it to return.
virtual void spin_once(std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
AnyExecutable::SharedPtr get_next_ready_executable()
static void execute_intra_process_subscription(rclcpp::SubscriptionBase::SharedPtr subscription)
rcl_guard_condition_t interrupt_guard_condition_
Guard condition for signaling the rmw layer to wake up for special events.
Definition: executor.hpp:342
rcl_wait_set_t wait_set_
Wait set for managing entities that the rmw layer waits on.
Definition: executor.hpp:345
std::atomic_bool spinning
Spinning state, used to prevent multi threaded calls to spin and to cancel blocking spins...
Definition: executor.hpp:339
memory_strategy::MemoryStrategy::SharedPtr memory_strategy
Definition: executor.hpp:68