Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions rclcpp_components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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;$<TARGET_FILE:test_component>\n")
set(components "${components}test_rclcpp_components::TestComponentBar;$<TARGET_FILE:test_component>\n")
set(components "${components}test_rclcpp_components::TestComponentNoNode;$<TARGET_FILE:test_component>\n")
Expand Down
3 changes: 3 additions & 0 deletions rclcpp_components/cmake/rclcpp_components_register_node.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion rclcpp_components/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
<build_depend>class_loader</build_depend>
<build_depend>composition_interfaces</build_depend>
<build_depend>rclcpp</build_depend>
<build_depend>libgoogle-glog-dev</build_depend>
<build_depend>rcpputils</build_depend>

<build_export_depend>libgoogle-glog-dev</build_export_depend>

<exec_depend>ament_index_cpp</exec_depend>
<exec_depend>class_loader</exec_depend>
<exec_depend>composition_interfaces</exec_depend>
<exec_depend>libgoogle-glog-dev</exec_depend>
<exec_depend>rclcpp</exec_depend>

<test_depend>ament_cmake_google_benchmark</test_depend>
Expand All @@ -38,4 +42,3 @@
<build_type>ament_cmake</build_type>
</export>
</package>

6 changes: 6 additions & 0 deletions rclcpp_components/src/component_container.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,14 +13,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.


#include <memory>
#include <glog/logging.h>

#include "rclcpp/rclcpp.hpp"

#include "rclcpp_components/component_manager.hpp"

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<rclcpp::executors::SingleThreadedExecutor>();
Expand Down
5 changes: 5 additions & 0 deletions rclcpp_components/src/component_container_isolated.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -15,13 +16,17 @@
#include <memory>
#include <vector>
#include <string>
#include <glog/logging.h>

#include "rclcpp/rclcpp.hpp"
#include "rclcpp/utilities.hpp"
#include "rclcpp_components/component_manager_isolated.hpp"

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
Expand Down
5 changes: 5 additions & 0 deletions rclcpp_components/src/component_container_mt.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -13,13 +14,17 @@
// limitations under the License.

#include <memory>
#include <glog/logging.h>

#include "rclcpp/rclcpp.hpp"

#include "rclcpp_components/component_manager.hpp"

int main(int argc, char * argv[])
{
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();

/// Component container with a multi-threaded executor.
rclcpp::init(argc, argv);

Expand Down
5 changes: 5 additions & 0 deletions rclcpp_components/src/node_main.cpp.in
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,6 +17,7 @@
#include <memory>
#include <string>
#include <vector>
#include <glog/logging.h>

#include "class_loader/class_loader.hpp"
#include "rclcpp/rclcpp.hpp"
Expand All @@ -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;
Expand Down