diff --git a/rclcpp_components/CMakeLists.txt b/rclcpp_components/CMakeLists.txt index 7d4135051c..231a92ab85 100644 --- a/rclcpp_components/CMakeLists.txt +++ b/rclcpp_components/CMakeLists.txt @@ -18,6 +18,7 @@ find_package(ament_cmake_ros REQUIRED) find_package(ament_index_cpp REQUIRED) find_package(class_loader REQUIRED) find_package(composition_interfaces REQUIRED) +find_package(glog REQUIRED) find_package(rclcpp REQUIRED) find_package(rcpputils REQUIRED) @@ -54,7 +55,7 @@ add_executable( component_container src/component_container.cpp ) -target_link_libraries(component_container component_manager rclcpp::rclcpp) +target_link_libraries(component_container component_manager rclcpp::rclcpp glog::glog) set(node_main_template_install_dir "share/${PROJECT_NAME}") install(FILES @@ -65,13 +66,13 @@ add_executable( component_container_mt src/component_container_mt.cpp ) -target_link_libraries(component_container_mt component_manager rclcpp::rclcpp) +target_link_libraries(component_container_mt component_manager rclcpp::rclcpp glog::glog) add_executable( component_container_isolated src/component_container_isolated.cpp ) -target_link_libraries(component_container_isolated component_manager rclcpp::rclcpp) +target_link_libraries(component_container_isolated component_manager rclcpp::rclcpp glog::glog) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_link_libraries(component_container "stdc++fs") @@ -90,7 +91,8 @@ if(BUILD_TESTING) set(components "") add_library(test_component SHARED test/components/test_component.cpp) target_link_libraries(test_component PRIVATE component) - #rclcpp_components_register_nodes(test_component "test_rclcpp_components::TestComponent") + + # rclcpp_components_register_nodes(test_component "test_rclcpp_components::TestComponent") set(components "${components}test_rclcpp_components::TestComponentFoo;$\n") set(components "${components}test_rclcpp_components::TestComponentBar;$\n") set(components "${components}test_rclcpp_components::TestComponentNoNode;$\n") diff --git a/rclcpp_components/cmake/rclcpp_components_register_node.cmake b/rclcpp_components/cmake/rclcpp_components_register_node.cmake index 7ddef9b9b6..d6b2fe976e 100644 --- a/rclcpp_components/cmake/rclcpp_components_register_node.cmake +++ b/rclcpp_components/cmake/rclcpp_components_register_node.cmake @@ -93,12 +93,15 @@ macro(rclcpp_components_register_node target) endif() endif() + find_package(glog QUIET REQUIRED) + configure_file(${rclcpp_components_NODE_TEMPLATE} ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_configured_${node}.cpp.in) file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_${node}.cpp INPUT ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_configured_${node}.cpp.in) add_executable(${node} ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_${node}.cpp) target_link_libraries(${node} + glog::glog class_loader::class_loader rclcpp::rclcpp rclcpp_components::component diff --git a/rclcpp_components/package.xml b/rclcpp_components/package.xml index e859c664a5..2a28379aeb 100644 --- a/rclcpp_components/package.xml +++ b/rclcpp_components/package.xml @@ -20,11 +20,15 @@ class_loader composition_interfaces rclcpp + libgoogle-glog-dev rcpputils + libgoogle-glog-dev + ament_index_cpp class_loader composition_interfaces + libgoogle-glog-dev rclcpp ament_cmake_google_benchmark @@ -38,4 +42,3 @@ ament_cmake - diff --git a/rclcpp_components/src/component_container.cpp b/rclcpp_components/src/component_container.cpp index 64083912de..2e3fa382e8 100644 --- a/rclcpp_components/src/component_container.cpp +++ b/rclcpp_components/src/component_container.cpp @@ -1,4 +1,5 @@ // Copyright 2019 Open Source Robotics Foundation, Inc. +// Copyright 2024 TIER IV, Inc. (Edit for glog) // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. + #include +#include #include "rclcpp/rclcpp.hpp" @@ -20,6 +23,9 @@ int main(int argc, char * argv[]) { + google::InitGoogleLogging(argv[0]); + google::InstallFailureSignalHandler(); + /// Component container with a single-threaded executor. rclcpp::init(argc, argv); auto exec = std::make_shared(); diff --git a/rclcpp_components/src/component_container_isolated.cpp b/rclcpp_components/src/component_container_isolated.cpp index 96ba8b1a03..4bc85592e1 100644 --- a/rclcpp_components/src/component_container_isolated.cpp +++ b/rclcpp_components/src/component_container_isolated.cpp @@ -1,4 +1,5 @@ // Copyright 2021 Open Source Robotics Foundation, Inc. +// Copyright 2024 TIER IV, Inc. (Edit for glog) // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +16,7 @@ #include #include #include +#include #include "rclcpp/rclcpp.hpp" #include "rclcpp/utilities.hpp" @@ -22,6 +24,9 @@ int main(int argc, char * argv[]) { + google::InitGoogleLogging(argv[0]); + google::InstallFailureSignalHandler(); + /// Component container with dedicated single-threaded executors for each components. rclcpp::init(argc, argv); // parse arguments diff --git a/rclcpp_components/src/component_container_mt.cpp b/rclcpp_components/src/component_container_mt.cpp index 9dcbade712..cd8934bea1 100644 --- a/rclcpp_components/src/component_container_mt.cpp +++ b/rclcpp_components/src/component_container_mt.cpp @@ -1,4 +1,5 @@ // Copyright 2019 Open Source Robotics Foundation, Inc. +// Copyright 2024 TIER IV, Inc. (Edit for glog) // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,6 +14,7 @@ // limitations under the License. #include +#include #include "rclcpp/rclcpp.hpp" @@ -20,6 +22,9 @@ int main(int argc, char * argv[]) { + google::InitGoogleLogging(argv[0]); + google::InstallFailureSignalHandler(); + /// Component container with a multi-threaded executor. rclcpp::init(argc, argv); diff --git a/rclcpp_components/src/node_main.cpp.in b/rclcpp_components/src/node_main.cpp.in index 7d621aac9f..ef899dd0f8 100644 --- a/rclcpp_components/src/node_main.cpp.in +++ b/rclcpp_components/src/node_main.cpp.in @@ -1,4 +1,5 @@ // Copyright 2019 Open Source Robotics Foundation, Inc. +// Copyright 2024 TIER IV, Inc. (Edit for glog) // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ #include #include #include +#include #include "class_loader/class_loader.hpp" #include "rclcpp/rclcpp.hpp" @@ -29,6 +31,9 @@ using namespace rclcpp::experimental::executors; int main(int argc, char * argv[]) { + google::InitGoogleLogging(argv[0]); + google::InstallFailureSignalHandler(); + auto args = rclcpp::init_and_remove_ros_arguments(argc, argv); rclcpp::Logger logger = rclcpp::get_logger(NODE_MAIN_LOGGER_NAME); @executor@ exec;