Skip to content

Commit 8552ce1

Browse files
committed
Add 'executor_type' parameter to ComponentManager and deprecate redundant component containers
Signed-off-by: Arman Hosseini <armanhosseini878787@gmail.com>
1 parent bddd610 commit 8552ce1

File tree

14 files changed

+122
-10
lines changed

14 files changed

+122
-10
lines changed

rclcpp/include/rclcpp/executor.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,10 @@ class Executor
407407
bool
408408
is_spinning();
409409

410+
RCLCPP_PUBLIC
411+
virtual std::string
412+
get_class_name() const = 0;
413+
410414
protected:
411415
/// Constructor that will not initialize any non-trivial members.
412416
/**

rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <memory>
2020
#include <mutex>
2121
#include <set>
22+
#include <string>
2223
#include <thread>
2324
#include <unordered_map>
2425

@@ -73,6 +74,10 @@ class MultiThreadedExecutor : public rclcpp::Executor
7374
size_t
7475
get_number_of_threads();
7576

77+
RCLCPP_PUBLIC
78+
std::string
79+
get_class_name() const override;
80+
7681
protected:
7782
RCLCPP_PUBLIC
7883
void

rclcpp/include/rclcpp/executors/single_threaded_executor.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cassert>
2121
#include <cstdlib>
2222
#include <memory>
23+
#include <string>
2324
#include <vector>
2425

2526
#include "rclcpp/executor.hpp"
@@ -65,6 +66,10 @@ class SingleThreadedExecutor : public rclcpp::Executor
6566
void
6667
spin() override;
6768

69+
RCLCPP_PUBLIC
70+
std::string
71+
get_class_name() const override;
72+
6873
private:
6974
RCLCPP_DISABLE_COPY(SingleThreadedExecutor)
7075
};

rclcpp/include/rclcpp/experimental/executors/events_executor/events_executor.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <atomic>
1919
#include <chrono>
2020
#include <memory>
21+
#include <string>
2122
#include <vector>
2223

2324
#include "rclcpp/executor.hpp"
@@ -126,6 +127,10 @@ class EventsExecutor : public rclcpp::Executor
126127
void
127128
spin_all(std::chrono::nanoseconds max_duration) override;
128129

130+
RCLCPP_PUBLIC
131+
std::string
132+
get_class_name() const override;
133+
129134
protected:
130135
/// Internal implementation of spin_once
131136
RCLCPP_PUBLIC

rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ MultiThreadedExecutor::get_number_of_threads()
7878
return number_of_threads_;
7979
}
8080

81+
std::string
82+
MultiThreadedExecutor::get_class_name() const
83+
{
84+
return "MultiThreadedExecutor";
85+
}
86+
8187
void
8288
MultiThreadedExecutor::run([[maybe_unused]] size_t this_thread_number)
8389
{

rclcpp/src/rclcpp/executors/single_threaded_executor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ SingleThreadedExecutor::spin()
4343
}
4444
}
4545
}
46+
47+
std::string
48+
SingleThreadedExecutor::get_class_name() const
49+
{
50+
return "SingleThreadedExecutor";
51+
}

rclcpp/src/rclcpp/experimental/executors/events_executor/events_executor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ EventsExecutor::spin_once_impl(std::chrono::nanoseconds timeout)
240240
}
241241
}
242242

243+
std::string
244+
EventsExecutor::get_class_name() const
245+
{
246+
return "EventsExecutor";
247+
}
243248

244249
void
245250
EventsExecutor::execute_event(const ExecutorEvent & event)

rclcpp/test/rclcpp/executors/test_executors_callback_group_behavior.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class CustomExecutor : public rclcpp::Executor
4242

4343
void spin() override {}
4444

45+
std::string get_class_name() const override
46+
{
47+
return "CustomExecutor";
48+
}
49+
4550
void collect()
4651
{
4752
this->collect_entities();

rclcpp/test/rclcpp/test_executor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class DummyExecutor : public rclcpp::Executor
4747
{
4848
}
4949

50+
std::string get_class_name() const override
51+
{
52+
return "DummyExecutor";
53+
}
54+
5055
void spin_nanoseconds(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node)
5156
{
5257
spin_node_once_nanoseconds(node, std::chrono::milliseconds(100));

rclcpp_components/include/rclcpp_components/component_manager.hpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ class ComponentManager : public rclcpp::Node
9090
using ComponentResource = std::pair<std::string, std::string>;
9191

9292
/// Default constructor
93+
/**
94+
* Initializes the component manager. It creates the services: load node, unload node
95+
* and list nodes. Initialize executor after construction using set_executor.
96+
*
97+
* \param executor the executor which will spin the node.
98+
* \param node_name the name of the node that the data originates from.
99+
* \param node_options additional options to control creation of the node.
100+
*/
101+
RCLCPP_COMPONENTS_PUBLIC
102+
ComponentManager(
103+
std::string node_name = "ComponentManager",
104+
const rclcpp::NodeOptions & node_options = rclcpp::NodeOptions());
105+
106+
/// Constructor with executor
93107
/**
94108
* Initializes the component manager. It creates the services: load node, unload node
95109
* and list nodes.
@@ -100,12 +114,9 @@ class ComponentManager : public rclcpp::Node
100114
*/
101115
RCLCPP_COMPONENTS_PUBLIC
102116
ComponentManager(
103-
std::weak_ptr<rclcpp::Executor> executor =
104-
std::weak_ptr<rclcpp::executors::MultiThreadedExecutor>(),
117+
std::weak_ptr<rclcpp::Executor> executor,
105118
std::string node_name = "ComponentManager",
106-
const rclcpp::NodeOptions & node_options = rclcpp::NodeOptions()
107-
.start_parameter_services(false)
108-
.start_parameter_event_publisher(false));
119+
const rclcpp::NodeOptions & node_options = rclcpp::NodeOptions());
109120

110121
RCLCPP_COMPONENTS_PUBLIC
111122
virtual ~ComponentManager();

0 commit comments

Comments
 (0)