From df7e483f63bce6818fd26b07986759ce8952325b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Thu, 12 Jan 2023 22:18:14 +0300 Subject: [PATCH] feat(autoware_node): add AutowareNode base class 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_control_center/CMakeLists.txt | 20 +++++++++ common/autoware_control_center/README.md | 0 .../autoware_control_center.hpp | 41 ++++++++++++++++++ .../visibility_control.hpp | 28 +++++++++++++ common/autoware_control_center/package.xml | 29 +++++++++++++ .../src/autoware_control_center.cpp | 34 +++++++++++++++ .../src/autoware_control_center_node.cpp | 36 ++++++++++++++++ .../test/test_autoware_control_center.cpp | 16 +++++++ .../test/test_autoware_control_center.hpp | 23 ++++++++++ .../CMakeLists.txt | 15 +++++++ common/autoware_control_center_msgs/README.md | 3 ++ .../msg/StatusRegistration.msg | 6 +++ .../autoware_control_center_msgs/package.xml | 23 ++++++++++ .../srv/AutowareNodeRegister.srv | 17 ++++++++ common/autoware_node/CMakeLists.txt | 18 ++++++++ common/autoware_node/README.md | 0 .../include/autoware_node/autoware_node.hpp | 42 +++++++++++++++++++ .../autoware_node/visibility_control.hpp | 27 ++++++++++++ common/autoware_node/package.xml | 25 +++++++++++ common/autoware_node/src/autoware_node.cpp | 34 +++++++++++++++ .../autoware_node/test/test_autoware_node.cpp | 16 +++++++ .../autoware_node/test/test_autoware_node.hpp | 19 +++++++++ common/test_node/CMakeLists.txt | 29 +++++++++++++ common/test_node/README.md | 0 .../test_node/include/test_node/test_node.hpp | 35 ++++++++++++++++ .../include/test_node/visibility_control.hpp | 27 ++++++++++++ common/test_node/package.xml | 28 +++++++++++++ common/test_node/src/test_node.cpp | 35 ++++++++++++++++ common/test_node/test/test_autoware_node.cpp | 16 +++++++ common/test_node/test/test_autoware_node.hpp | 19 +++++++++ 30 files changed, 661 insertions(+) create mode 100644 common/autoware_control_center/CMakeLists.txt create mode 100644 common/autoware_control_center/README.md create mode 100644 common/autoware_control_center/include/autoware_control_center/autoware_control_center.hpp create mode 100644 common/autoware_control_center/include/autoware_control_center/visibility_control.hpp create mode 100644 common/autoware_control_center/package.xml create mode 100644 common/autoware_control_center/src/autoware_control_center.cpp create mode 100644 common/autoware_control_center/src/autoware_control_center_node.cpp create mode 100644 common/autoware_control_center/test/test_autoware_control_center.cpp create mode 100644 common/autoware_control_center/test/test_autoware_control_center.hpp create mode 100644 common/autoware_control_center_msgs/CMakeLists.txt create mode 100644 common/autoware_control_center_msgs/README.md create mode 100644 common/autoware_control_center_msgs/msg/StatusRegistration.msg create mode 100644 common/autoware_control_center_msgs/package.xml create mode 100644 common/autoware_control_center_msgs/srv/AutowareNodeRegister.srv 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/autoware_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/autoware_node.cpp create mode 100644 common/autoware_node/test/test_autoware_node.cpp create mode 100644 common/autoware_node/test/test_autoware_node.hpp create mode 100644 common/test_node/CMakeLists.txt create mode 100644 common/test_node/README.md create mode 100644 common/test_node/include/test_node/test_node.hpp create mode 100644 common/test_node/include/test_node/visibility_control.hpp create mode 100644 common/test_node/package.xml create mode 100644 common/test_node/src/test_node.cpp create mode 100644 common/test_node/test/test_autoware_node.cpp create mode 100644 common/test_node/test/test_autoware_node.hpp diff --git a/common/autoware_control_center/CMakeLists.txt b/common/autoware_control_center/CMakeLists.txt new file mode 100644 index 00000000..315a643a --- /dev/null +++ b/common/autoware_control_center/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.8) +project(autoware_control_center) + +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() + +autoware_package() + +ament_auto_add_executable(${PROJECT_NAME} src/autoware_control_center_node.cpp + src/autoware_control_center.cpp) +#target_link_libraries(${PROJECT_NAME}) + +#if (BUILD_TESTING) +# find_package(ament_lint_auto REQUIRED) +# ament_lint_auto_find_test_dependencies() +# ament_add_ros_isolated_gtest(test_autoware_control_center test/test_autoware_control_center.cpp) +# target_link_libraries(test_autoware_control_center ${PROJECT_NAME}) +#endif () + +ament_auto_package() diff --git a/common/autoware_control_center/README.md b/common/autoware_control_center/README.md new file mode 100644 index 00000000..e69de29b diff --git a/common/autoware_control_center/include/autoware_control_center/autoware_control_center.hpp b/common/autoware_control_center/include/autoware_control_center/autoware_control_center.hpp new file mode 100644 index 00000000..9f5d27f9 --- /dev/null +++ b/common/autoware_control_center/include/autoware_control_center/autoware_control_center.hpp @@ -0,0 +1,41 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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_CONTROL_CENTER__AUTOWARE_CONTROL_CENTER_HPP_ +#define AUTOWARE_CONTROL_CENTER__AUTOWARE_CONTROL_CENTER_HPP_ + +#include "autoware_control_center/visibility_control.hpp" +#include "rclcpp_lifecycle/lifecycle_node.hpp" + +#include "autoware_control_center_msgs/msg/autoware_control_center_json.hpp" + +namespace autoware_control_center +{ + +class AutowareControlCenter : public rclcpp_lifecycle::LifecycleNode +{ +public: + AutowareControlCenter(const rclcpp::NodeOptions & options); + +private: + using AutowareControlCenterJson = autoware_control_center_msgs::msg::AutowareControlCenterJson; + rclcpp::Subscription::SharedPtr sub_global_; + + void callback_acc_json_global(const AutowareControlCenterJson::ConstSharedPtr & msg); +}; + +} // namespace autoware_control_center + +#endif // AUTOWARE_CONTROL_CENTER__AUTOWARE_CONTROL_CENTER_HPP_ diff --git a/common/autoware_control_center/include/autoware_control_center/visibility_control.hpp b/common/autoware_control_center/include/autoware_control_center/visibility_control.hpp new file mode 100644 index 00000000..cbb9a067 --- /dev/null +++ b/common/autoware_control_center/include/autoware_control_center/visibility_control.hpp @@ -0,0 +1,28 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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_CONTROL_CENTER__VISIBILITY_CONTROL_HPP_ +#define AUTOWARE_CONTROL_CENTER__VISIBILITY_CONTROL_HPP_ + +#include "rcutils/visibility_control_macros.h" + +#ifdef AUTOWARE_CONTROL_CENTER_BUILDING_DLL +#define AUTOWARE_CONTROL_CENTER_PUBLIC RCUTILS_EXPORT +#else +#define AUTOWARE_CONTROL_CENTER_PUBLIC RCUTILS_IMPORT +#endif // !AUTOWARE_CONTROL_CENTER_BUILDING_DLL +#define AUTOWARE_CONTROL_CENTER_LOCAL RCUTILS_LOCAL + +#endif // AUTOWARE_CONTROL_CENTER__VISIBILITY_CONTROL_HPP_ diff --git a/common/autoware_control_center/package.xml b/common/autoware_control_center/package.xml new file mode 100644 index 00000000..2c46741a --- /dev/null +++ b/common/autoware_control_center/package.xml @@ -0,0 +1,29 @@ + + + + autoware_control_center + 0.0.0 + TODO: Package description + M. Fatih Cırıt + Apache-2.0 + + ament_cmake_auto + autoware_cmake + + autoware_control_center_msgs + bond + bondcpp + lifecycle_msgs + nlohmann-json-dev + rclcpp_components + rclcpp_lifecycle + rcutils + + ament_cmake_ros + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/common/autoware_control_center/src/autoware_control_center.cpp b/common/autoware_control_center/src/autoware_control_center.cpp new file mode 100644 index 00000000..bc378941 --- /dev/null +++ b/common/autoware_control_center/src/autoware_control_center.cpp @@ -0,0 +1,34 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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_control_center/autoware_control_center.hpp" + +namespace autoware_control_center +{ +AutowareControlCenter::AutowareControlCenter(const rclcpp::NodeOptions & options) +: LifecycleNode("autoware_control_center", options) +{ + // log info + RCLCPP_INFO(get_logger(), "AutowareControlCenter is initialized"); +} + +void AutowareControlCenter::callback_acc_json_global( + const autoware_control_center_msgs::msg::AutowareControlCenterJson::ConstSharedPtr & msg) +{ + // log message + RCLCPP_INFO(get_logger(), "AutowareControlCenterJson received %s", msg->json_message.c_str()); +} + +} // namespace autoware_control_center diff --git a/common/autoware_control_center/src/autoware_control_center_node.cpp b/common/autoware_control_center/src/autoware_control_center_node.cpp new file mode 100644 index 00000000..fddc0b7d --- /dev/null +++ b/common/autoware_control_center/src/autoware_control_center_node.cpp @@ -0,0 +1,36 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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_control_center/autoware_control_center.hpp" + +#include + +#include + +int main(int argc, char * argv[]) +{ + rclcpp::init(argc, argv); + auto autoware_control_center = + std::make_shared(rclcpp::NodeOptions()); + rclcpp::executors::MultiThreadedExecutor exec; + exec.add_node(autoware_control_center->get_node_base_interface()); + exec.spin(); + rclcpp::shutdown(); + + return 0; +} + +#include +RCLCPP_COMPONENTS_REGISTER_NODE(autoware_control_center::AutowareControlCenter) diff --git a/common/autoware_control_center/test/test_autoware_control_center.cpp b/common/autoware_control_center/test/test_autoware_control_center.cpp new file mode 100644 index 00000000..7644a1ae --- /dev/null +++ b/common/autoware_control_center/test/test_autoware_control_center.cpp @@ -0,0 +1,16 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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 "test_autoware_control_center.hpp" diff --git a/common/autoware_control_center/test/test_autoware_control_center.hpp b/common/autoware_control_center/test/test_autoware_control_center.hpp new file mode 100644 index 00000000..ba8e0b29 --- /dev/null +++ b/common/autoware_control_center/test/test_autoware_control_center.hpp @@ -0,0 +1,23 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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_AUTOWARE_CONTROL_CENTER_HPP_ +#define TEST_AUTOWARE_CONTROL_CENTER_HPP_ + +class test_autoware_control_center +{ +}; + +#endif // TEST_AUTOWARE_CONTROL_CENTER_HPP_ diff --git a/common/autoware_control_center_msgs/CMakeLists.txt b/common/autoware_control_center_msgs/CMakeLists.txt new file mode 100644 index 00000000..3042b2f4 --- /dev/null +++ b/common/autoware_control_center_msgs/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.14) +project(autoware_control_center_msgs) + +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() +set(msg_dependencies + unique_identifier_msgs) + +rosidl_generate_interfaces(${PROJECT_NAME} + "msg/StatusRegistration.msg" + "srv/AutowareNodeRegister.srv" + DEPENDENCIES ${msg_dependencies} + ADD_LINTER_TESTS) + +ament_auto_package() diff --git a/common/autoware_control_center_msgs/README.md b/common/autoware_control_center_msgs/README.md new file mode 100644 index 00000000..8bfa7c3f --- /dev/null +++ b/common/autoware_control_center_msgs/README.md @@ -0,0 +1,3 @@ +# autoware_msgs + +Before contributing, review [the message guidelines](https://autowarefoundation.github.io/autoware-documentation/main/contributing/coding-guidelines/ros-nodes/message-guidelines/). diff --git a/common/autoware_control_center_msgs/msg/StatusRegistration.msg b/common/autoware_control_center_msgs/msg/StatusRegistration.msg new file mode 100644 index 00000000..239c68bc --- /dev/null +++ b/common/autoware_control_center_msgs/msg/StatusRegistration.msg @@ -0,0 +1,6 @@ +# Status States +uint8 FAILURE=0 +uint8 SUCCESS=1 + +# Status +uint8 status diff --git a/common/autoware_control_center_msgs/package.xml b/common/autoware_control_center_msgs/package.xml new file mode 100644 index 00000000..c7090991 --- /dev/null +++ b/common/autoware_control_center_msgs/package.xml @@ -0,0 +1,23 @@ + + + + autoware_control_center_msgs + 1.0.0 + autoware_control_center_msgs package. + M. Fatih Cırıt + Apache License 2.0 + + ament_cmake_auto + + rosidl_default_generators + unique_identifier_msgs + + ament_lint_auto + ament_lint_common + + rosidl_interface_packages + + + ament_cmake + + diff --git a/common/autoware_control_center_msgs/srv/AutowareNodeRegister.srv b/common/autoware_control_center_msgs/srv/AutowareNodeRegister.srv new file mode 100644 index 00000000..860da163 --- /dev/null +++ b/common/autoware_control_center_msgs/srv/AutowareNodeRegister.srv @@ -0,0 +1,17 @@ +# Request + +## Name of the registering AutowareNode +string name_node + +--- + +# Response + +## Status +autoware_control_center_msgs/StatusRegistration status + +## UUID +unique_identifier_msgs/UUID uuid_node + +## Response Log +string log_response diff --git a/common/autoware_node/CMakeLists.txt b/common/autoware_node/CMakeLists.txt new file mode 100644 index 00000000..27d283e1 --- /dev/null +++ b/common/autoware_node/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.8) +project(autoware_node) + +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() + +autoware_package() + +ament_auto_add_library(${PROJECT_NAME} src/autoware_node.cpp) + +if (BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() + ament_add_ros_isolated_gtest(test_autoware_node test/test_autoware_node.cpp) + target_link_libraries(test_autoware_node ${PROJECT_NAME}) +endif () + +ament_auto_package() diff --git a/common/autoware_node/README.md b/common/autoware_node/README.md new file mode 100644 index 00000000..e69de29b diff --git a/common/autoware_node/include/autoware_node/autoware_node.hpp b/common/autoware_node/include/autoware_node/autoware_node.hpp new file mode 100644 index 00000000..3f966231 --- /dev/null +++ b/common/autoware_node/include/autoware_node/autoware_node.hpp @@ -0,0 +1,42 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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__AUTOWARE_NODE_HPP_ +#define AUTOWARE_NODE__AUTOWARE_NODE_HPP_ + +#include "autoware_node/visibility_control.hpp" +#include "rclcpp_lifecycle/lifecycle_node.hpp" + +#include "autoware_control_center_msgs/srv/autoware_node_register.hpp" + +namespace autoware_node +{ + +class AutowareNode : public rclcpp_lifecycle::LifecycleNode +{ +public: + AUTOWARE_NODE_PUBLIC + AutowareNode( + const std::string & node_name, const std::string & ns = "", + const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); + + rclcpp::CallbackGroup::SharedPtr callback_group_mut_ex_; + + rclcpp::Client::SharedPtr cli_register_; +}; + +} // namespace autoware_node + +#endif // AUTOWARE_NODE__AUTOWARE_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 00000000..0bc63e14 --- /dev/null +++ b/common/autoware_node/include/autoware_node/visibility_control.hpp @@ -0,0 +1,27 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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 00000000..ae480341 --- /dev/null +++ b/common/autoware_node/package.xml @@ -0,0 +1,25 @@ + + + + autoware_node + 0.0.0 + TODO: Package description + M. Fatih Cırıt + Apache-2.0 + + ament_cmake_auto + autoware_cmake + + autoware_control_center_msgs + nlohmann-json-dev + rclcpp_lifecycle + + ament_cmake_ros + ament_lint_auto + ament_lint_common + autoware_control_center + + + ament_cmake + + diff --git a/common/autoware_node/src/autoware_node.cpp b/common/autoware_node/src/autoware_node.cpp new file mode 100644 index 00000000..5ff8c57b --- /dev/null +++ b/common/autoware_node/src/autoware_node.cpp @@ -0,0 +1,34 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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 "autoware_node/autoware_node.hpp" + +#include "autoware_control_center_msgs/srv/autoware_node_register.hpp" + +namespace autoware_node +{ + +AutowareNode::AutowareNode( + const std::string & node_name, const std::string & ns, const rclcpp::NodeOptions & options) +: LifecycleNode(node_name, ns, options) +{ + callback_group_mut_ex_ = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive); + + cli_register_ = create_client( + "~/cli/autoware_node_register", rmw_qos_profile_default, callback_group_mut_ex_); +} + +} // namespace autoware_node diff --git a/common/autoware_node/test/test_autoware_node.cpp b/common/autoware_node/test/test_autoware_node.cpp new file mode 100644 index 00000000..d910f600 --- /dev/null +++ b/common/autoware_node/test/test_autoware_node.cpp @@ -0,0 +1,16 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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 "test_autoware_node.hpp" diff --git a/common/autoware_node/test/test_autoware_node.hpp b/common/autoware_node/test/test_autoware_node.hpp new file mode 100644 index 00000000..4c221a3e --- /dev/null +++ b/common/autoware_node/test/test_autoware_node.hpp @@ -0,0 +1,19 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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_AUTOWARE_NODE_HPP_ +#define TEST_AUTOWARE_NODE_HPP_ + +#endif // TEST_AUTOWARE_NODE_HPP_ diff --git a/common/test_node/CMakeLists.txt b/common/test_node/CMakeLists.txt new file mode 100644 index 00000000..65711eca --- /dev/null +++ b/common/test_node/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.8) +project(test_node) + +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() + +autoware_package() + +include_directories( + include) + +set(executable_name ${PROJECT_NAME}) +set(library_name ${executable_name}_core) + +ament_auto_add_library(${library_name} SHARED + src/test_node.cpp) + +rclcpp_components_register_node(${library_name} + PLUGIN "test_node::TestNode" + EXECUTABLE ${executable_name} + ) +#if(BUILD_TESTING) +# find_package(ament_lint_auto REQUIRED) +# ament_lint_auto_find_test_dependencies() +# ament_add_ros_isolated_gtest(test_autoware_node test/test_autoware_node.cpp) +# target_link_libraries(test_autoware_node ${PROJECT_NAME}) +#endif() + +ament_auto_package() diff --git a/common/test_node/README.md b/common/test_node/README.md new file mode 100644 index 00000000..e69de29b diff --git a/common/test_node/include/test_node/test_node.hpp b/common/test_node/include/test_node/test_node.hpp new file mode 100644 index 00000000..7ae9c2ac --- /dev/null +++ b/common/test_node/include/test_node/test_node.hpp @@ -0,0 +1,35 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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__TEST_NODE_HPP_ +#define TEST_NODE__TEST_NODE_HPP_ + +#include "autoware_node/autoware_node.hpp" +#include "rclcpp_lifecycle/lifecycle_node.hpp" +#include "test_node/visibility_control.hpp" + +namespace test_node +{ + +class TestNode : public autoware_node::AutowareNode +{ +public: + TEST_NODE_PUBLIC + explicit TestNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); +}; + +} // namespace test_node + +#endif // TEST_NODE__TEST_NODE_HPP_ diff --git a/common/test_node/include/test_node/visibility_control.hpp b/common/test_node/include/test_node/visibility_control.hpp new file mode 100644 index 00000000..f49c1529 --- /dev/null +++ b/common/test_node/include/test_node/visibility_control.hpp @@ -0,0 +1,27 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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__VISIBILITY_CONTROL_HPP_ +#define TEST_NODE__VISIBILITY_CONTROL_HPP_ + +#include "rcutils/visibility_control_macros.h" +#ifdef TEST_NODE_BUILDING_DLL +#define TEST_NODE_PUBLIC RCUTILS_EXPORT +#else +#define TEST_NODE_PUBLIC RCUTILS_IMPORT +#endif // !TEST_NODE_BUILDING_DLL +#define TEST_NODE_LOCAL RCUTILS_LOCAL + +#endif // TEST_NODE__VISIBILITY_CONTROL_HPP_ diff --git a/common/test_node/package.xml b/common/test_node/package.xml new file mode 100644 index 00000000..fcddbe5e --- /dev/null +++ b/common/test_node/package.xml @@ -0,0 +1,28 @@ + + + + test_node + 0.0.0 + TODO: Package description + M. Fatih Cırıt + Apache-2.0 + + ament_cmake_auto + autoware_cmake + + autoware_control_center_msgs + autoware_node + nlohmann-json-dev + rclcpp + rclcpp_components + rclcpp_lifecycle + + ament_cmake_ros + ament_lint_auto + ament_lint_common + autoware_control_center + + + ament_cmake + + diff --git a/common/test_node/src/test_node.cpp b/common/test_node/src/test_node.cpp new file mode 100644 index 00000000..254542c3 --- /dev/null +++ b/common/test_node/src/test_node.cpp @@ -0,0 +1,35 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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 "test_node/test_node.hpp" + +#include "autoware_node/autoware_node.hpp" + +namespace test_node +{ + +TestNode::TestNode(const rclcpp::NodeOptions & options) +: autoware_node::AutowareNode("test_node", "", options) +{ +} + +} // namespace test_node + +#include "rclcpp_components/register_node_macro.hpp" + +// Register the component with class_loader. +// This acts as a sort of entry point, allowing the component to be discoverable when its library +// is being loaded into a running process. +RCLCPP_COMPONENTS_REGISTER_NODE(test_node::TestNode) diff --git a/common/test_node/test/test_autoware_node.cpp b/common/test_node/test/test_autoware_node.cpp new file mode 100644 index 00000000..d910f600 --- /dev/null +++ b/common/test_node/test/test_autoware_node.cpp @@ -0,0 +1,16 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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 "test_autoware_node.hpp" diff --git a/common/test_node/test/test_autoware_node.hpp b/common/test_node/test/test_autoware_node.hpp new file mode 100644 index 00000000..4c221a3e --- /dev/null +++ b/common/test_node/test/test_autoware_node.hpp @@ -0,0 +1,19 @@ +// Copyright 2022 The Autoware Contributors +// SPDX-License-Identifier: Apache-2.0 +// +// 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_AUTOWARE_NODE_HPP_ +#define TEST_AUTOWARE_NODE_HPP_ + +#endif // TEST_AUTOWARE_NODE_HPP_