From f92ee8c8309eef39166106ca0dd7a6ef16393f56 Mon Sep 17 00:00:00 2001 From: TetsuKawa <70682030+TetsuKawa@users.noreply.github.com> Date: Fri, 17 May 2024 10:48:47 +0900 Subject: [PATCH] feat: componentize-mrm-handler (#7018) Signed-off-by: TetsuKawa --- system/mrm_handler/CMakeLists.txt | 9 ++++-- .../include/mrm_handler/mrm_handler_core.hpp | 2 +- .../mrm_handler/launch/mrm_handler.launch.xml | 2 +- system/mrm_handler/package.xml | 1 + .../src/mrm_handler/mrm_handler_core.cpp | 5 ++- .../src/mrm_handler/mrm_handler_node.cpp | 32 ------------------- 6 files changed, 14 insertions(+), 37 deletions(-) delete mode 100644 system/mrm_handler/src/mrm_handler/mrm_handler_node.cpp diff --git a/system/mrm_handler/CMakeLists.txt b/system/mrm_handler/CMakeLists.txt index 7c2174f03a6f3..93e03e7f20ead 100644 --- a/system/mrm_handler/CMakeLists.txt +++ b/system/mrm_handler/CMakeLists.txt @@ -4,11 +4,16 @@ project(mrm_handler) find_package(autoware_cmake REQUIRED) autoware_package() -ament_auto_add_executable(mrm_handler - src/mrm_handler/mrm_handler_node.cpp +ament_auto_add_library(${PROJECT_NAME} SHARED src/mrm_handler/mrm_handler_core.cpp ) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "MrmHandler" + EXECUTABLE ${PROJECT_NAME}_node + EXECUTOR MultiThreadedExecutor +) + ament_auto_package(INSTALL_TO_SHARE launch config diff --git a/system/mrm_handler/include/mrm_handler/mrm_handler_core.hpp b/system/mrm_handler/include/mrm_handler/mrm_handler_core.hpp index 1dd0f6b081337..c7aaca96aae49 100644 --- a/system/mrm_handler/include/mrm_handler/mrm_handler_core.hpp +++ b/system/mrm_handler/include/mrm_handler/mrm_handler_core.hpp @@ -60,7 +60,7 @@ struct Param class MrmHandler : public rclcpp::Node { public: - MrmHandler(); + explicit MrmHandler(const rclcpp::NodeOptions & options); private: // type diff --git a/system/mrm_handler/launch/mrm_handler.launch.xml b/system/mrm_handler/launch/mrm_handler.launch.xml index 562134f5301e2..7e761157956df 100644 --- a/system/mrm_handler/launch/mrm_handler.launch.xml +++ b/system/mrm_handler/launch/mrm_handler.launch.xml @@ -18,7 +18,7 @@ - + diff --git a/system/mrm_handler/package.xml b/system/mrm_handler/package.xml index e62091f2984e6..c15bc98a6c190 100644 --- a/system/mrm_handler/package.xml +++ b/system/mrm_handler/package.xml @@ -18,6 +18,7 @@ autoware_auto_vehicle_msgs nav_msgs rclcpp + rclcpp_components std_msgs std_srvs tier4_system_msgs diff --git a/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp b/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp index e8e692f755e2d..5e709946c2f46 100644 --- a/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp +++ b/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp @@ -18,7 +18,7 @@ #include #include -MrmHandler::MrmHandler() : Node("mrm_handler") +MrmHandler::MrmHandler(const rclcpp::NodeOptions & options) : Node("mrm_handler", options) { // Parameter param_.update_rate = declare_parameter("update_rate", 10); @@ -597,3 +597,6 @@ bool MrmHandler::isArrivedAtGoal() return operation_mode_state_->mode == OperationModeState::STOP; } + +#include +RCLCPP_COMPONENTS_REGISTER_NODE(MrmHandler) diff --git a/system/mrm_handler/src/mrm_handler/mrm_handler_node.cpp b/system/mrm_handler/src/mrm_handler/mrm_handler_node.cpp deleted file mode 100644 index 4aaab3296f64b..0000000000000 --- a/system/mrm_handler/src/mrm_handler/mrm_handler_node.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2024 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "mrm_handler/mrm_handler_core.hpp" - -#include - -#include - -int main(int argc, char ** argv) -{ - rclcpp::init(argc, argv); - rclcpp::executors::MultiThreadedExecutor executor; - auto node = std::make_shared(); - executor.add_node(node); - executor.spin(); - executor.remove_node(node); - rclcpp::shutdown(); - - return 0; -}