Skip to content

Commit 2041a87

Browse files
saikishormergify[bot]
authored andcommitted
Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (#1451)
(cherry picked from commit 25f2c97) # Conflicts: # hardware_interface/src/resource_manager.cpp
1 parent bbd7058 commit 2041a87

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hardware_interface/src/resource_manager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,13 @@ void ResourceManager::load_urdf(
764764
const std::string sensor_type = "sensor";
765765
const std::string actuator_type = "actuator";
766766

767+
<<<<<<< HEAD
767768
const auto hardware_info = hardware_interface::parse_control_resources_from_urdf(urdf);
768769
if (load_and_initialize_components)
770+
=======
771+
std::lock_guard<std::recursive_mutex> resource_guard(resources_lock_);
772+
for (const auto & individual_hardware_info : hardware_info)
773+
>>>>>>> 25f2c97 (Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (#1451))
769774
{
770775
for (const auto & individual_hardware_info : hardware_info)
771776
{
@@ -1287,6 +1292,7 @@ return_type ResourceManager::set_component_state(
12871292
return false;
12881293
};
12891294

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

0 commit comments

Comments
 (0)