From 5b00b44bc9bc76a6fa8c6d44795e80b84ea1f821 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Fri, 10 Jan 2025 00:43:25 +0100 Subject: [PATCH] Add `get_urdf` method for the ResourceManager --- controller_manager/src/controller_manager.cpp | 3 ++- .../include/hardware_interface/resource_manager.hpp | 2 ++ hardware_interface/src/resource_manager.cpp | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 08cebdad09..4e14eb209c 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -278,7 +278,8 @@ ControllerManager::ControllerManager( chainable_loader_( std::make_shared>( kControllerInterfaceNamespace, kChainableControllerInterfaceClassName)), - cm_node_options_(options) + cm_node_options_(options), + robot_description_(resource_manager_->get_urdf()) { initialize_parameters(); init_controller_manager(); diff --git a/hardware_interface/include/hardware_interface/resource_manager.hpp b/hardware_interface/include/hardware_interface/resource_manager.hpp index cd759a96e4..efadf53528 100644 --- a/hardware_interface/include/hardware_interface/resource_manager.hpp +++ b/hardware_interface/include/hardware_interface/resource_manager.hpp @@ -471,6 +471,8 @@ class ResourceManager */ bool state_interface_exists(const std::string & key) const; + const std::string & get_urdf() const; + protected: /// Gets the logger for the resource manager /** diff --git a/hardware_interface/src/resource_manager.cpp b/hardware_interface/src/resource_manager.cpp index e2f1110206..f5bf36a4f0 100644 --- a/hardware_interface/src/resource_manager.cpp +++ b/hardware_interface/src/resource_manager.cpp @@ -1118,6 +1118,8 @@ class ResourceStorage joint_limits::JointLimiterInterface>>> joint_limiters_interface_; + std::string robot_description_; + // Update rate of the controller manager, and the clock interface of its node // Used by async components. unsigned int cm_update_rate_ = 100; @@ -1138,6 +1140,7 @@ ResourceManager::ResourceManager( const unsigned int update_rate) : resource_storage_(std::make_unique(clock_interface, logger_interface)) { + resource_storage_->robot_description_ = urdf; load_and_initialize_components(urdf, update_rate); if (activate_all) @@ -1157,6 +1160,7 @@ bool ResourceManager::load_and_initialize_components( { components_are_loaded_and_initialized_ = true; + resource_storage_->robot_description_ = urdf; resource_storage_->cm_update_rate_ = update_rate; auto hardware_info = hardware_interface::parse_control_resources_from_urdf(urdf); @@ -2056,7 +2060,10 @@ bool ResourceManager::state_interface_exists(const std::string & key) const return resource_storage_->state_interface_map_.find(key) != resource_storage_->state_interface_map_.end(); } - +const std::string & ResourceManager::get_urdf() const +{ + return resource_storage_->robot_description_; +} // END: "used only in tests and locally" rclcpp::Logger ResourceManager::get_logger() const { return resource_storage_->get_logger(); }