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

Allow global scaling of PD terms in multicopters #26620

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

Conversation

andyp1per
Copy link
Collaborator

From discussion with @lthall and @bnsgeyer

This makes it easy to raise or lower gains in a proportional manner.

@rmaia3d
Copy link
Contributor

rmaia3d commented Mar 26, 2024

This is a good idea!! Very much in line with the theory Mark Spatz (UAVTech) explains in this video:

https://www.youtube.com/watch?v=uN3JKYu5TLc

@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Mar 31, 2024
@IamPete1
Copy link
Member

IamPete1 commented Apr 1, 2024

Why not also scale I term? If the goal is to make it easier to setup would it be better to have a scale param in the PID object itself so it works for all PID loops?

@andyp1per
Copy link
Collaborator Author

Why not also scale I term? If the goal is to make it easier to setup would it be better to have a scale param in the PID object itself so it works for all PID loops?

@bnsgeyer only wanted PD

@bnsgeyer
Copy link
Contributor

bnsgeyer commented Apr 1, 2024

@andyp1per the way this is currently implemented. It is multicopter only. I guess you are letting me implement it for heli?

@bnsgeyer only wanted PD

The I term for heli’s is kept at a lower value and is not adjusted to be the same as the feedforward term. The I term is left at a small value to keep from causing roll over while on the ground.

@IamPete1
Copy link
Member

IamPete1 commented Apr 1, 2024

If the goal is to make it easy for users to setup then it probably should scale I term as well. Most users are not flying heli. Its still not 100% clear to me what the goal of this PR is?

@bnsgeyer
Copy link
Contributor

bnsgeyer commented Apr 1, 2024

@IamPete1 the goal is having the ability to scale based off of some other condition whether it be rotor speed, airspeed, or density altitude.

@IamPete1
Copy link
Member

IamPete1 commented Apr 1, 2024

@IamPete1 the goal is having the ability to scale based off of some other condition whether it be rotor speed, airspeed, or density altitude.

From scripting? Scripting can just as easily set two parameters as one. I think the benefit of only having to change one parameter is only really valid if its a user who is changing it manually.

@andyp1per
Copy link
Collaborator Author

Happy to scale I as well if the current params are multicopter only.

@bnsgeyer
Copy link
Contributor

bnsgeyer commented Apr 1, 2024

@IamPete1 i think having the hooks in the PID is good to haVe. I am not sure that I would make it a parameter available to users.

@andyp1per what you are proposing would affect all vehicles that use the PID. You only added parameters to multicopter. I guess that is what I meant but my comment. But now that I think of it, I probably would not add the parameters. Just want to use the scaling feature in the PID object. I guess we could add another scaling function that did PID rather than just PD.

// boost output if required
P_out *= boost;
D_out *= boost;
// scale output if required
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a user exposed parameter should we consider adding protection against negative values or 0.

@tridge
Copy link
Contributor

tridge commented Apr 1, 2024

if this changes P on multicopters and allows for lowering P and doesn't lower I then I think that is extremely dangerous. If you set the scale to 0.5 then you could get massive phase lag from I

@tridge
Copy link
Contributor

tridge commented Apr 1, 2024

I think we would need a thread in discord code_review channel to discuss, given we can't get all the key people on the same call

@lthall
Copy link
Contributor

lthall commented Apr 5, 2024

This PR was motivated by developers wanting to make it easier for people to back off their gains to make an aircraft a little more stable during tuning.

The normal approach is:

  • Tune D
  • Tune P
  • Set I = P
  • Evaluate
  • If we see signs of oscillation in a phase of flight, reduce P, I and D by the same factor to increase the stability margin.

My position on this has always been that people should be able to do the last step without an additional parameter but I understand that many developers feel that this would make it easier for people to tune this last step with a parameter and also easier for us as developers to support if this was the case.

The purpose of the Scale factor that Andy uses here is to allow a dynamic back off of the gains in known phases of flight where we expect to see oscillation or where we are turning a PID loop on in flight (quad plane). I intend to add a backoff for roll, pitch and yaw that will the oscillation on the ground before take-off.

For non-feedforward based control like multirotors the scale should do PID. However, I am not sure about heli. Maybe that would be PIDFF, PD, IFF, not sure.

To include these parameters that are fundamentally there only to save users from multiplying a couple numbers the consensus between developers needs to be a 100% slam dunk. I am not seeing anything close to that here.
I am starting to think this juice is not worth the squeeze.

@lthall lthall self-requested a review April 5, 2024 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WikiNeeded needs wiki update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants