Given that I’ve chosen the 2 PID option for drift management, why are the angles (integrated from the gyro angular speeds) still necessary?

Imagine Phoebe is horizontal, her X, Y, and Y axes aligns with the earth’s X, Y, and Z axes.

But imagine that she’s pitches over at an angle θ, and rolls over at an angle ψ in the Y plane. Then her X, Y, and Z axes do not align with the earth’s X, Y, and Z axes; readings from her accelerometers are relative to her axes, not those of the earth.

Now the “target”s for the horizontal and vertical speed PIDs make most sense in the earth space – for example vertical speed “target” = 0, horizonal speed “target”s (both X & Y) = 0 means a stable, non-drifting hover regardless of wind or other factors.

Therefore the PIDs controlling vertical and horizontal movement need to be fed sensor inputs converted from Phoebe’s space to the earth’s. And that’s where the angles come in.

Conversion of Phoebe’s X-axis sensor to the earth equivalent is like this – simply imagine a triangle between the 2 X axes – the value of movement compared to the earth is less than that detected by Phoebe thus:

Xe = Xp * cos(θ)

Likewise conversion of Phoebe’s y-axis sensor to the earth equivalent is like this:

Ye = Yp * cos(ψ)

Now given that Phoebe is tilting on both the X and Y axes compared to earth, the conversion from Phoebe’s Z axis accelerometer readings to the earth’s is like this:

Ze = Zp * cos(θ) * cos(ψ)

θ and ψ can both be inferred by integrating the gyro sensor outputs. However this use of angles between Phoebe’s and the earth’s spaces makes the accuracy of the angles critical. Integrated gyro output is good enough for short flights, but as flight lengths increase, rounding errors in the integration are likely to make the inferred angle increasingly wrong. That’s where Kalman filters or Complementary filters are used to limit this drift.

For now though, I think I have all the pieces of the jigsaw I need to solve wind-drift in short term flights, and as an added benefit, take-off from non-horizontal platforms, and controlled horizontal movement – I’ll leave Kalman / Complementary filters for another day.