Skip to content

Commit 79210b9

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 0a9529a commit 79210b9

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
@@ -684,8 +684,13 @@ void ResourceManager::load_urdf(
684684
const std::string sensor_type = "sensor";
685685
const std::string actuator_type = "actuator";
686686

687+
<<<<<<< HEAD
687688
const auto hardware_info = hardware_interface::parse_control_resources_from_urdf(urdf);
688689
if (load_and_initialize_components)
690+
=======
691+
std::lock_guard<std::recursive_mutex> resource_guard(resources_lock_);
692+
for (const auto & individual_hardware_info : hardware_info)
693+
>>>>>>> 25f2c97 (Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (#1451))
689694
{
690695
for (const auto & individual_hardware_info : hardware_info)
691696
{
@@ -1209,6 +1214,7 @@ return_type ResourceManager::set_component_state(
12091214
return false;
12101215
};
12111216

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

0 commit comments

Comments
 (0)