Skip to content

Commit

Permalink
Add get_urdf method for the ResourceManager
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Jan 9, 2025
1 parent efa76b3 commit 5b00b44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ ControllerManager::ControllerManager(
chainable_loader_(
std::make_shared<pluginlib::ClassLoader<controller_interface::ChainableControllerInterface>>(
kControllerInterfaceNamespace, kChainableControllerInterfaceClassName)),
cm_node_options_(options)
cm_node_options_(options),
robot_description_(resource_manager_->get_urdf())
{
initialize_parameters();
init_controller_manager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down
9 changes: 8 additions & 1 deletion hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,8 @@ class ResourceStorage
joint_limits::JointLimiterInterface<joint_limits::JointControlInterfacesData>>>>
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;
Expand All @@ -1138,6 +1140,7 @@ ResourceManager::ResourceManager(
const unsigned int update_rate)
: resource_storage_(std::make_unique<ResourceStorage>(clock_interface, logger_interface))
{
resource_storage_->robot_description_ = urdf;
load_and_initialize_components(urdf, update_rate);

if (activate_all)
Expand 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);
Expand Down Expand Up @@ -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(); }
Expand Down

0 comments on commit 5b00b44

Please sign in to comment.