Quadcopter PID Control: Is it possible to stabilize a quadcopter considering only angle measurements?

Good day,

I am a student currently working on an autonomous quadcopter project, specifically the stabilization part as of now. I am using a tuned propeller system and I also already considered the balancing of the quadcopter during component placements. I had been tuning the PID's of my quadcopter for the past 3 1/2 weeks now and the best I've achieved is a constant angle oscillation of the quadcopter by +-10 degrees with 0 degrees as the setpoint/desired angle. I also tried a conservative 7 degrees setpoint with the same results on the pitch axis.

As of now my PID code takes in the difference of the angle measurement from the complementary filter ( FilteredAngle=(0.98)*(FilteredAngle + GyroAngleVel*dt) + (0.02)*(AccelAngle) ) and the desired angle.

I have read somewhere that it is IMPOSSIBLE to stabilize the quadcopter utilizing only angle measurements, adding that the angular rate must be also taken into consideration. But I have read a lot of works using only a single pid loop with angle differences (Pitch Yaw and Roll) as the input.

In contrast to what was stated above, I have read a comment from this article (https://www.quora.com/What-is-rate-and-stabilize-PID-in-quadcopter-control) by Edouard Leurent that a Single PID control loop only angle errors and a Cascaded PID loop (Angle and Rate) that utilizes both angle errors and angular velocity errors are equivalent Mathematically.

If I were to continue using only the Single PID loop (Angle) method, I would only have to tune 3 parameters (Kp, Ki & Kd).

But if I were to change my code to utilize the Cascaded Loop (Angle and Angular Velocity),

1. Would I have to tune two sets of the 3 parameters (Kp, Ki & Kd for angle and Kp, Ki & Kd for the angular velocity)?
2. Would the cascaded PID control loop give better performance than the single PID control loop?
3. In the Cascaded Loop, is the set point for the angular velocity for stabilized flight also 0 in deg/sec? What if the quadcopter is not yet at its desired angle?

Thank you :)

• I am also using a 100Hz sampling rate for my control loop – user123456098 Jan 15 '16 at 7:16
• Regarding your cascading PID controllers, I would ask you to consider a thought experiment. What if you commanded angular position to be a constant value, but also commanded angular velocity to be a constant, non-zero value? Would the system obey the angular position and set velocity to zero, or would it obey angular velocity and allow angular position to move to infinity? You can't control both, you can only control one and the other will do what the controlled signal requires. PID controllers use position because velocity can be limited (not controlled) by PID gains - damping, settling, etc. – Chuck Jan 15 '16 at 15:43
• just keep trying that's the way I fix things. – hunt Jan 15 '16 at 17:32
• This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. - From Review – Josh Vander Hook Jan 15 '16 at 18:33
• That would wind up with the controllers "fighting". The only way to get to zero position error is... to get there. That is, there has to be some speed approaching zero in order to ever arrive at zero. If you just switch controllers the moment you hit zero, then you'll be acting to stay at zero speed despite the fact that inertia will pull you past zero angular error. – Chuck Mar 19 '16 at 15:20

It is possible to stabilize a quadcopter using only angle measurements in a single loop pid. However it is easier to stabilize a quadcopter using a cascaded PID controller. Yes you are tuning more parameters. Firstly you tune first the inner loop rate PID controller using the gyroscope's (the fast sensor, but drifts) angular rate readings then tune the outer loop stabilize PID using an angle setpoint and angle measurements from the sensor fusion of the angle readings from both the accelerometer and the angles integrated from the angular velocity readings from the gyroscope. I found that it was the easiest way to achieve stable flight coupled with my now current control loop rate of 530Hz.

Resources:

How are you managing to get any angle from the code you posted, filter = (0.98*gyro*dt + 0.02*accel)? Gyro output is in $\mbox{deg}/s$, where acceleration is $\mbox{deg}/s^2$. When you multiply gyro times time, you get an angle unit, $\mbox{deg}$, (not an angle, see below) but then you're adding that to an acceleration, which doesn't have the correct units.

Also, for the gyro portion, you're just getting to the correct units. Angular position is the integral of angular velocity, meaning that you have to sum those gyro*dt segments to accumulate an angle. Otherwise all gyro*dt gives you is the angle that you moved in the last time interval dt.

Can you check if your code matches what you wrote in the question and then update the question?

:EDIT:

My question wasn't about how you're calculating the accel values, but instead about how you're implementing the filter. In your update, the filter calculation is still incorrect.

Now, instead of getting your gyro output to angular position units, you've gone the other way and gotten to angular acceleration units. Worse, you're also now accumulating that acceleration, which doesn't make sense.

What you should have somewhere in the initialization portion of your code is:

gyro<AXIS>Position = 0;
accelerometer<AXIS>Position = 0;
accelerometer<AXIS>Velocity = 0;


Then, in your loop, update the accelerometer-based angular velocity by numerical integration:

accelerometer<AXIS>Velocity = accelerometer<AXIS>Velocity + accel<AXIS>*dt;


Next, numerically integrate the gyro angular velocity and the accelerometer-based angular velocity:

accelerometer<AXIS>Position = accelerometer<AXIS>Position + accelerometer<AXIS>Velocity*dt;
gyro<AXIS>Position = gyro<AXIS>Position + gyro<AXIS>*dt;


blend = 0.98;