Skip to content

Shift to Struct based Method and Constructors, with Executor passed from CM to on_init() #2323

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

Merged
merged 53 commits into from
Jun 25, 2025

Conversation

soham2560
Copy link
Contributor

@soham2560 soham2560 commented Jun 9, 2025

Brief

This addition is the first step towards solving #2141 (also #1732 in some way).
The concept is simple, we are creating a Struct pathway of sorts all the way from the CM to the on_init() call in the hardware component. This enables future additions without too harsh API/ABI breaks.

An example to show this currently is to give the user access to the MultiThreadedExecutor so that they can add nodes to it and publish if necessary by propogating the executor_ from CM all the way to on_init() (refer ab8d08c). A future PR will add a node by default with the hardware_components name

Three Structs have been added to help in the above

  • HardwareComponentInterfaceParams
    • To be passed in on_init() and parsed by user to get all relevant data (hardware_info and executor at this point)
  • HardwareComponentParams
    • To be used for all other initialisation, loading calls up till resource manager
  • ResourceManagerParams
    • To construct Resource Manager

Important Note

This means over time we will have to deprecate and remove the non struct based methods

Side Notes

  • This does mean we have to update the ros2_control_demos with the updated API
  • It is expected the user will lock and use the executor as needed
  • documentation is yet to be added, in particular about notifying the user to not abuse the executor (since they can use the cancel() call internally and cripple the services etc for the CM basically )

Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 23 lines in your changes missing coverage. Please review.

Project coverage is 88.99%. Comparing base (4d3362d) to head (c31cfac).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
hardware_interface/src/resource_manager.cpp 79.45% 11 Missing and 4 partials ⚠️
controller_manager/src/controller_manager.cpp 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2323      +/-   ##
==========================================
+ Coverage   88.96%   88.99%   +0.03%     
==========================================
  Files         144      147       +3     
  Lines       16634    16707      +73     
  Branches     1436     1433       -3     
==========================================
+ Hits        14799    14869      +70     
- Misses       1277     1283       +6     
+ Partials      558      555       -3     
Flag Coverage Δ
unittests 88.99% <83.33%> (+0.03%) ⬆️

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

Files with missing lines Coverage Δ
..._interface/include/hardware_interface/actuator.hpp 100.00% <ø> (ø)
.../include/hardware_interface/actuator_interface.hpp 91.30% <100.00%> (+0.34%) ⬆️
...re_interface/include/hardware_interface/sensor.hpp 100.00% <ø> (ø)
...ce/include/hardware_interface/sensor_interface.hpp 85.98% <100.00%> (+0.98%) ⬆️
...re_interface/include/hardware_interface/system.hpp 100.00% <ø> (ø)
...ce/include/hardware_interface/system_interface.hpp 84.80% <100.00%> (+0.53%) ⬆️
...face/types/hardware_component_interface_params.hpp 100.00% <100.00%> (ø)
...ware_interface/types/hardware_component_params.hpp 100.00% <100.00%> (ø)
...rdware_interface/types/resource_manager_params.hpp 100.00% <100.00%> (ø)
hardware_interface/src/actuator.cpp 80.61% <100.00%> (+0.61%) ⬆️
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@soham2560 soham2560 marked this pull request as ready for review June 9, 2025 10:50
Copy link
Member

@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.

A partial review here

I think as this is an API breaking change, we should open the corresponding PRs in the packages like gz_ros2_control and also webots_ros2_control probably? We can discuss this part when we finish the final review of this PR

@soham2560
Copy link
Contributor Author

soham2560 commented Jun 9, 2025

we should open the corresponding PRs in the packages like gz_ros2_control

@saikishor have added PR at ros-controls/gz_ros2_control#606

@saikishor
Copy link
Member

we should open the corresponding PRs in the packages like gz_ros2_control

@saikishor have added PR at ros-controls/gz_ros2_control#606

Awesome. Sorry I missed that one

@bmagyar
Copy link
Member

bmagyar commented Jun 22, 2025

Good renamings!

Copy link
Member

@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.

Partial review

Copy link
Member

@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.

Overall looks spot on! Just some nitpicks

Very very good job. Based on how it looks, we can even backport this to Jazzy, as there is no break of API.

saikishor
saikishor previously approved these changes Jun 25, 2025
Copy link
Member

@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.

LGTM

bmagyar
bmagyar previously approved these changes Jun 25, 2025
@bmagyar bmagyar added the backport-jazzy This label should be used by maintainers only! Label triggers PR backport to ROS 2 jazzy. label Jun 25, 2025
@soham2560 soham2560 dismissed stale reviews from bmagyar and saikishor via c31cfac June 25, 2025 11:11
Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

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

thank you!

@bmagyar bmagyar merged commit 8c52010 into ros-controls:master Jun 25, 2025
19 of 26 checks passed
mergify bot pushed a commit that referenced this pull request Jun 25, 2025
…rom CM to `on_init()` (#2323)

(cherry picked from commit 8c52010)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-jazzy This label should be used by maintainers only! Label triggers PR backport to ROS 2 jazzy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants