From caef34d9ba26bc7447bdb5a3c03719b96fb35050 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Mon, 23 Oct 2023 08:34:58 +0200 Subject: [PATCH] added get_robot_description method to the base class --- .../controller_interface/controller_interface_base.hpp | 3 +++ controller_interface/src/controller_interface_base.cpp | 2 ++ controller_manager/test/test_controller/test_controller.cpp | 2 -- controller_manager/test/test_controller_manager.cpp | 6 +++--- controller_manager/test/test_controller_manager_srvs.cpp | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/controller_interface/include/controller_interface/controller_interface_base.hpp b/controller_interface/include/controller_interface/controller_interface_base.hpp index bba334aa3c..96141a034b 100644 --- a/controller_interface/include/controller_interface/controller_interface_base.hpp +++ b/controller_interface/include/controller_interface/controller_interface_base.hpp @@ -156,6 +156,9 @@ class ControllerInterfaceBase : public rclcpp_lifecycle::node_interfaces::Lifecy CONTROLLER_INTERFACE_PUBLIC bool is_async() const; + CONTROLLER_INTERFACE_PUBLIC + const std::string & get_robot_description() const; + /// Declare and initialize a parameter with a type. /** * diff --git a/controller_interface/src/controller_interface_base.cpp b/controller_interface/src/controller_interface_base.cpp index c30d264b90..fcbc28590a 100644 --- a/controller_interface/src/controller_interface_base.cpp +++ b/controller_interface/src/controller_interface_base.cpp @@ -133,4 +133,6 @@ unsigned int ControllerInterfaceBase::get_update_rate() const { return update_ra bool ControllerInterfaceBase::is_async() const { return is_async_; } +const std::string & ControllerInterfaceBase::get_robot_description() const { return urdf_; } + } // namespace controller_interface diff --git a/controller_manager/test/test_controller/test_controller.cpp b/controller_manager/test/test_controller/test_controller.cpp index 73bc0403c7..06f76bd044 100644 --- a/controller_manager/test/test_controller/test_controller.cpp +++ b/controller_manager/test/test_controller/test_controller.cpp @@ -119,8 +119,6 @@ void TestController::set_state_interface_configuration( state_iface_cfg_ = cfg; } -const std::string & TestController::getRobotDescription() const { return urdf_; } - } // namespace test_controller #include "pluginlib/class_list_macros.hpp" diff --git a/controller_manager/test/test_controller_manager.cpp b/controller_manager/test/test_controller_manager.cpp index 9639e92a69..c6603d82cd 100644 --- a/controller_manager/test/test_controller_manager.cpp +++ b/controller_manager/test/test_controller_manager.cpp @@ -45,7 +45,7 @@ TEST_F(TestControllerManagerRobotDescription, controller_robot_description_updat cm_->add_controller( test_controller, test_controller::TEST_CONTROLLER_NAME, test_controller::TEST_CONTROLLER_CLASS_NAME); - ASSERT_EQ(ros2_control_test_assets::minimal_robot_urdf, test_controller->getRobotDescription()); + ASSERT_EQ(ros2_control_test_assets::minimal_robot_urdf, test_controller->get_robot_description()); // Now change the robot description and then load a new controller and see if the new controller // gets the new description and the old controller still maintains the configuration @@ -55,10 +55,10 @@ TEST_F(TestControllerManagerRobotDescription, controller_robot_description_updat cm_->add_controller( test_controller2, test_controller::TEST_CONTROLLER2_NAME, test_controller::TEST_CONTROLLER_CLASS_NAME); - ASSERT_EQ(ros2_control_test_assets::minimal_robot_urdf, test_controller->getRobotDescription()); + ASSERT_EQ(ros2_control_test_assets::minimal_robot_urdf, test_controller->get_robot_description()); ASSERT_EQ( ros2_control_test_assets::minimal_robot_missing_state_keys_urdf, - test_controller2->getRobotDescription()); + test_controller2->get_robot_description()); } TEST_P(TestControllerManagerWithStrictness, controller_lifecycle) diff --git a/controller_manager/test/test_controller_manager_srvs.cpp b/controller_manager/test/test_controller_manager_srvs.cpp index a8fc184719..5744b3dd26 100644 --- a/controller_manager/test/test_controller_manager_srvs.cpp +++ b/controller_manager/test/test_controller_manager_srvs.cpp @@ -472,14 +472,14 @@ TEST_F(TestControllerManagerSrvs, robot_description_on_load_and_unload_controlle EXPECT_EQ(1u, cm_->get_loaded_controllers().size()); // check the robot description - ASSERT_EQ(ros2_control_test_assets::minimal_robot_urdf, test_controller->getRobotDescription()); + ASSERT_EQ(ros2_control_test_assets::minimal_robot_urdf, test_controller->get_robot_description()); // Now change the robot description and then see that the controller maintains the old URDF until // it is unloaded and loaded again auto msg = std_msgs::msg::String(); msg.data = ros2_control_test_assets::minimal_robot_missing_state_keys_urdf; cm_->robot_description_callback(msg); - ASSERT_EQ(ros2_control_test_assets::minimal_robot_urdf, test_controller->getRobotDescription()); + ASSERT_EQ(ros2_control_test_assets::minimal_robot_urdf, test_controller->get_robot_description()); // now unload and load the controller and see if the controller gets the new robot description auto unload_request = std::make_shared(); @@ -494,7 +494,7 @@ TEST_F(TestControllerManagerSrvs, robot_description_on_load_and_unload_controlle EXPECT_EQ(1u, cm_->get_loaded_controllers().size()); ASSERT_EQ( ros2_control_test_assets::minimal_robot_missing_state_keys_urdf, - test_controller->getRobotDescription()); + test_controller->get_robot_description()); } TEST_F(TestControllerManagerSrvs, configure_controller_srv)