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 0a9529a commit 79210b9
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 @@ -684,8 +684,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 @@ -1209,6 +1214,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 79210b9

Please sign in to comment.