-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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 implementation - Parallel vs Ideal #12362
Comments
Very cool! Let's make sure we can execute on this on a fixed timeline. |
@jlecoeur It is important to note that we have protected against large I gains with this commit, so tuning can now include a large I gain: I would also argue that a lot of airframe configs here would not stand an evaluation on what we consider "great performance", as we find that community-provided tuning values are hit-and-miss. My take-away is that we need to centralize these configs and make sure we have the same scrutiny on them as we have on code changes. |
@jlecoeur Thanks for your input and the graphs. Yes, there is a quite clear linear relation between Kp and Kd.
(when I say "low integral", understand low 1/T1 or low Ki') In summary, the integral time constant is more correlated with the size of the vehicle than Kp. This is why in the table of my original post (sorted by increasing 1/T1), the VTOL plane is at the top, the medium size drones at the middle and the racers at the bottom while the Kp gains seem more random (even if a racer usually have a much higher thrust-to-weight ratio than other drones). I'll add a new variable for the "controller gain" with a default of 1.0 and try with different platforms to see if it's really easier to tune in practice. Since it only scales the other gains, there will be no visible changes for the current setups. |
@bresch sounds good! If it turns out that you often need to tune Kc and Ki separately then you may consider an "ideal-parallel" implementation where Kc scales both the proportional and derivactive actions, but not the integral action. |
@jlecoeur In fact you still want to Ki with Kc because this decouples the static part (pure gain) from the dynamic tuning (integral and derivative time constants). Intuitive example
Proof Edit: The equations were a bit oversimplified so I updated with more general and correct ones |
Very clear explanation, thank you! Looking forward to seeing the PR ;-) |
I wanted to discuss a bit in this issue the different types on PID controllers. The main reason is that I find the current implementation not intuitive to adjust manually.
Parallel:
This is the current implementation of the rate and velocity controllers in PX4. The specificity of that implementation is that the P, I and D path are independent. This sounds to be a good idea, but in practice it is not practical because modifying the proportional gain (P) changes the integral and derivatives actions. Consequence: both decreasing or increasing the P gain can destabilize the system because decreasing P increases the integral effect.
Ideal:
This implementation is widely used in commercial controller as it decouples the integral and derivative actions from the proportional gain: The gain of the controller is defined by the P gain, the integral action by its time constant Ti (or Ki' = 1/Ti) and the derivative action by Td (or Kd' = Td).
Describe problem solved by the proposed feature
Adjusting a parallel PID controller requires to modify all three gains together. This a a reason why the tuning sequence is "Set I and D to zero, tune P and D together and then add a bit of I to reduce the steady-state error." and that some vehicles are poorly tuned because "the integrator is scary".
Changing to the ideal form should make the tuning easier. In order to show why it is not intuitive, I collected some rate controller gains of the standard config files, computed the integral and derivative effects and plotted the integral effect with the Ki gain (scaled up) on the same graph.
On the graph, you can directly see that more Ki doesn't necessarily mean "more integral action".
Take for example the M100 and the Mid size quad 1: the M100 has 20% more integral action but it's Ki gain is three times smaller. Also, its derivative time constant is only 50% smaller even if Kd is 7 times smaller. This is simply because the proportional gain of those two vehicles are quite different, mainly due to different propulsion systems and inertia. Furthermore, Td is quite constant across the frames but Kd have to be tuned every time Kp changes.
I am convinced that a simple slider that changes the Kp' gain of an ideal PID would be enough to tune most of the vehicles.
Implementation
We can easily convert the actual algorithm into a Ideal form by introducing a "Controller gain" Kc that multiplies Kp, Ki and Kd. This Kc can then be mapped to a slider in QGC to increase or decrease the performance/robustness of the controller.
FYI: @bkueng
The text was updated successfully, but these errors were encountered: