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

Integrate pal_statistics for introspection of controllers, hardware components and more #1918

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

Conversation

saikishor
Copy link
Member

Added integration of pal_statistics into the ros2_control infrastructure

You can find more examples at #1897

image

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 88.60%. Comparing base (4ad5709) to head (5f91488).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...re_interface/include/hardware_interface/handle.hpp 50.00% 3 Missing and 3 partials ⚠️
hardware_interface/src/resource_manager.cpp 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1918      +/-   ##
==========================================
- Coverage   88.61%   88.60%   -0.01%     
==========================================
  Files         122      122              
  Lines       13304    13357      +53     
  Branches     1207     1215       +8     
==========================================
+ Hits        11789    11835      +46     
- Misses       1062     1064       +2     
- Partials      453      458       +5     
Flag Coverage Δ
unittests 88.60% <87.50%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...controller_interface/controller_interface_base.hpp 92.30% <ø> (ø)
...roller_interface/src/controller_interface_base.cpp 88.57% <100.00%> (+6.09%) ⬆️
.../include/controller_manager/controller_manager.hpp 100.00% <ø> (ø)
controller_manager/src/controller_manager.cpp 76.12% <100.00%> (-0.24%) ⬇️
.../include/hardware_interface/actuator_interface.hpp 92.24% <100.00%> (+0.27%) ⬆️
...ce/include/hardware_interface/sensor_interface.hpp 95.65% <100.00%> (+0.26%) ⬆️
...ce/include/hardware_interface/system_interface.hpp 82.35% <100.00%> (+0.53%) ⬆️
hardware_interface/src/actuator.cpp 81.29% <100.00%> (+0.62%) ⬆️
hardware_interface/src/sensor.cpp 76.98% <100.00%> (+0.95%) ⬆️
hardware_interface/src/system.cpp 81.29% <100.00%> (+0.62%) ⬆️
... and 2 more

... and 1 file with indirect coverage changes

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

I could write an AI agent commenting on PRs 😆

  • Please update the docs
  • Please update the release_notes

@saikishor
Copy link
Member Author

I could write an AI agent commenting on PRs 😆

  • Please update the docs
  • Please update the release_notes

Sure! Boss 😆😆

Copy link
Contributor

mergify bot commented Dec 7, 2024

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

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Thanks! I tested this successfully and discussed some details with Sai, just add some notes here:

  • pal_statistics name/values pair is parsed by plotjuggler to be able to select the values by name without a custom message layout/no need for sending the names on a regular basis.

https://github.com/facontidavide/PlotJuggler/blob/b1ad0896844e848c2495e09a6e5c3548685adedd/plotjuggler_plugins/ParserROS/ros_parser.cpp#L81-L90

I added some minor comments below.

hardware_interface/package.xml Outdated Show resolved Hide resolved
doc/debugging.rst Outdated Show resolved Hide resolved
doc/debugging.rst Outdated Show resolved Hide resolved
doc/debugging.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Approving as we have fixed clang now.

.github/workflows/jazzy-semi-binary-build.yml Outdated Show resolved Hide resolved
.github/workflows/rolling-semi-binary-build.yml Outdated Show resolved Hide resolved
@saikishor
Copy link
Member Author

Approving as we have fixed clang now.

Thank you @christophfroehlich

Copy link
Contributor

mergify bot commented Dec 20, 2024

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

Copy link

@MarqRazz MarqRazz left a comment

Choose a reason for hiding this comment

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

Thanks for detailed answers @saikishor, I think this looks like a great addition!

@saikishor
Copy link
Member Author

Thanks for detailed answers @saikishor, I think this looks like a great addition!

Thanks to you for taking time and reviewing it

@saikishor saikishor force-pushed the integrate/pal_statistics branch from b9d892c to 90d12f2 Compare December 20, 2024 23:33
@saikishor
Copy link
Member Author

Conflicts resolved! ;)

@saikishor saikishor force-pushed the integrate/pal_statistics branch from 90d12f2 to da34b78 Compare December 30, 2024 15:15
Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
@saikishor saikishor force-pushed the integrate/pal_statistics branch from da34b78 to aa19ef9 Compare December 31, 2024 10:16
Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

A few comments to clarify before continuing.

@@ -26,6 +26,7 @@
#include "hardware_interface/loaned_command_interface.hpp"
#include "hardware_interface/loaned_state_interface.hpp"

#include "pal_statistics/pal_statistics_utils.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

This adds a new dependency to almost everything. Should we at first have this removed by on compiler flags and one can enable it if required.

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 think the change is minimal, or may be I can add it to the hardware_interface/introspection and add it eveywhere, that way it is minimal

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

@@ -283,6 +284,8 @@ ControllerManager::ControllerManager(
init_controller_manager();
}

ControllerManager::~ControllerManager() { CLEAR_ALL_REGISTRIES(); }
Copy link
Member

Choose a reason for hiding this comment

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

I am not a fan of global macros if those are not required. If this is the only way, OK, but then I would propose to have a more explicit name, e.g., CLEAR_ALL_INTROSPECTION_REGISTRIES.

Copy link
Member Author

Choose a reason for hiding this comment

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

This global macro is from PAL statistics. The macros are added for simplistic integration. May be I can add another macro, that can call 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.

Done. I added more explicit name as you requested

@@ -321,6 +324,10 @@ void ControllerManager::init_controller_manager()
diagnostics_updater_.add(
"Controller Manager Activity", this,
&ControllerManager::controller_manager_diagnostic_callback);
INITIALIZE_REGISTRY(
Copy link
Member

Choose a reason for hiding this comment

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

Also here, can we do this on an object? If not, can we rename this to INITIALIZE_INTROSPECTION_REGISTRY?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is from the PAL statistics. I'm not sure that this can be renamed :(

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. I've also changed this and others

doc/introspection.rst Outdated Show resolved Hide resolved
@@ -93,7 +94,7 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
*/
ActuatorInterface(const ActuatorInterface & other) = delete;

ActuatorInterface(ActuatorInterface && other) = default;
ActuatorInterface(ActuatorInterface && other) = delete;
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to delete this constructor? It is obviously not used, but if this is the reason for deletion, then why not do this in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

Copy link
Member Author

Choose a reason for hiding this comment

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

@destogl I just checked the code. This is a part of the change as the pal_statistics::RegistrationsRAII stats_registrations_ is non moveable. As we already deleted the copies, I think it makes sense to remove the move operations as well

hardware_interface/include/hardware_interface/handle.hpp Outdated Show resolved Hide resolved
hardware_interface/include/hardware_interface/handle.hpp Outdated Show resolved Hide resolved
rclcpp::get_logger("command_interface"), "Registering handle: " << get_name());
std::function<double()> f = [this]()
{ return value_ptr_ ? *value_ptr_ : std::numeric_limits<double>::quiet_NaN(); };
REGISTER_ENTITY(DEFAULT_REGISTRY_KEY, "command_interface." + get_name(), f);
Copy link
Member

Choose a reason for hiding this comment

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

Kind or too generic name. I understand this is from the pal_statistics, but maybe we can sub-specify it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

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'll take a look at it

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it with specific naming

{
RCLCPP_INFO_STREAM(
rclcpp::get_logger("command_interface"), "Unregistering handle: " << get_name());
UNREGISTER_ENTITY(DEFAULT_REGISTRY_KEY, "command_interface." + get_name());
Copy link
Member

Choose a reason for hiding this comment

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

Kind of too generic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, PAL statistics uses that. I'll what I can do wiht it

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. Also changed it to be more generic

saikishor and others added 2 commits January 1, 2025 20:14
Copy link
Member Author

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

@destogl Thanks for the review.

I've addressed all your comments in the PR.

@@ -26,6 +26,7 @@
#include "hardware_interface/loaned_command_interface.hpp"
#include "hardware_interface/loaned_state_interface.hpp"

#include "pal_statistics/pal_statistics_utils.hpp"
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

@@ -283,6 +284,8 @@ ControllerManager::ControllerManager(
init_controller_manager();
}

ControllerManager::~ControllerManager() { CLEAR_ALL_REGISTRIES(); }
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. I added more explicit name as you requested

@@ -321,6 +324,10 @@ void ControllerManager::init_controller_manager()
diagnostics_updater_.add(
"Controller Manager Activity", this,
&ControllerManager::controller_manager_diagnostic_callback);
INITIALIZE_REGISTRY(
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. I've also changed this and others

hardware_interface/include/hardware_interface/handle.hpp Outdated Show resolved Hide resolved
rclcpp::get_logger("command_interface"), "Registering handle: " << get_name());
std::function<double()> f = [this]()
{ return value_ptr_ ? *value_ptr_ : std::numeric_limits<double>::quiet_NaN(); };
REGISTER_ENTITY(DEFAULT_REGISTRY_KEY, "command_interface." + get_name(), f);
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it with specific naming

hardware_interface/include/hardware_interface/handle.hpp Outdated Show resolved Hide resolved
{
RCLCPP_INFO_STREAM(
rclcpp::get_logger("command_interface"), "Unregistering handle: " << get_name());
UNREGISTER_ENTITY(DEFAULT_REGISTRY_KEY, "command_interface." + get_name());
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. Also changed it to be more generic

@saikishor saikishor requested a review from destogl January 1, 2025 20:18
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.

4 participants