Skip to content

Commit ef118c5

Browse files
committed
Handling dedicated executor for nodes inside ComponentManager itself rather than ComponentManagerIsolated
Signed-off-by: Arman Hosseini <armanhosseini878787@gmail.com>
1 parent 6ff4d83 commit ef118c5

13 files changed

Lines changed: 274 additions & 11 deletions

File tree

build/.built_by

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
colcon

build/COLCON_IGNORE

Whitespace-only changes.

install/.colcon_install_layout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
isolated

install/COLCON_IGNORE

Whitespace-only changes.

log/COLCON_IGNORE

Whitespace-only changes.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
[0.266s] DEBUG:colcon:Command line arguments: ['/usr/bin/colcon', 'build', '--packages-select', 'rclcpp_components']
2+
[0.266s] DEBUG:colcon:Parsed command line arguments: Namespace(log_base=None, log_level=None, verb_name='build', build_base='build', install_base='install', merge_install=False, symlink_install=False, test_result_base=None, continue_on_error=False, executor='parallel', parallel_workers=4, event_handlers=None, ignore_user_meta=False, metas=['./colcon.meta'], base_paths=['.'], packages_ignore=None, packages_ignore_regex=None, paths=None, packages_up_to=None, packages_up_to_regex=None, packages_above=None, packages_above_and_dependencies=None, packages_above_depth=None, packages_select_by_dep=None, packages_skip_by_dep=None, packages_skip_up_to=None, packages_select_build_failed=False, packages_skip_build_finished=False, packages_select_test_failures=False, packages_skip_test_passed=False, packages_select=['rclcpp_components'], packages_skip=None, packages_select_regex=None, packages_skip_regex=None, packages_start=None, packages_end=None, allow_overriding=[], cmake_args=None, cmake_target=None, cmake_target_skip_unavailable=False, cmake_clean_cache=False, cmake_clean_first=False, cmake_force_configure=False, ament_cmake_args=None, catkin_cmake_args=None, catkin_skip_building_tests=False, mixin_files=None, mixin=None, verb_parser=<colcon_mixin.mixin.mixin_argument.MixinArgumentDecorator object at 0xffff92d2ce30>, verb_extension=<colcon_core.verb.build.BuildVerb object at 0xffff92e88950>, main=<bound method BuildVerb.main of <colcon_core.verb.build.BuildVerb object at 0xffff92e88950>>, mixin_verb=('build',))
3+
[0.344s] Level 1:colcon.colcon_core.package_discovery:discover_packages(colcon_meta) check parameters
4+
[0.344s] Level 1:colcon.colcon_core.package_discovery:discover_packages(recursive) check parameters
5+
[0.344s] Level 1:colcon.colcon_core.package_discovery:discover_packages(ignore) check parameters
6+
[0.344s] Level 1:colcon.colcon_core.package_discovery:discover_packages(path) check parameters
7+
[0.344s] Level 1:colcon.colcon_core.package_discovery:discover_packages(colcon_meta) discover
8+
[0.345s] Level 1:colcon.colcon_core.package_discovery:discover_packages(recursive) discover
9+
[0.345s] INFO:colcon.colcon_core.package_discovery:Crawling recursively for packages in '/home/arman/ros2_rolling/src/ros2/rclcpp'
10+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['ignore', 'ignore_ament_install']
11+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'ignore'
12+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'ignore_ament_install'
13+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['colcon_pkg']
14+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'colcon_pkg'
15+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['colcon_meta']
16+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'colcon_meta'
17+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['ros']
18+
[0.345s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'ros'
19+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['cmake', 'python']
20+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'cmake'
21+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'python'
22+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extensions ['python_setup_py']
23+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(.) by extension 'python_setup_py'
24+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(build) by extensions ['ignore', 'ignore_ament_install']
25+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(build) by extension 'ignore'
26+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(build) ignored
27+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(install) by extensions ['ignore', 'ignore_ament_install']
28+
[0.390s] Level 1:colcon.colcon_core.package_identification:_identify(install) by extension 'ignore'
29+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(install) ignored
30+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(log) by extensions ['ignore', 'ignore_ament_install']
31+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(log) by extension 'ignore'
32+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(log) ignored
33+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extensions ['ignore', 'ignore_ament_install']
34+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extension 'ignore'
35+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extension 'ignore_ament_install'
36+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extensions ['colcon_pkg']
37+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extension 'colcon_pkg'
38+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extensions ['colcon_meta']
39+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extension 'colcon_meta'
40+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extensions ['ros']
41+
[0.391s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp) by extension 'ros'
42+
[0.395s] DEBUG:colcon.colcon_core.package_identification:Package 'rclcpp' with type 'ros.ament_cmake' and name 'rclcpp'
43+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extensions ['ignore', 'ignore_ament_install']
44+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extension 'ignore'
45+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extension 'ignore_ament_install'
46+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extensions ['colcon_pkg']
47+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extension 'colcon_pkg'
48+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extensions ['colcon_meta']
49+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extension 'colcon_meta'
50+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extensions ['ros']
51+
[0.396s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_action) by extension 'ros'
52+
[0.397s] DEBUG:colcon.colcon_core.package_identification:Package 'rclcpp_action' with type 'ros.ament_cmake' and name 'rclcpp_action'
53+
[0.397s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extensions ['ignore', 'ignore_ament_install']
54+
[0.397s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extension 'ignore'
55+
[0.397s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extension 'ignore_ament_install'
56+
[0.398s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extensions ['colcon_pkg']
57+
[0.398s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extension 'colcon_pkg'
58+
[0.398s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extensions ['colcon_meta']
59+
[0.398s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extension 'colcon_meta'
60+
[0.398s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extensions ['ros']
61+
[0.398s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_components) by extension 'ros'
62+
[0.399s] DEBUG:colcon.colcon_core.package_identification:Package 'rclcpp_components' with type 'ros.ament_cmake' and name 'rclcpp_components'
63+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extensions ['ignore', 'ignore_ament_install']
64+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extension 'ignore'
65+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extension 'ignore_ament_install'
66+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extensions ['colcon_pkg']
67+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extension 'colcon_pkg'
68+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extensions ['colcon_meta']
69+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extension 'colcon_meta'
70+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extensions ['ros']
71+
[0.399s] Level 1:colcon.colcon_core.package_identification:_identify(rclcpp_lifecycle) by extension 'ros'
72+
[0.400s] DEBUG:colcon.colcon_core.package_identification:Package 'rclcpp_lifecycle' with type 'ros.ament_cmake' and name 'rclcpp_lifecycle'
73+
[0.400s] Level 1:colcon.colcon_core.package_discovery:discover_packages(recursive) using defaults
74+
[0.400s] Level 1:colcon.colcon_core.package_discovery:discover_packages(ignore) discover
75+
[0.400s] Level 1:colcon.colcon_core.package_discovery:discover_packages(ignore) using defaults
76+
[0.400s] Level 1:colcon.colcon_core.package_discovery:discover_packages(path) discover
77+
[0.400s] Level 1:colcon.colcon_core.package_discovery:discover_packages(path) using defaults
78+
[0.445s] INFO:colcon.colcon_core.package_selection:Skipping not selected package 'rclcpp' in 'rclcpp'
79+
[0.445s] INFO:colcon.colcon_core.package_selection:Skipping not selected package 'rclcpp_action' in 'rclcpp_action'
80+
[0.445s] INFO:colcon.colcon_core.package_selection:Skipping not selected package 'rclcpp_lifecycle' in 'rclcpp_lifecycle'
81+
[0.446s] Level 1:colcon.colcon_core.package_discovery:discover_packages(prefix_path) check parameters
82+
[0.446s] Level 1:colcon.colcon_core.package_discovery:discover_packages(prefix_path) discover
83+
[0.490s] DEBUG:colcon.colcon_installed_package_information.package_discovery:Found 360 installed packages in /home/arman/ros2_rolling/install
84+
[0.492s] Level 1:colcon.colcon_core.package_discovery:discover_packages(prefix_path) using defaults

log/latest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
latest_build

log/latest_build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build_2026-02-20_13-59-24

rclcpp_components/include/rclcpp_components/component_manager.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ class ComponentManagerException : public std::runtime_error
7878
/// ComponentManager handles the services to load, unload, and get the list of loaded components.
7979
class ComponentManager : public rclcpp::Node
8080
{
81+
struct DedicatedExecutorWrapper
82+
{
83+
std::shared_ptr<rclcpp::Executor> executor;
84+
std::thread thread;
85+
std::atomic_bool thread_initialized;
86+
87+
/// Constructor for the wrapper.
88+
/// This is necessary as atomic variables don't have copy/move operators
89+
/// implemented so this structure is not copyable/movable by default
90+
explicit DedicatedExecutorWrapper(std::shared_ptr<rclcpp::Executor> exec)
91+
: executor(exec), thread_initialized(false)
92+
{
93+
}
94+
};
95+
8196
public:
8297
using LoadNode = composition_interfaces::srv::LoadNode;
8398
using UnloadNode = composition_interfaces::srv::UnloadNode;
@@ -225,6 +240,16 @@ class ComponentManager : public rclcpp::Node
225240
rclcpp::Service<LoadNode>::SharedPtr loadNode_srv_;
226241
rclcpp::Service<UnloadNode>::SharedPtr unloadNode_srv_;
227242
rclcpp::Service<ListNodes>::SharedPtr listNodes_srv_;
243+
244+
private:
245+
/// Stops a spinning executor avoiding race conditions.
246+
/**
247+
* @param executor_wrapper executor to stop and its associated thread
248+
*/
249+
void
250+
cancel_executor(DedicatedExecutorWrapper & executor_wrapper);
251+
252+
std::unordered_map<uint64_t, DedicatedExecutorWrapper> dedicated_executor_wrappers_;
228253
};
229254

230255
} // namespace rclcpp_components

rclcpp_components/include/rclcpp_components/component_manager_isolated.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ namespace rclcpp_components
3737
{
3838
/// ComponentManagerIsolated uses dedicated single-threaded executors for each components.
3939
template<typename ExecutorT = rclcpp::executors::SingleThreadedExecutor>
40-
class ComponentManagerIsolated : public rclcpp_components::ComponentManager
40+
class
41+
[[deprecated(
42+
"ComponentManagerIsolated is deprecated. Use ComponentManager, and specify the type of executor "
43+
"you want to use for each node with the 'executor_type' parameter of "
44+
"load_node.")]]
45+
ComponentManagerIsolated : public rclcpp_components::ComponentManager
4146
{
4247
using rclcpp_components::ComponentManager::ComponentManager;
4348

0 commit comments

Comments
 (0)