Skip to content

Commit

Permalink
Add resources_lock_ lock_guards to avoid race condition when loading …
Browse files Browse the repository at this point in the history
…robot_description through topic (#1451)

(cherry picked from commit 25f2c97)

# Conflicts:
#	hardware_interface/src/resource_manager.cpp
  • Loading branch information
saikishor authored and mergify[bot] committed Jul 1, 2024
1 parent bbd7058 commit 2041a87
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,13 @@ void ResourceManager::load_urdf(
const std::string sensor_type = "sensor";
const std::string actuator_type = "actuator";

<<<<<<< HEAD
const auto hardware_info = hardware_interface::parse_control_resources_from_urdf(urdf);
if (load_and_initialize_components)
=======
std::lock_guard<std::recursive_mutex> resource_guard(resources_lock_);
for (const auto & individual_hardware_info : hardware_info)
>>>>>>> 25f2c97 (Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (#1451))
{
for (const auto & individual_hardware_info : hardware_info)
{
Expand Down Expand Up @@ -1287,6 +1292,7 @@ return_type ResourceManager::set_component_state(
return false;
};

std::lock_guard<std::recursive_mutex> guard(resources_lock_);
bool found = find_set_component_state(
std::bind(&ResourceStorage::set_component_state<Actuator>, resource_storage_.get(), _1, _2),
resource_storage_->actuators_);
Expand Down

0 comments on commit 2041a87

Please sign in to comment.