Skip to content

Commit

Permalink
add resources lock at the beginning of the method
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Mar 18, 2024
1 parent 178a6c8 commit 7dca6a2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,23 +767,22 @@ void ResourceManager::load_urdf(
const auto hardware_info = hardware_interface::parse_control_resources_from_urdf(urdf);
if (load_and_initialize_components)
{
std::lock_guard<std::recursive_mutex> resources_guard(resources_lock_);
for (const auto & individual_hardware_info : hardware_info)
{
if (individual_hardware_info.type == actuator_type)
{
std::scoped_lock guard(
resources_lock_, resource_interfaces_lock_, claimed_command_interfaces_lock_);
std::scoped_lock guard(resource_interfaces_lock_, claimed_command_interfaces_lock_);
resource_storage_->load_and_initialize_actuator(individual_hardware_info);
}
if (individual_hardware_info.type == sensor_type)
{
std::scoped_lock resources_guard(resources_lock_, resource_interfaces_lock_);
std::scoped_lock guard(resource_interfaces_lock_);
resource_storage_->load_and_initialize_sensor(individual_hardware_info);
}
if (individual_hardware_info.type == system_type)
{
std::scoped_lock guard(
resources_lock_, resource_interfaces_lock_, claimed_command_interfaces_lock_);
std::scoped_lock guard(resource_interfaces_lock_, claimed_command_interfaces_lock_);
resource_storage_->load_and_initialize_system(individual_hardware_info);
}
}
Expand Down

0 comments on commit 7dca6a2

Please sign in to comment.