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

Fix controller parameter loading issue in different cases #1293

Merged

Conversation

saikishor
Copy link
Member

@saikishor saikishor commented Jan 13, 2024

Lately, we have had reports about issues with loading parameters by parsing the param file to the spawners. This didn't work sometimes because we were trying to initialize the GPL library in the init. When it tries to declare and get the parameters, as they are not available, it throws an exception as the validation sometimes fails (as in ros-controls/ros2_controllers#698 and ros-controls/ros2_controllers#795) (or) that we couldn't also use the read_only parameters in this case, and they need to exist upon the LifeCycleNode creation (ros-controls/ros2_controllers#966).

Upon taking a close look at the documentation, I think we can use the following approach to be able to properly set the parameters to the Node.

The following approach can be backported, however, in some cases that the controllers needs to override their NodeOptions for their particular use-case (as in some tests), this won't work as the default argument from the controller_interface_base.hpp will be overridden by the CM now. Inorder to properly fix this, we will need a part of this PR : #1169

Fixes: #1311
Fixes: ros-controls/ros2_controllers#966
Closes: ros-controls/ros2_controllers#795
Closes: PickNikRobotics/generate_parameter_library#156

Copy link

codecov bot commented Jan 13, 2024

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (71506d5) 47.87% compared to head (604c0eb) 47.68%.
Report is 14 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1293      +/-   ##
==========================================
- Coverage   47.87%   47.68%   -0.19%     
==========================================
  Files          41       41              
  Lines        3453     3477      +24     
  Branches     1878     1896      +18     
==========================================
+ Hits         1653     1658       +5     
- Misses        444      453       +9     
- Partials     1356     1366      +10     
Flag Coverage Δ
unittests 47.68% <17.24%> (-0.19%) ⬇️

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

Files Coverage Δ
.../include/controller_manager/controller_manager.hpp 18.18% <ø> (ø)
controller_manager/src/controller_manager.cpp 38.79% <17.24%> (-0.37%) ⬇️

@saikishor saikishor marked this pull request as ready for review January 14, 2024 21:03
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.

Looks very good to me :)

controller_manager/src/controller_manager.cpp Outdated Show resolved Hide resolved
controller_manager/src/controller_manager.cpp Show resolved Hide resolved
@christophfroehlich
Copy link
Contributor

Does it make a difference now if the ParamListener of GPL is created in the on_init or on_configure method? Do we have a clear solution for this PR?

@saikishor
Copy link
Member Author

Does it make a difference now if the ParamListener of GPL is created in the on_init or on_configure method? Do we have a clear solution for this PR?

Thanks for bringing it up. Nope, it doesn't make any difference at all. You can have it created anywhere in on_init or on_configure method. I believe this is exactly what we want.

Co-authored-by: Christoph Fröhlich <[email protected]>
@Noel215
Copy link
Contributor

Noel215 commented Jan 16, 2024

Hi,

I've reverted ros-controls/ros2_controllers#967 locally and backported the main functionality of this PR to humble (I needed to adapt it) in order to test it and it works for me. It solves ros-controls/ros2_controllers#966.

@christophfroehlich
Copy link
Contributor

Does it make a difference now if the ParamListener of GPL is created in the on_init or on_configure method? Do we have a clear solution for this PR?

Thanks for bringing it up. Nope, it doesn't make any difference at all. You can have it created anywhere in on_init or on_configure method. I believe this is exactly what we want.

fine. do we have a favorite in doing it in on_init or on_configure? Not sure if it is implemented in the same way with all controllers.

@saikishor
Copy link
Member Author

fine. do we have a favorite in doing it in on_init or on_configure? Not sure if it is implemented in the same way with all controllers.

@christophfroehlich I would favor the on_init, because in that way you still can change the parameters after loading the controller and then configure them. This is something that you brought up in some conversation, as this is very interesting to have.

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.

I generally agree with this, but I would suggest that we don't backport this but create separate PRs for humble and rolling. This one would be for humble and the breaking one for rolling.

Oh and BTW, don't we already have something like PIMPL, where controllers have only on_init. In that case, we should make init not overridable from now on, i.e., it should not be virtual. In this case, we don't break user API, but only internal one.

@destogl
Copy link
Member

destogl commented Jan 16, 2024

Hi,

I've reverted ros-controls/ros2_controllers#967 locally and backported the main functionality of this PR to humble (I needed to adapt it) in order to test it and it works for me. It solves ros-controls/ros2_controllers#966.

can you open PR please with this revert and write there that it should be merged when we have this functionality added.

destogl
destogl previously approved these changes Jan 22, 2024
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.

Thanks for following up!

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.

Looks good other than the refactor request

@saikishor saikishor dismissed stale reviews from christophfroehlich and destogl via 604c0eb January 22, 2024 23:27
@bmagyar bmagyar merged commit 5d4f6e7 into ros-controls:master Jan 23, 2024
14 of 15 checks passed
saikishor added a commit to saikishor/ros2_control that referenced this pull request Jan 23, 2024
saikishor added a commit to saikishor/ros2_control that referenced this pull request Jan 23, 2024
saikishor added a commit to saikishor/ros2_control that referenced this pull request Jan 23, 2024
@saikishor saikishor deleted the fix_controller_parameter_loading_issue branch August 17, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants