Edited for clarity and organization: September 30, 2011
This discussion goes over the various tips I've picked up going over tuning PID and FLC (fuzzy logic) controllers for a quadrotor device.
Regardless of which type of controller your using, you MUST use some sort of algorithm that will limit how fast the quad will turn! This will give the slower angle error controller a chance to stabelize the craft.
That being said, something like a PD can be used, or a combination PI + d(PI), in which another PI is used to control the angle rate. FLC's may be able to operate by claculating the difference between the current error signal and the previous error signal, but this has its own quirks...
After trying to help someone that goes by Chris here with his quad, I came across a tuning method for PID's:
- Set your quad up onto some sort of test rig, so that it can only tilt in one direction. Depending on the software used, you might be able to do this just once and be done with it, or you might have to change the orientation of the Quad and tune all three axiis.
- Determine a PD combination for Kp and Kd (with Ki zero'd) that gives you an acceptable rate to an abrupt change in angle. You can simulate this on your quad by giving it a sharp tap on one end (don't put alot of force into it, just enough to make it tilt quickly).
- Determine a PI combination (keep the same P used in PD) for Kp and Ki (with Kd zero'd) that gives you an acceptable steady state error. This error is basically the mathematical difference between the desired final value (0 degrees for our testing) and what the craft actually achieves.
- Combine the constants used for the PD and PI using the following math formulas:
Eq_PD * Eq_PI = P^2 * (s + D) * (s + I) / s
= P^2 * (s^2 + (I + D)s + (I * D) ) / s
comparing this to Eq_PID gives:
Kd = P^2;
Kp = P^2 * (I + D);
Ki = P^2 * I * D;
Where P is the Kp for your PD and PI combinations, I is the Ki for your PI combination, and D is the Kd for your PD combination. You'll have to disable the D and I terms (set 'em to zero) and find a P that will give you an underdamped response... in other words the oscillations will eventually die down.
The Kd, Kp, and Ki in the last three equations will be (or really close to) what values you need.
NOTE: I haven't been able to verify these equations yet, so use at your own risk!!!1
Fuzzy Logic Controller Essentials:
If you didn't know this already, there are two common type of FLC's: Mamdani and Sugeno.
Mamdani types are the "standard" FLC's, in which they have membership shapes for both their input and output. De-fuzzification of the output fuzzy variables are done by using a center-of gravity method.
Sugeno types are the "simplified" FLC's, in which they only have membership shapes for the input. The output fuzzy variables are represented as singletons, and defuzzification is done by a much simplier weighted average method.
- Sugeno types are less-intuitive than Mamdani types, since the output fuzzy variables are "partially" defuzzified to a degree.
- Sugeno output curves are very relient upon the input membership shapes. Piece-wise linear memberships (particularely trapazoids) leave "ledges" near their centroid, which can effect calculations. This can be partially mitigated by using non-linear memberships such as gaussian curves.
Depending on your setup, the FLC may be tuned just like a PID system by starting off with 3-triangles per compensator.
- Essentially, modifiy the output "gain" until the craft's oscillations no longer grows, but does not decay.
- Then, gradually transition from triangle functions to trapazoids (or gaussian if applicable) by keeping the outside shapes as triangles.
- Add more shapes to the functions as needed.
- If your using Sugeno type FLC's remember that your output shape is sensitive to ledges. Ideally, you'd want only one significant ledge around the 0 change area.
NOTE: I'm in the process of verifying this method, so I'll let you know of any changes.