From 608a4d303f86d171510739149fd1f10717337eaa Mon Sep 17 00:00:00 2001 From: Yara Shahin <58101871+YaraShahin@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:41:29 +0300 Subject: [PATCH] fix build errors in ros2 controller package setup (#232) --- scripts/ros2_control/setup-controller-package.bash | 4 ++-- templates/ros2_control/controller/test_dummy_controller.cpp | 1 + templates/ros2_control/controller/test_dummy_controller.hpp | 5 ++++- .../ros2_control/controller/test_load_dummy_controller.cpp | 4 +--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/ros2_control/setup-controller-package.bash b/scripts/ros2_control/setup-controller-package.bash index 764a6092..9b13307f 100755 --- a/scripts/ros2_control/setup-controller-package.bash +++ b/scripts/ros2_control/setup-controller-package.bash @@ -374,8 +374,8 @@ for DEP_PKG in "${TEST_DEP_PKGS[@]}"; do if `grep -q " find_package(${DEP_PKG} REQUIRED)" CMakeLists.txt`; then echo "'$DEP_PKG' is already listed in CMakeLists.txt" else - append_to_string="ament_lint_auto_find_test_dependencies()" - sed -i "s/$append_to_string/$append_to_string\\n find_package(${DEP_PKG} REQUIRED)/g" CMakeLists.txt + append_to_string="find_package(generate_parameter_library REQUIRED)" + sed -i "s/$append_to_string/$append_to_string\\nfind_package(${DEP_PKG} REQUIRED)/g" CMakeLists.txt fi # package.xml diff --git a/templates/ros2_control/controller/test_dummy_controller.cpp b/templates/ros2_control/controller/test_dummy_controller.cpp index 88067cac..66bf3970 100644 --- a/templates/ros2_control/controller/test_dummy_controller.cpp +++ b/templates/ros2_control/controller/test_dummy_controller.cpp @@ -18,6 +18,7 @@ // #include "test_dummy_controller.hpp" +#include "rclcpp/rclcpp.hpp" #include #include diff --git a/templates/ros2_control/controller/test_dummy_controller.hpp b/templates/ros2_control/controller/test_dummy_controller.hpp index 4fd9e2fe..dece0dfd 100644 --- a/templates/ros2_control/controller/test_dummy_controller.hpp +++ b/templates/ros2_control/controller/test_dummy_controller.hpp @@ -33,6 +33,7 @@ #include "hardware_interface/loaned_command_interface.hpp" #include "hardware_interface/loaned_state_interface.hpp" #include "hardware_interface/types/hardware_interface_return_values.hpp" +#include "rclcpp/executor.hpp" #include "rclcpp/parameter_value.hpp" #include "rclcpp/time.hpp" #include "rclcpp/utilities.hpp" @@ -132,7 +133,9 @@ class DummyClassNameFixture : public ::testing::Test protected: void SetUpController(const std::string controller_name = "test_dummy_controller") { - ASSERT_EQ(controller_->init(controller_name), controller_interface::return_type::OK); + ASSERT_EQ( + controller_->init(controller_name, "", 0, "", controller_->define_custom_node_options()), + controller_interface::return_type::OK); std::vector command_ifs; command_itfs_.reserve(joint_command_values_.size()); diff --git a/templates/ros2_control/controller/test_load_dummy_controller.cpp b/templates/ros2_control/controller/test_load_dummy_controller.cpp index 8875e9cb..14121668 100644 --- a/templates/ros2_control/controller/test_load_dummy_controller.cpp +++ b/templates/ros2_control/controller/test_load_dummy_controller.cpp @@ -35,9 +35,7 @@ TEST(TestLoadDummyClassName, load_controller) std::make_shared(); controller_manager::ControllerManager cm( - std::make_unique( - ros2_control_test_assets::minimal_robot_urdf), - executor, "test_controller_manager"); + executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager"); ASSERT_NO_THROW( cm.load_controller("test_dummy_package_namespace", "dummy_package_namespace/DummyClassName"));