Skip to content

Commit

Permalink
added get_robot_description method to the base class
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Oct 23, 2023
1 parent 5f40b28 commit caef34d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/**
*
Expand Down
2 changes: 2 additions & 0 deletions controller_interface/src/controller_interface_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions controller_manager/test/test_controller/test_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions controller_manager/test/test_controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions controller_manager/test/test_controller_manager_srvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<controller_manager_msgs::srv::UnloadController::Request>();
Expand All @@ -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)
Expand Down

0 comments on commit caef34d

Please sign in to comment.