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

[PID] Add support for saving i-term when PID is reset #180

Open
wants to merge 17 commits into
base: ros2-master
Choose a base branch
from

Conversation

destogl
Copy link
Member

@destogl destogl commented Feb 11, 2024

Saves integral term on reset to maintain steady state offset output.
This is required for controlling of system without integral part to achieve correct steady-state output.
If intergral term is reset for some time there will be incorrect output in steady-state. This features avoids such situations and makes btter performance.

Whalex451 and others added 4 commits February 11, 2024 09:06
Added save_iterm_ to PID gains
Added save_iterm() and clear_saved_iterm() methods to update and clear save integral term
Cleared saved integral term in constructor
Called save_iterm() in reset() method
Added saved integral term to PID output
Simplified saving of integral term
Copy link

@olivier-stasse olivier-stasse left a comment

Choose a reason for hiding this comment

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

LGTM

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.

There is no test if this parameter has the desired effect. Could you please add any? e.g., to gainSettingCopyPIDTest or add a new one..

@codecov-commenter
Copy link

codecov-commenter commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 6 lines in your changes missing coverage. Please review.

Project coverage is 75.02%. Comparing base (6611872) to head (410c61d).

Files with missing lines Patch % Lines
src/pid_ros.cpp 45.45% 6 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           ros2-master     #180      +/-   ##
===============================================
+ Coverage        74.88%   75.02%   +0.13%     
===============================================
  Files               24       24              
  Lines             1107     1133      +26     
  Branches            86       89       +3     
===============================================
+ Hits               829      850      +21     
- Misses             231      236       +5     
  Partials            47       47              
Flag Coverage Δ
unittests 75.02% <81.81%> (+0.13%) ⬆️

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

Files with missing lines Coverage Δ
include/control_toolbox/pid.hpp 77.77% <ø> (ø)
include/control_toolbox/pid_ros.hpp 100.00% <ø> (ø)
src/pid.cpp 93.24% <100.00%> (+0.59%) ⬆️
test/pid_parameters_tests.cpp 100.00% <100.00%> (ø)
test/pid_publisher_tests.cpp 95.23% <100.00%> (ø)
test/pid_tests.cpp 100.00% <100.00%> (ø)
src/pid_ros.cpp 71.03% <45.45%> (-1.38%) ⬇️

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 added a test for this functionality to integralOnlyTest

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.

The changes in the PR look fine to me, just some minor changes here

Apart from that, just a conceptual question. I'm not sure if the save_i_term should be the part of the Gains itself or it should be a parameter to the reset method alone. If everyone is happy with the original choice, I'm fine with it.

src/pid.cpp Outdated Show resolved Hide resolved
src/pid.cpp Outdated Show resolved Hide resolved
Co-authored-by: Sai Kishor Kothakota <[email protected]>
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 applied the changes requested by @saikishor and had a focus on not breaking ABI -> check is green -> we can merge that into jazzy imho.

saikishor
saikishor previously approved these changes Jan 23, 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.

In general, LGTM

include/control_toolbox/pid.hpp Show resolved Hide resolved
include/control_toolbox/pid_ros.hpp Show resolved Hide resolved
include/control_toolbox/pid_ros.hpp Outdated Show resolved Hide resolved
src/pid.cpp Outdated
Comment on lines 96 to 100
// If last integral error is already zero, just return
if (std::abs(i_error_) < std::numeric_limits<double>::epsilon())
{
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this check?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe not? it does not take more effort to just zero it.

Copy link
Contributor

Choose a reason for hiding this comment

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

in the earlier version we had to use the RT buffer here, that's why

Copy link
Member

Choose a reason for hiding this comment

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

Got it

src/pid.cpp Outdated Show resolved Hide resolved
Co-authored-by: Sai Kishor Kothakota <[email protected]>
@christophfroehlich christophfroehlich dismissed stale reviews from saikishor and themself via 410c61d January 23, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants