diff --git a/system/emergency_handler/CMakeLists.txt b/system/emergency_handler/CMakeLists.txt index b7895b07f6e4c..0475cdbe57dd8 100644 --- a/system/emergency_handler/CMakeLists.txt +++ b/system/emergency_handler/CMakeLists.txt @@ -4,11 +4,16 @@ project(emergency_handler) find_package(autoware_cmake REQUIRED) autoware_package() -ament_auto_add_executable(emergency_handler - src/emergency_handler/emergency_handler_node.cpp +ament_auto_add_library(${PROJECT_NAME} SHARED src/emergency_handler/emergency_handler_core.cpp ) +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "EmergencyHandler" + EXECUTABLE ${PROJECT_NAME}_node + EXECUTOR MultiThreadedExecutor +) + ament_auto_package(INSTALL_TO_SHARE launch config diff --git a/system/emergency_handler/include/emergency_handler/emergency_handler_core.hpp b/system/emergency_handler/include/emergency_handler/emergency_handler_core.hpp index 5c76d96e573ab..a78b35be26daf 100644 --- a/system/emergency_handler/include/emergency_handler/emergency_handler_core.hpp +++ b/system/emergency_handler/include/emergency_handler/emergency_handler_core.hpp @@ -53,7 +53,7 @@ struct Param class EmergencyHandler : public rclcpp::Node { public: - EmergencyHandler(); + explicit EmergencyHandler(const rclcpp::NodeOptions & options); private: // Subscribers diff --git a/system/emergency_handler/launch/emergency_handler.launch.xml b/system/emergency_handler/launch/emergency_handler.launch.xml index 308eaf90dbb69..203c13bd94e0a 100644 --- a/system/emergency_handler/launch/emergency_handler.launch.xml +++ b/system/emergency_handler/launch/emergency_handler.launch.xml @@ -16,7 +16,7 @@ - + diff --git a/system/emergency_handler/package.xml b/system/emergency_handler/package.xml index 10282297017b1..97344f9b8c594 100644 --- a/system/emergency_handler/package.xml +++ b/system/emergency_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/emergency_handler/src/emergency_handler/emergency_handler_core.cpp b/system/emergency_handler/src/emergency_handler/emergency_handler_core.cpp index db3ad40249bfb..2770a14691d95 100644 --- a/system/emergency_handler/src/emergency_handler/emergency_handler_core.cpp +++ b/system/emergency_handler/src/emergency_handler/emergency_handler_core.cpp @@ -18,7 +18,8 @@ #include #include -EmergencyHandler::EmergencyHandler() : Node("emergency_handler") +EmergencyHandler::EmergencyHandler(const rclcpp::NodeOptions & options) +: Node("emergency_handler", options) { // Parameter param_.update_rate = declare_parameter("update_rate"); @@ -459,3 +460,6 @@ bool EmergencyHandler::isStopped() return false; } + +#include +RCLCPP_COMPONENTS_REGISTER_NODE(EmergencyHandler) diff --git a/system/emergency_handler/src/emergency_handler/emergency_handler_node.cpp b/system/emergency_handler/src/emergency_handler/emergency_handler_node.cpp deleted file mode 100644 index 5b60117cc3ff4..0000000000000 --- a/system/emergency_handler/src/emergency_handler/emergency_handler_node.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2020 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 "emergency_handler/emergency_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; -}