From d6ec2f5da91e53fe8c617259b74f68ab2dde389d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Sat, 7 Dec 2024 18:18:09 +0300 Subject: [PATCH 01/11] feat: add autoware_node and autoware_test node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- common/autoware_node/CMakeLists.txt | 26 ++++++++ common/autoware_node/README.md | 23 +++++++ .../include/autoware/node/node.hpp | 36 ++++++++++ .../autoware/node/visibility_control.hpp | 26 ++++++++ common/autoware_node/package.xml | 22 +++++++ common/autoware_node/src/node.cpp | 28 ++++++++ .../test/test_an_init_shutdown.cpp | 65 +++++++++++++++++++ common/autoware_test_node/CMakeLists.txt | 15 +++++ common/autoware_test_node/README.md | 3 + .../launch/autoware_test_node.launch.xml | 4 ++ common/autoware_test_node/package.xml | 21 ++++++ .../src/include/test_node.hpp | 32 +++++++++ common/autoware_test_node/src/test_node.cpp | 30 +++++++++ 13 files changed, 331 insertions(+) create mode 100644 common/autoware_node/CMakeLists.txt create mode 100644 common/autoware_node/README.md create mode 100644 common/autoware_node/include/autoware/node/node.hpp create mode 100644 common/autoware_node/include/autoware/node/visibility_control.hpp create mode 100644 common/autoware_node/package.xml create mode 100644 common/autoware_node/src/node.cpp create mode 100644 common/autoware_node/test/test_an_init_shutdown.cpp create mode 100644 common/autoware_test_node/CMakeLists.txt create mode 100644 common/autoware_test_node/README.md create mode 100644 common/autoware_test_node/launch/autoware_test_node.launch.xml create mode 100644 common/autoware_test_node/package.xml create mode 100644 common/autoware_test_node/src/include/test_node.hpp create mode 100644 common/autoware_test_node/src/test_node.cpp diff --git a/common/autoware_node/CMakeLists.txt b/common/autoware_node/CMakeLists.txt new file mode 100644 index 0000000000..4ef5fbeae7 --- /dev/null +++ b/common/autoware_node/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.8) +project(autoware_node) + +find_package(autoware_cmake REQUIRED) +autoware_package() + +ament_auto_add_library(${PROJECT_NAME} src/node.cpp) + +if(BUILD_TESTING) + file(GLOB_RECURSE TEST_FILES test/*.cpp) + + foreach(TEST_FILE ${TEST_FILES}) + # Get the test name without directory and extension + get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE) + + # Add each test separately + ament_add_ros_isolated_gtest(${TEST_NAME} ${TEST_FILE} TIMEOUT 10) + target_include_directories(${TEST_NAME} PRIVATE src/include) + target_link_libraries(${TEST_NAME} ${PROJECT_NAME}) + ament_target_dependencies(${TEST_NAME} + rclcpp + rclcpp_lifecycle) + endforeach() +endif() + +ament_auto_package(INSTALL_TO_SHARE) diff --git a/common/autoware_node/README.md b/common/autoware_node/README.md new file mode 100644 index 0000000000..be86ecff9e --- /dev/null +++ b/common/autoware_node/README.md @@ -0,0 +1,23 @@ +# Autoware Node + +## Abbreviations + +- **AN:** Autoware Node + +## Overview + +AN is an `autoware.core` package designed to provide a base class for all future nodes in the +system. +It also inherits all lifecycle control capabilities of the base +class [LifecycleNode](https://docs.ros2.org/latest/api/rclcpp_lifecycle/classrclcpp__lifecycle_1_1LifecycleNode.html) + +## Usage + +Check the [autoware_test_node](../autoware_test_node/README.md) package for an example of how to use `autoware::Node`. + +## Design + +### Lifecycle + +AN inherits from ROS 2 [rclcpp_lifecycle::LifecycleNode](https://design.ros2.org/articles/node_lifecycle.html) and has +all the basic functions of it. diff --git a/common/autoware_node/include/autoware/node/node.hpp b/common/autoware_node/include/autoware/node/node.hpp new file mode 100644 index 0000000000..4e978bc337 --- /dev/null +++ b/common/autoware_node/include/autoware/node/node.hpp @@ -0,0 +1,36 @@ +// Copyright 2024 The Autoware Contributors +// +// 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. + +#ifndef AUTOWARE__NODE__NODE_HPP_ +#define AUTOWARE__NODE__NODE_HPP_ + +#include "autoware/node/visibility_control.hpp" + +#include + +#include + +namespace autoware::node +{ +class Node : public rclcpp_lifecycle::LifecycleNode +{ +public: + AUTOWARE_NODE_PUBLIC + explicit Node( + const std::string & node_name, const std::string & ns = "", + const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); +}; +} // namespace autoware::node + +#endif // AUTOWARE__NODE__NODE_HPP_ diff --git a/common/autoware_node/include/autoware/node/visibility_control.hpp b/common/autoware_node/include/autoware/node/visibility_control.hpp new file mode 100644 index 0000000000..b7a6bbd07c --- /dev/null +++ b/common/autoware_node/include/autoware/node/visibility_control.hpp @@ -0,0 +1,26 @@ +// Copyright 2024 The Autoware Contributors +// +// 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. + +#ifndef AUTOWARE__NODE__VISIBILITY_CONTROL_HPP_ +#define AUTOWARE__NODE__VISIBILITY_CONTROL_HPP_ + +#include "rcutils/visibility_control_macros.h" +#ifdef AUTOWARE_NODE_BUILDING_DLL +#define AUTOWARE_NODE_PUBLIC RCUTILS_EXPORT +#else +#define AUTOWARE_NODE_PUBLIC RCUTILS_IMPORT +#endif // !AUTOWARE_NODE_BUILDING_DLL +#define AUTOWARE_NODE_LOCAL RCUTILS_LOCAL + +#endif // AUTOWARE__NODE__VISIBILITY_CONTROL_HPP_ diff --git a/common/autoware_node/package.xml b/common/autoware_node/package.xml new file mode 100644 index 0000000000..dbbf7c15d1 --- /dev/null +++ b/common/autoware_node/package.xml @@ -0,0 +1,22 @@ + + + + autoware_node + 0.0.0 + Autoware Node is an Autoware.Core package designed to provide a base class for all nodes in the system. + + M. Fatih Cırıt + Apache-2.0 + + ament_cmake_auto + autoware_cmake + + rclcpp_lifecycle + + ament_cmake_ros + autoware_lint_common + + + ament_cmake + + diff --git a/common/autoware_node/src/node.cpp b/common/autoware_node/src/node.cpp new file mode 100644 index 0000000000..8bd3b39d50 --- /dev/null +++ b/common/autoware_node/src/node.cpp @@ -0,0 +1,28 @@ +// Copyright 2024 The Autoware Contributors +// +// 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 "autoware/node/node.hpp" + +#include + +namespace autoware::node +{ +Node::Node( + const std::string & node_name, const std::string & ns, const rclcpp::NodeOptions & options) +: LifecycleNode(node_name, ns, options) +{ + RCLCPP_DEBUG( + get_logger(), "Node %s constructor was called.", get_node_base_interface()->get_fully_qualified_name()); +} +} // namespace autoware::node diff --git a/common/autoware_node/test/test_an_init_shutdown.cpp b/common/autoware_node/test/test_an_init_shutdown.cpp new file mode 100644 index 0000000000..a10438ef2a --- /dev/null +++ b/common/autoware_node/test/test_an_init_shutdown.cpp @@ -0,0 +1,65 @@ +// Copyright 2024 The Autoware Contributors +// +// 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 +#include + +#include + +#include + +class AutowareNodeInitShutdown : public ::testing::Test +{ +public: + void SetUp() override + { + rclcpp::init(0, nullptr); + } + + void TearDown() override { rclcpp::shutdown(); } + + rclcpp::NodeOptions node_options_an_; +}; + +TEST_F(AutowareNodeInitShutdown, NodeInitShutdown) +{ + std::shared_ptr executor; + executor = std::make_shared(); + + autoware::node::Node::SharedPtr autoware_node = + std::make_shared("test_node", "test_ns", node_options_an_); + + executor->add_node(autoware_node->get_node_base_interface()); + + std::thread thread_spin = std::thread([&executor]() { executor->spin(); }); + + ASSERT_EQ( + autoware_node->get_current_state().id(), + lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED); + + auto state = autoware_node->shutdown(); + + ASSERT_EQ(state.id(), lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED); + + // wait until executor is spinning + while (!executor->is_spinning()) { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + executor->cancel(); // make sure cancel is called after spin + if (thread_spin.joinable()) { + thread_spin.join(); + } +} + +// TEST_F(AutowareNodeTest, Sen) diff --git a/common/autoware_test_node/CMakeLists.txt b/common/autoware_test_node/CMakeLists.txt new file mode 100644 index 0000000000..64db7b3b9b --- /dev/null +++ b/common/autoware_test_node/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(autoware_test_node) + +find_package(autoware_cmake REQUIRED) +autoware_package() + +ament_auto_add_library(${PROJECT_NAME} SHARED + src/test_node.cpp) + +rclcpp_components_register_node(${PROJECT_NAME} + PLUGIN "autoware::test_node::TestNode" + EXECUTABLE ${PROJECT_NAME}_node) + +ament_auto_package(INSTALL_TO_SHARE + launch) diff --git a/common/autoware_test_node/README.md b/common/autoware_test_node/README.md new file mode 100644 index 0000000000..04d7edf933 --- /dev/null +++ b/common/autoware_test_node/README.md @@ -0,0 +1,3 @@ +# autoware_test_node + +This package contains a simple example of how to use `autoware::Node`. diff --git a/common/autoware_test_node/launch/autoware_test_node.launch.xml b/common/autoware_test_node/launch/autoware_test_node.launch.xml new file mode 100644 index 0000000000..a6cadc811f --- /dev/null +++ b/common/autoware_test_node/launch/autoware_test_node.launch.xml @@ -0,0 +1,4 @@ + + + + diff --git a/common/autoware_test_node/package.xml b/common/autoware_test_node/package.xml new file mode 100644 index 0000000000..50d8aedacf --- /dev/null +++ b/common/autoware_test_node/package.xml @@ -0,0 +1,21 @@ + + + + autoware_test_node + 0.0.0 + Test package for Autoware Node. + M. Fatih Cırıt + Apache-2.0 + + ament_cmake_auto + autoware_cmake + + autoware_node + rclcpp + rclcpp_components + rclcpp_lifecycle + + + ament_cmake + + diff --git a/common/autoware_test_node/src/include/test_node.hpp b/common/autoware_test_node/src/include/test_node.hpp new file mode 100644 index 0000000000..027171d2d8 --- /dev/null +++ b/common/autoware_test_node/src/include/test_node.hpp @@ -0,0 +1,32 @@ +// Copyright 2024 The Autoware Contributors +// +// 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. + +#ifndef TEST_NODE_HPP_ +#define TEST_NODE_HPP_ + +#include +#include + +namespace autoware::test_node +{ + +class TestNode : public autoware::node::Node +{ +public: + explicit TestNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); +}; + +} // namespace autoware::test_node + +#endif // TEST_NODE_HPP_ diff --git a/common/autoware_test_node/src/test_node.cpp b/common/autoware_test_node/src/test_node.cpp new file mode 100644 index 0000000000..c28a884102 --- /dev/null +++ b/common/autoware_test_node/src/test_node.cpp @@ -0,0 +1,30 @@ +// Copyright 2024 The Autoware Contributors +// +// 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 "include/test_node.hpp" + +#include + +namespace autoware::test_node +{ +TestNode::TestNode(const rclcpp::NodeOptions & options) +: autoware::node::Node("test_node", "", options) +{ + RCLCPP_DEBUG( + get_logger(), "TestNode %s constructor was called.", get_node_base_interface()->get_fully_qualified_name()); +} +} // namespace autoware::test_node + +#include "rclcpp_components/register_node_macro.hpp" +RCLCPP_COMPONENTS_REGISTER_NODE(autoware::test_node::TestNode) From 699e6ef828830739ae74a3cab4d7b55718631b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Sat, 7 Dec 2024 18:25:07 +0300 Subject: [PATCH 02/11] add readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- common/autoware_test_node/README.md | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/common/autoware_test_node/README.md b/common/autoware_test_node/README.md index 04d7edf933..a67dbd1e2b 100644 --- a/common/autoware_test_node/README.md +++ b/common/autoware_test_node/README.md @@ -1,3 +1,44 @@ # autoware_test_node This package contains a simple example of how to use `autoware::Node`. + +## Usage + +```bash +ros2 launch autoware_test_node autoware_test_node.launch.xml +``` + +### Lifecycle control + +Output a list of nodes with lifecycle: + +```console +$ ros2 lifecycle nodes +/test_ns1/test_node1 +``` + +Get the current state of a node: + +```console +$ ros2 lifecycle get /test_ns1/test_node1 +unconfigured [1] +``` + +List the available transitions for the node: + +```console +$ ros2 lifecycle list /test_ns1/test_node1 +- configure [1] + Start: unconfigured + Goal: configuring +- shutdown [5] + Start: unconfigured + Goal: shuttingdown +``` + +Shutdown the node: + +```console +$ ros2 lifecycle set /test_ns1/test_node1 shutdown +Transitioning successful +``` \ No newline at end of file From 7b1bd3b43cadba5960bb6452797391e13d715dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Sat, 7 Dec 2024 19:28:46 +0300 Subject: [PATCH 03/11] add info about shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- common/autoware_node/include/autoware/node/node.hpp | 5 +++++ common/autoware_node/src/node.cpp | 11 ++++++++++- common/autoware_test_node/README.md | 11 ++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/common/autoware_node/include/autoware/node/node.hpp b/common/autoware_node/include/autoware/node/node.hpp index 4e978bc337..4531bf48c7 100644 --- a/common/autoware_node/include/autoware/node/node.hpp +++ b/common/autoware_node/include/autoware/node/node.hpp @@ -23,6 +23,8 @@ namespace autoware::node { +using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; + class Node : public rclcpp_lifecycle::LifecycleNode { public: @@ -30,6 +32,9 @@ class Node : public rclcpp_lifecycle::LifecycleNode explicit Node( const std::string & node_name, const std::string & ns = "", const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); + +protected: + CallbackReturn on_shutdown(const rclcpp_lifecycle::State & state) override; }; } // namespace autoware::node diff --git a/common/autoware_node/src/node.cpp b/common/autoware_node/src/node.cpp index 8bd3b39d50..f402f4daf5 100644 --- a/common/autoware_node/src/node.cpp +++ b/common/autoware_node/src/node.cpp @@ -23,6 +23,15 @@ Node::Node( : LifecycleNode(node_name, ns, options) { RCLCPP_DEBUG( - get_logger(), "Node %s constructor was called.", get_node_base_interface()->get_fully_qualified_name()); + get_logger(), "Node %s constructor was called.", + get_node_base_interface()->get_fully_qualified_name()); +} + +CallbackReturn Node::on_shutdown(const rclcpp_lifecycle::State & state) +{ + RCLCPP_DEBUG( + get_logger(), "Node %s shutdown was called with state %s.", + get_node_base_interface()->get_fully_qualified_name(), state.label().c_str()); + return CallbackReturn::SUCCESS; } } // namespace autoware::node diff --git a/common/autoware_test_node/README.md b/common/autoware_test_node/README.md index a67dbd1e2b..91a07cd710 100644 --- a/common/autoware_test_node/README.md +++ b/common/autoware_test_node/README.md @@ -10,6 +10,8 @@ ros2 launch autoware_test_node autoware_test_node.launch.xml ### Lifecycle control +Information on Lifecycle nodes can be found [here](https://design.ros2.org/articles/node_lifecycle.html). + Output a list of nodes with lifecycle: ```console @@ -41,4 +43,11 @@ Shutdown the node: ```console $ ros2 lifecycle set /test_ns1/test_node1 shutdown Transitioning successful -``` \ No newline at end of file +``` + +```console +$ ros2 lifecycle get /test_ns1/test_node1 +finalized [4] +``` + +The node will remain alive in the `finalized` state until it is killed by the user. From 609ae1f1befdff236618bdb16226b4ce6c65adb9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 7 Dec 2024 16:30:37 +0000 Subject: [PATCH 04/11] style(pre-commit): autofix --- common/autoware_node/package.xml | 3 +-- common/autoware_node/test/test_an_init_shutdown.cpp | 5 +---- .../autoware_test_node/launch/autoware_test_node.launch.xml | 3 +-- common/autoware_test_node/src/test_node.cpp | 3 ++- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/common/autoware_node/package.xml b/common/autoware_node/package.xml index dbbf7c15d1..e52fa4e4f7 100644 --- a/common/autoware_node/package.xml +++ b/common/autoware_node/package.xml @@ -3,8 +3,7 @@ autoware_node 0.0.0 - Autoware Node is an Autoware.Core package designed to provide a base class for all nodes in the system. - + Autoware Node is an Autoware.Core package designed to provide a base class for all nodes in the system. M. Fatih Cırıt Apache-2.0 diff --git a/common/autoware_node/test/test_an_init_shutdown.cpp b/common/autoware_node/test/test_an_init_shutdown.cpp index a10438ef2a..8dea411e87 100644 --- a/common/autoware_node/test/test_an_init_shutdown.cpp +++ b/common/autoware_node/test/test_an_init_shutdown.cpp @@ -22,10 +22,7 @@ class AutowareNodeInitShutdown : public ::testing::Test { public: - void SetUp() override - { - rclcpp::init(0, nullptr); - } + void SetUp() override { rclcpp::init(0, nullptr); } void TearDown() override { rclcpp::shutdown(); } diff --git a/common/autoware_test_node/launch/autoware_test_node.launch.xml b/common/autoware_test_node/launch/autoware_test_node.launch.xml index a6cadc811f..c034fa0813 100644 --- a/common/autoware_test_node/launch/autoware_test_node.launch.xml +++ b/common/autoware_test_node/launch/autoware_test_node.launch.xml @@ -1,4 +1,3 @@ - - + diff --git a/common/autoware_test_node/src/test_node.cpp b/common/autoware_test_node/src/test_node.cpp index c28a884102..4f38f58a5e 100644 --- a/common/autoware_test_node/src/test_node.cpp +++ b/common/autoware_test_node/src/test_node.cpp @@ -22,7 +22,8 @@ TestNode::TestNode(const rclcpp::NodeOptions & options) : autoware::node::Node("test_node", "", options) { RCLCPP_DEBUG( - get_logger(), "TestNode %s constructor was called.", get_node_base_interface()->get_fully_qualified_name()); + get_logger(), "TestNode %s constructor was called.", + get_node_base_interface()->get_fully_qualified_name()); } } // namespace autoware::test_node From a0466d1635d59f876e990941e060dd35e8a7316f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 10:08:14 +0300 Subject: [PATCH 05/11] quote->brace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- common/autoware_node/src/node.cpp | 2 +- common/autoware_test_node/src/test_node.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/autoware_node/src/node.cpp b/common/autoware_node/src/node.cpp index f402f4daf5..9d7c3d729b 100644 --- a/common/autoware_node/src/node.cpp +++ b/common/autoware_node/src/node.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "autoware/node/node.hpp" +#include #include diff --git a/common/autoware_test_node/src/test_node.cpp b/common/autoware_test_node/src/test_node.cpp index 4f38f58a5e..2e2b60b824 100644 --- a/common/autoware_test_node/src/test_node.cpp +++ b/common/autoware_test_node/src/test_node.cpp @@ -27,5 +27,5 @@ TestNode::TestNode(const rclcpp::NodeOptions & options) } } // namespace autoware::test_node -#include "rclcpp_components/register_node_macro.hpp" +#include RCLCPP_COMPONENTS_REGISTER_NODE(autoware::test_node::TestNode) From 4ffcf7469745c18d4232e750c2cd558b51b5c742 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 07:10:29 +0000 Subject: [PATCH 06/11] style(pre-commit): autofix --- common/autoware_node/src/node.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/common/autoware_node/src/node.cpp b/common/autoware_node/src/node.cpp index 9d7c3d729b..5b610472f3 100644 --- a/common/autoware_node/src/node.cpp +++ b/common/autoware_node/src/node.cpp @@ -13,7 +13,6 @@ // limitations under the License. #include - #include namespace autoware::node From 06aa70dc2adf2fe7a55e49a1dfc6535bcfe129e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 13:55:48 +0300 Subject: [PATCH 07/11] move the test node to demos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- {common => demos}/autoware_test_node/CMakeLists.txt | 0 {common => demos}/autoware_test_node/README.md | 0 .../autoware_test_node/launch/autoware_test_node.launch.xml | 0 {common => demos}/autoware_test_node/package.xml | 0 {common => demos}/autoware_test_node/src/include/test_node.hpp | 0 {common => demos}/autoware_test_node/src/test_node.cpp | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {common => demos}/autoware_test_node/CMakeLists.txt (100%) rename {common => demos}/autoware_test_node/README.md (100%) rename {common => demos}/autoware_test_node/launch/autoware_test_node.launch.xml (100%) rename {common => demos}/autoware_test_node/package.xml (100%) rename {common => demos}/autoware_test_node/src/include/test_node.hpp (100%) rename {common => demos}/autoware_test_node/src/test_node.cpp (100%) diff --git a/common/autoware_test_node/CMakeLists.txt b/demos/autoware_test_node/CMakeLists.txt similarity index 100% rename from common/autoware_test_node/CMakeLists.txt rename to demos/autoware_test_node/CMakeLists.txt diff --git a/common/autoware_test_node/README.md b/demos/autoware_test_node/README.md similarity index 100% rename from common/autoware_test_node/README.md rename to demos/autoware_test_node/README.md diff --git a/common/autoware_test_node/launch/autoware_test_node.launch.xml b/demos/autoware_test_node/launch/autoware_test_node.launch.xml similarity index 100% rename from common/autoware_test_node/launch/autoware_test_node.launch.xml rename to demos/autoware_test_node/launch/autoware_test_node.launch.xml diff --git a/common/autoware_test_node/package.xml b/demos/autoware_test_node/package.xml similarity index 100% rename from common/autoware_test_node/package.xml rename to demos/autoware_test_node/package.xml diff --git a/common/autoware_test_node/src/include/test_node.hpp b/demos/autoware_test_node/src/include/test_node.hpp similarity index 100% rename from common/autoware_test_node/src/include/test_node.hpp rename to demos/autoware_test_node/src/include/test_node.hpp diff --git a/common/autoware_test_node/src/test_node.cpp b/demos/autoware_test_node/src/test_node.cpp similarity index 100% rename from common/autoware_test_node/src/test_node.cpp rename to demos/autoware_test_node/src/test_node.cpp From 9efb556b23d6fd2e9a1024b5b4ef6f0d2540977b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 14:00:36 +0300 Subject: [PATCH 08/11] fix pre-commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- common/autoware_node/README.md | 2 +- common/autoware_node/src/node.cpp | 2 ++ common/autoware_node/test/test_an_init_shutdown.cpp | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/autoware_node/README.md b/common/autoware_node/README.md index be86ecff9e..28e39e54ea 100644 --- a/common/autoware_node/README.md +++ b/common/autoware_node/README.md @@ -13,7 +13,7 @@ class [LifecycleNode](https://docs.ros2.org/latest/api/rclcpp_lifecycle/classrcl ## Usage -Check the [autoware_test_node](../autoware_test_node/README.md) package for an example of how to use `autoware::Node`. +Check the [autoware_test_node](../../demos/autoware_test_node/README.md) package for an example of how to use `autoware::Node`. ## Design diff --git a/common/autoware_node/src/node.cpp b/common/autoware_node/src/node.cpp index 5b610472f3..385d3731d0 100644 --- a/common/autoware_node/src/node.cpp +++ b/common/autoware_node/src/node.cpp @@ -15,6 +15,8 @@ #include #include +#include + namespace autoware::node { Node::Node( diff --git a/common/autoware_node/test/test_an_init_shutdown.cpp b/common/autoware_node/test/test_an_init_shutdown.cpp index 8dea411e87..597e9d38d1 100644 --- a/common/autoware_node/test/test_an_init_shutdown.cpp +++ b/common/autoware_node/test/test_an_init_shutdown.cpp @@ -19,6 +19,8 @@ #include +#include + class AutowareNodeInitShutdown : public ::testing::Test { public: From 7cbb780086f34a616e365ee5bb62668f5fd89e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 14:28:03 +0300 Subject: [PATCH 09/11] remove node namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- common/autoware_node/include/autoware/node/node.hpp | 4 ++-- common/autoware_node/src/node.cpp | 4 ++-- common/autoware_node/test/test_an_init_shutdown.cpp | 4 ++-- demos/autoware_test_node/src/include/test_node.hpp | 2 +- demos/autoware_test_node/src/test_node.cpp | 3 +-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/common/autoware_node/include/autoware/node/node.hpp b/common/autoware_node/include/autoware/node/node.hpp index 4531bf48c7..618550c770 100644 --- a/common/autoware_node/include/autoware/node/node.hpp +++ b/common/autoware_node/include/autoware/node/node.hpp @@ -21,7 +21,7 @@ #include -namespace autoware::node +namespace autoware { using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; @@ -36,6 +36,6 @@ class Node : public rclcpp_lifecycle::LifecycleNode protected: CallbackReturn on_shutdown(const rclcpp_lifecycle::State & state) override; }; -} // namespace autoware::node +} // namespace autoware #endif // AUTOWARE__NODE__NODE_HPP_ diff --git a/common/autoware_node/src/node.cpp b/common/autoware_node/src/node.cpp index 385d3731d0..fc064f691e 100644 --- a/common/autoware_node/src/node.cpp +++ b/common/autoware_node/src/node.cpp @@ -17,7 +17,7 @@ #include -namespace autoware::node +namespace autoware { Node::Node( const std::string & node_name, const std::string & ns, const rclcpp::NodeOptions & options) @@ -35,4 +35,4 @@ CallbackReturn Node::on_shutdown(const rclcpp_lifecycle::State & state) get_node_base_interface()->get_fully_qualified_name(), state.label().c_str()); return CallbackReturn::SUCCESS; } -} // namespace autoware::node +} // namespace autoware diff --git a/common/autoware_node/test/test_an_init_shutdown.cpp b/common/autoware_node/test/test_an_init_shutdown.cpp index 597e9d38d1..a75af7a617 100644 --- a/common/autoware_node/test/test_an_init_shutdown.cpp +++ b/common/autoware_node/test/test_an_init_shutdown.cpp @@ -36,8 +36,8 @@ TEST_F(AutowareNodeInitShutdown, NodeInitShutdown) std::shared_ptr executor; executor = std::make_shared(); - autoware::node::Node::SharedPtr autoware_node = - std::make_shared("test_node", "test_ns", node_options_an_); + autoware::Node::SharedPtr autoware_node = + std::make_shared("test_node", "test_ns", node_options_an_); executor->add_node(autoware_node->get_node_base_interface()); diff --git a/demos/autoware_test_node/src/include/test_node.hpp b/demos/autoware_test_node/src/include/test_node.hpp index 027171d2d8..9d46499fd2 100644 --- a/demos/autoware_test_node/src/include/test_node.hpp +++ b/demos/autoware_test_node/src/include/test_node.hpp @@ -21,7 +21,7 @@ namespace autoware::test_node { -class TestNode : public autoware::node::Node +class TestNode : public autoware::Node { public: explicit TestNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); diff --git a/demos/autoware_test_node/src/test_node.cpp b/demos/autoware_test_node/src/test_node.cpp index 2e2b60b824..e76ac8e5e6 100644 --- a/demos/autoware_test_node/src/test_node.cpp +++ b/demos/autoware_test_node/src/test_node.cpp @@ -18,8 +18,7 @@ namespace autoware::test_node { -TestNode::TestNode(const rclcpp::NodeOptions & options) -: autoware::node::Node("test_node", "", options) +TestNode::TestNode(const rclcpp::NodeOptions & options) : autoware::Node("test_node", "", options) { RCLCPP_DEBUG( get_logger(), "TestNode %s constructor was called.", From ea6f047cc618233702432c11db5761313509e0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 14:28:15 +0300 Subject: [PATCH 10/11] Revert "remove node namespace" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7cbb780086f34a616e365ee5bb62668f5fd89e0d. Signed-off-by: M. Fatih Cırıt --- common/autoware_node/include/autoware/node/node.hpp | 4 ++-- common/autoware_node/src/node.cpp | 4 ++-- common/autoware_node/test/test_an_init_shutdown.cpp | 4 ++-- demos/autoware_test_node/src/include/test_node.hpp | 2 +- demos/autoware_test_node/src/test_node.cpp | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/autoware_node/include/autoware/node/node.hpp b/common/autoware_node/include/autoware/node/node.hpp index 618550c770..4531bf48c7 100644 --- a/common/autoware_node/include/autoware/node/node.hpp +++ b/common/autoware_node/include/autoware/node/node.hpp @@ -21,7 +21,7 @@ #include -namespace autoware +namespace autoware::node { using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; @@ -36,6 +36,6 @@ class Node : public rclcpp_lifecycle::LifecycleNode protected: CallbackReturn on_shutdown(const rclcpp_lifecycle::State & state) override; }; -} // namespace autoware +} // namespace autoware::node #endif // AUTOWARE__NODE__NODE_HPP_ diff --git a/common/autoware_node/src/node.cpp b/common/autoware_node/src/node.cpp index fc064f691e..385d3731d0 100644 --- a/common/autoware_node/src/node.cpp +++ b/common/autoware_node/src/node.cpp @@ -17,7 +17,7 @@ #include -namespace autoware +namespace autoware::node { Node::Node( const std::string & node_name, const std::string & ns, const rclcpp::NodeOptions & options) @@ -35,4 +35,4 @@ CallbackReturn Node::on_shutdown(const rclcpp_lifecycle::State & state) get_node_base_interface()->get_fully_qualified_name(), state.label().c_str()); return CallbackReturn::SUCCESS; } -} // namespace autoware +} // namespace autoware::node diff --git a/common/autoware_node/test/test_an_init_shutdown.cpp b/common/autoware_node/test/test_an_init_shutdown.cpp index a75af7a617..597e9d38d1 100644 --- a/common/autoware_node/test/test_an_init_shutdown.cpp +++ b/common/autoware_node/test/test_an_init_shutdown.cpp @@ -36,8 +36,8 @@ TEST_F(AutowareNodeInitShutdown, NodeInitShutdown) std::shared_ptr executor; executor = std::make_shared(); - autoware::Node::SharedPtr autoware_node = - std::make_shared("test_node", "test_ns", node_options_an_); + autoware::node::Node::SharedPtr autoware_node = + std::make_shared("test_node", "test_ns", node_options_an_); executor->add_node(autoware_node->get_node_base_interface()); diff --git a/demos/autoware_test_node/src/include/test_node.hpp b/demos/autoware_test_node/src/include/test_node.hpp index 9d46499fd2..027171d2d8 100644 --- a/demos/autoware_test_node/src/include/test_node.hpp +++ b/demos/autoware_test_node/src/include/test_node.hpp @@ -21,7 +21,7 @@ namespace autoware::test_node { -class TestNode : public autoware::Node +class TestNode : public autoware::node::Node { public: explicit TestNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); diff --git a/demos/autoware_test_node/src/test_node.cpp b/demos/autoware_test_node/src/test_node.cpp index e76ac8e5e6..2e2b60b824 100644 --- a/demos/autoware_test_node/src/test_node.cpp +++ b/demos/autoware_test_node/src/test_node.cpp @@ -18,7 +18,8 @@ namespace autoware::test_node { -TestNode::TestNode(const rclcpp::NodeOptions & options) : autoware::Node("test_node", "", options) +TestNode::TestNode(const rclcpp::NodeOptions & options) +: autoware::node::Node("test_node", "", options) { RCLCPP_DEBUG( get_logger(), "TestNode %s constructor was called.", From de30f052a0b17bcc9de73ebda72ae2823d6fa34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 15:53:05 +0300 Subject: [PATCH 11/11] clean up the test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- common/autoware_node/test/test_an_init_shutdown.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/common/autoware_node/test/test_an_init_shutdown.cpp b/common/autoware_node/test/test_an_init_shutdown.cpp index 597e9d38d1..1224c17c92 100644 --- a/common/autoware_node/test/test_an_init_shutdown.cpp +++ b/common/autoware_node/test/test_an_init_shutdown.cpp @@ -33,12 +33,10 @@ class AutowareNodeInitShutdown : public ::testing::Test TEST_F(AutowareNodeInitShutdown, NodeInitShutdown) { - std::shared_ptr executor; - executor = std::make_shared(); - autoware::node::Node::SharedPtr autoware_node = std::make_shared("test_node", "test_ns", node_options_an_); + auto executor = std::make_shared(); executor->add_node(autoware_node->get_node_base_interface()); std::thread thread_spin = std::thread([&executor]() { executor->spin(); }); @@ -60,5 +58,3 @@ TEST_F(AutowareNodeInitShutdown, NodeInitShutdown) thread_spin.join(); } } - -// TEST_F(AutowareNodeTest, Sen)