rclcpp
master
C++ ROS Client Library API
|
Go to the documentation of this file.
15 #ifndef RCLCPP__EXECUTOR_HPP_
16 #define RCLCPP__EXECUTOR_HPP_
29 #include "rcl/guard_condition.h"
89 add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
bool notify =
true);
108 remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
bool notify =
true);
125 template<
typename RepT =
int64_t,
typename T = std::milli>
128 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
133 std::chrono::duration_cast<std::chrono::nanoseconds>(timeout)
138 template<
typename NodeT = rclcpp::Node,
typename RepT =
int64_t,
typename T = std::milli>
145 node->get_node_base_interface(),
146 std::chrono::duration_cast<std::chrono::nanoseconds>(timeout)
156 spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node);
192 template<
typename ResponseT,
typename TimeRepT =
int64_t,
typename TimeT = std::milli>
204 if (status == std::future_status::ready) {
212 end_time += timeout_ns;
217 throw std::runtime_error(
"spin_until_future_complete() called while already spinning");
222 spin_once_impl(timeout_left);
226 if (status == std::future_status::ready) {
235 if (now >= end_time) {
239 timeout_left = std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - now);
270 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node,
286 rclcpp::SubscriptionBase::SharedPtr subscription);
308 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
312 rclcpp::CallbackGroup::SharedPtr
362 #endif // RCLCPP__EXECUTOR_HPP_
virtual void spin_some(std::chrono::nanoseconds max_duration=std::chrono::nanoseconds(0))
Complete all available queued work without blocking.
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_by_group(rclcpp::CallbackGroup::SharedPtr group)
void spin_node_once_nanoseconds(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node, std::chrono::nanoseconds timeout)
FutureReturnCode
Return codes to be used with spin_until_future_complete.
Definition: future_return_code.hpp:33
void spin_node_once(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node, std::chrono::duration< RepT, T > timeout=std::chrono::duration< RepT, T >(-1))
Add a node to executor, execute the next available unit of work, and remove the node.
Definition: executor.hpp:127
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
rcl_guard_condition_t interrupt_guard_condition_
Guard condition for signaling the rmw layer to wake up for special events.
Definition: executor.hpp:329
virtual void spin_once(std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
static void execute_client(rclcpp::ClientBase::SharedPtr client)
virtual void spin()=0
Do work periodically as it becomes available to us. Blocking call, may block indefinitely.
memory_strategy::MemoryStrategy::SharedPtr memory_strategy_
The memory strategy: an interface for handling user-defined memory allocation strategies.
Definition: executor.hpp:338
void execute_any_executable(AnyExecutable &any_exec)
Find the next available executable and do the work associated with it.
Coordinate the order and timing of available communication tasks.
Definition: executor.hpp:58
rclcpp::Executor Executor
Definition: executor.hpp:357
std::mutex memory_strategy_mutex_
Definition: executor.hpp:335
std::list< rclcpp::node_interfaces::NodeBaseInterface::WeakPtr > weak_nodes_
Definition: executor.hpp:345
void cancel()
Cancel any running spin* function, causing it to return.
bool ok(rclcpp::Context::SharedPtr context=nullptr)
Check rclcpp's status.
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
rclcpp::CallbackGroup::SharedPtr get_group_by_timer(rclcpp::TimerBase::SharedPtr timer)
static void execute_timer(rclcpp::TimerBase::SharedPtr timer)
static void execute_service(rclcpp::ServiceBase::SharedPtr service)
Options to be passed to the executor constructor.
Definition: executor_options.hpp:28
virtual void remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true)
Remove a node from the executor.
void wait_for_work(std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
virtual ~Executor()
Default destructor.
Definition: any_executable.hpp:33
void spin_node_once(std::shared_ptr< NodeT > node, std::chrono::duration< RepT, T > timeout=std::chrono::duration< RepT, T >(-1))
Convenience function which takes Node and forwards NodeBaseInterface.
Definition: executor.hpp:140
#define RCLCPP_SCOPE_EXIT(code)
Definition: scope_exit.hpp:49
virtual void add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true)
Add a node to the executor.
bool get_next_executable(AnyExecutable &any_executable, std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
std::list< const rcl_guard_condition_t * > guard_conditions_
Definition: executor.hpp:346
Executor(const rclcpp::ExecutorOptions &options=rclcpp::ExecutorOptions())
Default constructor.
void set_memory_strategy(memory_strategy::MemoryStrategy::SharedPtr memory_strategy)
Support dynamic switching of the memory strategy.
bool get_next_ready_executable(AnyExecutable &any_executable)
FutureReturnCode spin_until_future_complete(const std::shared_future< ResponseT > &future, std::chrono::duration< TimeRepT, TimeT > timeout=std::chrono::duration< TimeRepT, TimeT >(-1))
Spin (blocking) until the future is complete, it times out waiting, or rclcpp is interrupted.
Definition: executor.hpp:194
rcl_wait_set_t wait_set_
Wait set for managing entities that the rmw layer waits on.
Definition: executor.hpp:332
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51
void spin_node_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node)
Add a node, complete all immediately available work, and remove the node.
std::atomic_bool spinning
Spinning state, used to prevent multi threaded calls to spin and to cancel blocking spins.
Definition: executor.hpp:326
std::shared_ptr< rclcpp::Context > context_
The context associated with this executor.
Definition: executor.hpp:341
static void execute_subscription(rclcpp::SubscriptionBase::SharedPtr subscription)