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

[HW interface] Resource manager publish all Command-/StateInterface values #1244

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mamueluth
Copy link
Member

This adds publishing of all the values of the command-/stateInterfaces by the resource manager. Provides a kind of diagnostic interface. The values are published to /resource_manager_publisher_node/interface_values.
This PR depends on this PR from the control_msgs repos.

hardware_interface/src/resource_manager.cpp Outdated Show resolved Hide resolved
Comment on lines 1335 to 1349
try
{
const auto command_interface_value =
resource_storage_->command_interface_map_.at(command_interface_name).get_value();
command_interface_values.interface_names.push_back(command_interface_name);
command_interface_values.values.push_back(command_interface_value);
}
catch (const std::out_of_range & e)
{
RCUTILS_LOG_WARN_NAMED(
"resource_manager",
"command interface '%s' is in available list, but could not get the interface "
"command_interface_map_ (std::out_of_range exception thrown).",
command_interface_name.c_str());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you could avoid the cost of throwing-consuming an exception and just emit your log behind a key-exists-in-the-map check?

Suggested change
try
{
const auto command_interface_value =
resource_storage_->command_interface_map_.at(command_interface_name).get_value();
command_interface_values.interface_names.push_back(command_interface_name);
command_interface_values.values.push_back(command_interface_value);
}
catch (const std::out_of_range & e)
{
RCUTILS_LOG_WARN_NAMED(
"resource_manager",
"command interface '%s' is in available list, but could not get the interface "
"command_interface_map_ (std::out_of_range exception thrown).",
command_interface_name.c_str());
}
if (const auto iter = resource_storage_->command_interface_map_.find(command_interface_name); iter != resource_storage_->command_interface_map_.cend())
{
const auto command_interface_value =
*iter;
command_interface_values.interface_names.push_back(command_interface_name);
command_interface_values.values.push_back(command_interface_value);
}
else
{
RCUTILS_LOG_WARN_NAMED(
"resource_manager",
"command interface '%s' is in available list, but could not get the interface "
"command_interface_map_ (std::out_of_range exception thrown).",
command_interface_name.c_str());
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one. This also makes sense.
I would only change a bit the printed log a bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
How would you change it?

hardware_interface/src/resource_manager.cpp Outdated Show resolved Hide resolved
hardware_interface/src/resource_manager.cpp Show resolved Hide resolved
hardware_interface/src/resource_manager.cpp Outdated Show resolved Hide resolved
}
catch (const std::out_of_range & e)
{
RCUTILS_LOG_WARN_NAMED(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, do you think this should be throttled? or do you think it is fine to have like this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure about the performance penalty, but since this case should not happen under normal circumstances, i think its fine like this. But any thoughts/corrections are welcome.

Comment on lines 1335 to 1349
try
{
const auto command_interface_value =
resource_storage_->command_interface_map_.at(command_interface_name).get_value();
command_interface_values.interface_names.push_back(command_interface_name);
command_interface_values.values.push_back(command_interface_value);
}
catch (const std::out_of_range & e)
{
RCUTILS_LOG_WARN_NAMED(
"resource_manager",
"command interface '%s' is in available list, but could not get the interface "
"command_interface_map_ (std::out_of_range exception thrown).",
command_interface_name.c_str());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one. This also makes sense.
I would only change a bit the printed log a bit.

hardware_interface/src/resource_manager.cpp Show resolved Hide resolved
Copy link
Contributor

@livanov93 livanov93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment on the locking mechanism.

hardware_interface/src/resource_manager.cpp Outdated Show resolved Hide resolved
@bmagyar
Copy link
Member

bmagyar commented Jun 11, 2024

The messages were merged and released to Iron, Jazzy and Rolling ;)

Copy link
Contributor

mergify bot commented Aug 16, 2024

This pull request is in conflict. Could you fix it @mamueluth?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants