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

Modify resource manager logic to support multiple hardware components #1391

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,7 @@ bool ResourceManager::prepare_command_mode_switch(
auto call_prepare_mode_switch =
[&start_interfaces, &stop_interfaces, &interfaces_to_string](auto & components)
{
size_t count = 0;
bool ret = true;
for (auto & component : components)
{
Expand All @@ -1162,8 +1163,12 @@ bool ResourceManager::prepare_command_mode_switch(
component.get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
{
if (
return_type::OK !=
return_type::OK ==
component.prepare_command_mode_switch(start_interfaces, stop_interfaces))
{
++count;
}
else
{
RCUTILS_LOG_ERROR_NAMED(
"resource_manager",
Expand All @@ -1173,7 +1178,7 @@ bool ResourceManager::prepare_command_mode_switch(
}
}
}
return ret;
return ret || (count > 0);
};

const bool actuators_result = call_prepare_mode_switch(resource_storage_->actuators_);
Expand All @@ -1195,6 +1200,7 @@ bool ResourceManager::perform_command_mode_switch(

auto call_perform_mode_switch = [&start_interfaces, &stop_interfaces](auto & components)
{
size_t count = 0;
bool ret = true;
for (auto & component : components)
{
Expand All @@ -1203,8 +1209,12 @@ bool ResourceManager::perform_command_mode_switch(
component.get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
{
if (
return_type::OK !=
return_type::OK ==
component.perform_command_mode_switch(start_interfaces, stop_interfaces))
{
++count;
}
else
{
RCUTILS_LOG_ERROR_NAMED(
"resource_manager", "Component '%s' could not perform switch",
Expand All @@ -1213,7 +1223,7 @@ bool ResourceManager::perform_command_mode_switch(
}
}
}
return ret;
return ret || (count > 0);
};

const bool actuators_result = call_perform_mode_switch(resource_storage_->actuators_);
Expand Down
Loading