From 78dc2e3ec22251dd61746544b359c1383fd21c78 Mon Sep 17 00:00:00 2001 From: TetsuKawa Date: Tue, 14 May 2024 15:06:38 +0900 Subject: [PATCH 1/3] feat: componentize-system_error_monitor Signed-off-by: TetsuKawa --- system/system_error_monitor/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/system/system_error_monitor/CMakeLists.txt b/system/system_error_monitor/CMakeLists.txt index 36edf5816f6d3..4d8b6a9f43ee3 100644 --- a/system/system_error_monitor/CMakeLists.txt +++ b/system/system_error_monitor/CMakeLists.txt @@ -4,11 +4,14 @@ project(system_error_monitor) find_package(autoware_cmake REQUIRED) autoware_package() -ament_auto_add_executable(${PROJECT_NAME} - src/system_error_monitor_node.cpp +ament_auto_add_library(system_error_monitor_component SHARED src/system_error_monitor_core.cpp ) +rclcpp_components_register_node(system_error_monitor_component + PLUGIN "AutowareErrorMonitor" + EXECUTABLE system_error_monitor) + ament_auto_package(INSTALL_TO_SHARE launch config From 0e5c2df10157b0058d7022911e996757dbc526fd Mon Sep 17 00:00:00 2001 From: TetsuKawa Date: Wed, 15 May 2024 00:18:37 +0900 Subject: [PATCH 2/3] modify: componentize-system_error_monitor Signed-off-by: TetsuKawa --- system/system_error_monitor/CMakeLists.txt | 6 ++--- .../system_error_monitor_core.hpp | 2 +- .../system_error_monitor_node.launch.xml | 2 +- system/system_error_monitor/package.xml | 1 + .../src/system_error_monitor_core.cpp | 7 +++-- .../src/system_error_monitor_node.cpp | 27 ------------------- 6 files changed, 11 insertions(+), 34 deletions(-) delete mode 100644 system/system_error_monitor/src/system_error_monitor_node.cpp diff --git a/system/system_error_monitor/CMakeLists.txt b/system/system_error_monitor/CMakeLists.txt index 4d8b6a9f43ee3..91e9e20146327 100644 --- a/system/system_error_monitor/CMakeLists.txt +++ b/system/system_error_monitor/CMakeLists.txt @@ -4,13 +4,13 @@ project(system_error_monitor) find_package(autoware_cmake REQUIRED) autoware_package() -ament_auto_add_library(system_error_monitor_component SHARED +ament_auto_add_library(${PROJECT_NAME} SHARED src/system_error_monitor_core.cpp ) -rclcpp_components_register_node(system_error_monitor_component +rclcpp_components_register_node(${PROJECT_NAME} PLUGIN "AutowareErrorMonitor" - EXECUTABLE system_error_monitor) + EXECUTABLE ${PROJECT_NAME}_node) ament_auto_package(INSTALL_TO_SHARE launch diff --git a/system/system_error_monitor/include/system_error_monitor/system_error_monitor_core.hpp b/system/system_error_monitor/include/system_error_monitor/system_error_monitor_core.hpp index 4dbf8813805e3..892e5a0f70c43 100644 --- a/system/system_error_monitor/include/system_error_monitor/system_error_monitor_core.hpp +++ b/system/system_error_monitor/include/system_error_monitor/system_error_monitor_core.hpp @@ -64,7 +64,7 @@ struct KeyName class AutowareErrorMonitor : public rclcpp::Node { public: - AutowareErrorMonitor(); + AutowareErrorMonitor(const rclcpp::NodeOptions & options); private: // Parameter diff --git a/system/system_error_monitor/launch/system_error_monitor_node.launch.xml b/system/system_error_monitor/launch/system_error_monitor_node.launch.xml index 6741b4f22ce48..f5ed927c7d6ca 100644 --- a/system/system_error_monitor/launch/system_error_monitor_node.launch.xml +++ b/system/system_error_monitor/launch/system_error_monitor_node.launch.xml @@ -11,7 +11,7 @@ - + diff --git a/system/system_error_monitor/package.xml b/system/system_error_monitor/package.xml index c6560209854d3..ed50eda95611a 100644 --- a/system/system_error_monitor/package.xml +++ b/system/system_error_monitor/package.xml @@ -15,6 +15,7 @@ diagnostic_msgs fmt rclcpp + rclcpp_components std_srvs tier4_autoware_utils tier4_control_msgs diff --git a/system/system_error_monitor/src/system_error_monitor_core.cpp b/system/system_error_monitor/src/system_error_monitor_core.cpp index fb0a607b9825a..e4ca33204f53e 100644 --- a/system/system_error_monitor/src/system_error_monitor_core.cpp +++ b/system/system_error_monitor/src/system_error_monitor_core.cpp @@ -202,10 +202,10 @@ int isInNoFaultCondition( } } // namespace -AutowareErrorMonitor::AutowareErrorMonitor() +AutowareErrorMonitor::AutowareErrorMonitor(const rclcpp::NodeOptions & options) : Node( "system_error_monitor", - rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true)), + rclcpp::NodeOptions(options).automatically_declare_parameters_from_overrides(true)), diag_array_stamp_(0, 0, this->get_clock()->get_clock_type()), autoware_state_stamp_(0, 0, this->get_clock()->get_clock_type()), current_gate_mode_stamp_(0, 0, this->get_clock()->get_clock_type()), @@ -720,3 +720,6 @@ void AutowareErrorMonitor::loggingErrors( logger_name, get_clock(), 5000, "[Single Point Fault]: " + hazard_diag.message); } } + +#include +RCLCPP_COMPONENTS_REGISTER_NODE(AutowareErrorMonitor) diff --git a/system/system_error_monitor/src/system_error_monitor_node.cpp b/system/system_error_monitor/src/system_error_monitor_node.cpp deleted file mode 100644 index f389497b93a43..0000000000000 --- a/system/system_error_monitor/src/system_error_monitor_node.cpp +++ /dev/null @@ -1,27 +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 "system_error_monitor/system_error_monitor_core.hpp" - -#include - -int main(int argc, char ** argv) -{ - rclcpp::init(argc, argv); - auto node = std::make_shared(); - rclcpp::spin(node); - rclcpp::shutdown(); - - return 0; -} From 0c614294534bfa210e6e1bbee5a6176494c2a0d0 Mon Sep 17 00:00:00 2001 From: TetsuKawa Date: Wed, 15 May 2024 13:21:38 +0900 Subject: [PATCH 3/3] feat: add explicit Signed-off-by: TetsuKawa --- .../include/system_error_monitor/system_error_monitor_core.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/system_error_monitor/include/system_error_monitor/system_error_monitor_core.hpp b/system/system_error_monitor/include/system_error_monitor/system_error_monitor_core.hpp index 892e5a0f70c43..8829bcc1edde2 100644 --- a/system/system_error_monitor/include/system_error_monitor/system_error_monitor_core.hpp +++ b/system/system_error_monitor/include/system_error_monitor/system_error_monitor_core.hpp @@ -64,7 +64,7 @@ struct KeyName class AutowareErrorMonitor : public rclcpp::Node { public: - AutowareErrorMonitor(const rclcpp::NodeOptions & options); + explicit AutowareErrorMonitor(const rclcpp::NodeOptions & options); private: // Parameter