Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions rclcpp_components/src/component_container_mt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ int main(int argc, char * argv[])
/// Component container with a multi-threaded executor.
rclcpp::init(argc, argv);

auto exec = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
auto node = std::make_shared<rclcpp_components::ComponentManager>();
rclcpp::executors::MultiThreadedExecutor::SharedPtr exec = nullptr;
const auto node = std::make_shared<rclcpp_components::ComponentManager>();
if (node->has_parameter("thread_num")) {
const auto thread_num = node->get_parameter("thread_num").as_int();
exec = std::make_shared<rclcpp::executors::MultiThreadedExecutor>(
rclcpp::ExecutorOptions{}, thread_num);
node->set_executor(exec);
} else {
node->set_executor(exec);
exec = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
}
node->set_executor(exec);
exec->add_node(node);
exec->spin();
}