rclcpp  master
C++ ROS Client Library API
static_single_threaded_executor.hpp
Go to the documentation of this file.
1 // Copyright 2019 Nobleo Technology
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCLCPP__EXECUTORS__STATIC_SINGLE_THREADED_EXECUTOR_HPP_
16 #define RCLCPP__EXECUTORS__STATIC_SINGLE_THREADED_EXECUTOR_HPP_
17 
18 #include <chrono>
19 #include <cassert>
20 #include <cstdlib>
21 #include <memory>
22 #include <vector>
23 #include <string>
24 
25 #include "rmw/rmw.h"
26 
27 #include "rclcpp/executor.hpp"
30 #include "rclcpp/macros.hpp"
32 #include "rclcpp/node.hpp"
33 #include "rclcpp/rate.hpp"
34 #include "rclcpp/utilities.hpp"
36 
37 namespace rclcpp
38 {
39 namespace executors
40 {
41 
43 
59 {
60 public:
62 
63 
67 
71 
73 
79  void
80  spin() override;
81 
83 
97  void
99 
101 
115  void
116  spin_all(std::chrono::nanoseconds max_duration) override;
117 
119 
123  void
125  rclcpp::CallbackGroup::SharedPtr group_ptr,
126  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
127  bool notify = true) override;
128 
130 
134  void
136  rclcpp::CallbackGroup::SharedPtr group_ptr,
137  bool notify = true) override;
138 
140 
144  void
145  add_node(
146  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
147  bool notify = true) override;
148 
150 
154  void
155  add_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true) override;
156 
158 
162  void
163  remove_node(
164  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr,
165  bool notify = true) override;
166 
168 
172  void
173  remove_node(std::shared_ptr<rclcpp::Node> node_ptr, bool notify = true) override;
174 
177  get_all_callback_groups() override;
178 
180 
186 
188 
194 
195 protected:
202  bool
203  execute_ready_executables(bool spin_once = false);
204 
206  void
207  spin_some_impl(std::chrono::nanoseconds max_duration, bool exhaustive);
208 
210  void
211  spin_once_impl(std::chrono::nanoseconds timeout) override;
212 
213 private:
215 
216  StaticExecutorEntitiesCollector::SharedPtr entities_collector_;
217 };
218 
219 } // namespace executors
220 } // namespace rclcpp
221 
222 #endif // RCLCPP__EXECUTORS__STATIC_SINGLE_THREADED_EXECUTOR_HPP_
rclcpp::executors::StaticSingleThreadedExecutor::execute_ready_executables
bool execute_ready_executables(bool spin_once=false)
Executes ready executables from wait set.
rclcpp::executors::StaticSingleThreadedExecutor::add_node
void add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true) override
Add a node to the executor.
std::shared_ptr
RCLCPP_DISABLE_COPY
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
rclcpp::executors::StaticSingleThreadedExecutor::get_all_callback_groups
std::vector< rclcpp::CallbackGroup::WeakPtr > get_all_callback_groups() override
Get callback groups that belong to executor.
rmw.h
rclcpp::Executor::spin_once
virtual void spin_once(std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
rclcpp::executors::StaticSingleThreadedExecutor::add_callback_group
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.
std::vector< rclcpp::CallbackGroup::WeakPtr >
rclcpp::executors::StaticSingleThreadedExecutor::spin_some_impl
void spin_some_impl(std::chrono::nanoseconds max_duration, bool exhaustive)
node.hpp
rclcpp::executors::StaticSingleThreadedExecutor::~StaticSingleThreadedExecutor
virtual ~StaticSingleThreadedExecutor()
Default destrcutor.
std::chrono::nanoseconds
rclcpp::executors::StaticSingleThreadedExecutor::spin_some
void spin_some(std::chrono::nanoseconds max_duration=std::chrono::nanoseconds(0)) override
Static executor implementation of spin some.
rclcpp::Executor
Coordinate the order and timing of available communication tasks.
Definition: executor.hpp:65
executable_list.hpp
rclcpp::executors::StaticSingleThreadedExecutor::get_automatically_added_callback_groups_from_nodes
std::vector< rclcpp::CallbackGroup::WeakPtr > get_automatically_added_callback_groups_from_nodes() override
Get callback groups that belong to executor.
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
RCLCPP_PUBLIC
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
rclcpp::executors::StaticSingleThreadedExecutor::remove_callback_group
void remove_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr, bool notify=true) override
Remove callback group from the executor.
rclcpp::executors::StaticSingleThreadedExecutor
Static executor implementation.
Definition: static_single_threaded_executor.hpp:58
RCLCPP_SMART_PTR_DEFINITIONS
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
macros.hpp
static_executor_entities_collector.hpp
rclcpp::ExecutorOptions
Options to be passed to the executor constructor.
Definition: executor_options.hpp:28
rclcpp::executors::StaticSingleThreadedExecutor::remove_node
void remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify=true) override
Remove a node from the executor.
rclcpp::executors::StaticSingleThreadedExecutor::spin
void spin() override
Static executor implementation of spin.
rate.hpp
executor.hpp
rclcpp::executors::StaticSingleThreadedExecutor::spin_once_impl
void spin_once_impl(std::chrono::nanoseconds timeout) override
rclcpp::executors::StaticSingleThreadedExecutor::StaticSingleThreadedExecutor
StaticSingleThreadedExecutor(const rclcpp::ExecutorOptions &options=rclcpp::ExecutorOptions())
Default constructor. See the default constructor for Executor.
visibility_control.hpp
rclcpp::executors::StaticSingleThreadedExecutor::spin_all
void spin_all(std::chrono::nanoseconds max_duration) override
Static executor implementation of spin all.
rclcpp::executors::StaticSingleThreadedExecutor::get_manually_added_callback_groups
std::vector< rclcpp::CallbackGroup::WeakPtr > get_manually_added_callback_groups() override
Get callback groups that belong to executor.
memory_strategies.hpp
utilities.hpp