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(autoware_pid_longitudinal_controller): correct the PID controller #8118

Closed
wants to merge 23 commits into from

Conversation

HansOersted
Copy link
Contributor

@HansOersted HansOersted commented Jul 22, 2024

Description

The previous PID controller in Autoware is actually equivalent to a PD/PI controller.
This PR corrects the utilization of and upgrades to the PID controller.

N.B. Without specific reasons, the parameters adopted in the previous PD/PI controller are adopted in another PR. And the parameters in that PR are equivalent to the PD/PI controller.

Before change:
Screencast from 07-19-2024 02_05_57 PM.webm

After change:
Screencast from 07-19-2024 02_37_49 PM.webm


Note that one of the benefits of using implementing PID controllers is being robust to the external noise (e.g., driving on an ice road). Therefore, a noise was introduced artificially to test the PD/PI controller (before) and PID controller (after).

Noise definition: a constant acceleration (+1.0 m/s2), that is return feedback_acc + 1.0;.
Also, note the PID output constraint has been relaxted to max_out: 2.0, min_out: -2.0 in the analysis.

Before change:
Screencast from 07-19-2024 02_15_43 PM.webm

After change (with new parameters below)

kp: 1.5 # kp > 0 (stability proof) for third-order
ki: 0.8 # ki > 0 && Ki < kp * kd (stability proof) for third-order
kd: 2.5 # kd > 0 (stability proof) for third-order
Screencast.from.07-19-2024.04_26_14.PM.webm

N.B. In the parameter PR, we picked the parameters equivalent to the PI/PD controller.
It means that it will also show limit robustness to the external noise.


Conclusions:

  1. The previous PI/PD controller shows the logical error , which is fixed in this PR.
  2. The updated PID controller (this PR) works as expected in the normal case.
  3. The previous PI/PD controller can fail to track the reference once the external disturbance in introduced.
  4. The previous PI/PD controller successfully tracks the reference for some introduced external disturbances.

Further steps:

  1. The user may change the coefficients of the PID controller based on the concentrations and missions.
  2. The max P, I, and D constraints can be adjusted.
  3. The coefficients of the PID controller for a robust tracking performances can be analyzed.

Discussions:

  1. Honestly, erasing the integration when and only when the car is controlled manually is personally preferred. If latecomers have interests on this topic, do not hesitate to contact me.
  2. If you are trying to implement Discussion 1, consider using reset().

Tests performed

Effects on system behavior

Not applicable.

Interface changes

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.

After all checkboxes are checked, anyone who has write access can merge the PR.

@github-actions github-actions bot added the component:control Vehicle control algorithms and mechanisms. (auto-assigned) label Jul 22, 2024
Copy link

github-actions bot commented Jul 22, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@HansOersted HansOersted added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Jul 22, 2024
@HansOersted HansOersted marked this pull request as ready for review July 22, 2024 04:41
@HansOersted HansOersted force-pushed the jerk-based-pid branch 2 times, most recently from a8af174 to 25c964e Compare July 24, 2024 02:43
@kyoichi-sugahara
Copy link
Contributor

* @param [in] is_integrated if true, will use the integral component for calculation

doxygen comment also should be changed

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

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

Project coverage is 29.25%. Comparing base (7fe1e36) to head (0555ea5).
Report is 1229 commits behind head on main.

Files with missing lines Patch % Lines
...ware_pid_longitudinal_controller/test/test_pid.cpp 12.50% 0 Missing and 7 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8118   +/-   ##
=======================================
  Coverage   29.25%   29.25%           
=======================================
  Files        1600     1600           
  Lines      117736   117751   +15     
  Branches    50713    50707    -6     
=======================================
+ Hits        34438    34447    +9     
+ Misses      74098    74064   -34     
- Partials     9200     9240   +40     
Flag Coverage Δ *Carryforward flag
differential 17.79% <63.15%> (?)
total 29.25% <ø> (+<0.01%) ⬆️ Carriedforward from ceab242

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HansOersted
Copy link
Contributor Author

* @param [in] is_integrated if true, will use the integral component for calculation

doxygen comment also should be changed

fixed in 55f0787

Signed-off-by: Zhe Shen <[email protected]>
Signed-off-by: Zhe Shen <[email protected]>
Signed-off-by: Zhe Shen <[email protected]>
Signed-off-by: Zhe Shen <[email protected]>
Signed-off-by: Zhe Shen <[email protected]>
Signed-off-by: Zhe Shen <[email protected]>
@@ -1107,11 +1107,13 @@ double PidLongitudinalController::applyVelocityFeedback(const ControlData & cont
(vehicle_is_moving || (m_enable_integration_at_low_speed && vehicle_is_stuck)) &&
is_under_control;

const bool erase_integral = !enable_integration;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to use the negative enable_integration here?
Using enable_integration consistently is easier to understand the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 0555ea5

Copy link

stale bot commented Sep 27, 2024

This pull request has been automatically marked as stale because it has not had recent activity.

@stale stale bot added the status:stale Inactive or outdated issues. (auto-assigned) label Sep 27, 2024
@mitsudome-r
Copy link
Member

@HansOersted @takayuki5168 Do you still need this modification?

@takayuki5168
Copy link
Contributor

It will take time to confirm this PR including the real vehicle experiment and we don't have a plan for that, so let me close it for now.

@rej55 rej55 deleted the jerk-based-pid branch December 25, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:control Vehicle control algorithms and mechanisms. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) status:stale Inactive or outdated issues. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants