Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resources_lock_ lock_guards to avoid race condition when loading robot_description through topic (backport #1451) #1600

Open
wants to merge 6 commits into
base: iron
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ 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> resource_guard(resources_lock_);
for (const auto & individual_hardware_info : hardware_info)
{
if (individual_hardware_info.type == actuator_type)
Expand Down Expand Up @@ -1287,6 +1288,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
Loading