Hi jack732,

In answer to your previous question about VTOL stability, my Arduino Micro based, 8-bit, flight controller managed to stablise a drone/multi-rotor with a modest update rate of around 250 updates (samples) per second. To achieve this, it sensed the angular rate and angles with gyroscope/accelerometer breakout board.

Might it be easier to consider using a simple gyroscope/accelerometer board to acquire the angle data, rather than using a Pixhawk 4?

Most gyroscope/accelerometer breakout boards employed for stabilisation, are capable of sample rates of around 1000Hz, increasing to around 8000Hz+ (for the gyroscope at least), if the anti-aliasing filter is turned off. Most modern flight control systems run at this higher rate with the filter turned off, providing their own custom software filtering instead.

Some gyroscope/accelerometer ICs also include a on-chip Digital Motion Processor (DMP) that can calculate the resultant roll and pitch angles, without having to resort to calculating all the mathematics in your code.

In answer to your question about dynamic acceleration affecting the angles. The Pixhawk 4 in common with other flight controllers, calculates the roll and pitch angles not only from the effect of gravity on the accelerometer (with a bit of trigonometry), but also from integrating the gyroscope over time.

A gyroscope measures angular rate (θ/s) in degrees per second, or alternatively in radians per second. In the same way that speed * time = distance, angular rate * time = angle. If you multiply the gyroscope angular rate by the microcontroller's loop() time, you'll get a tiny slither of angle. If you integrate by simply adding it to all the previous slithers of angle, you can also calculate the angle of the aircraft. The gyroscope however has an advantage over the accelerometer, in that the result is largely unaffected by dynamic acceleration.

In theory, you could just use the gyroscope to calculate the roll, pitch and yaw angles, however in the real world the gyroscope, while stable in the short term, suffers from long term drift. The accelerometer by contrast, while noisy and variable over the short term, is much more stable over a longer duration. The trick is to fuse the two sensors to get the best of both worlds, providing both short and long term stability. This is usually achieved using either a complementary, or (Extended) Kalman filter. These filters take around 99.9% of the integrated gyroscope output and fuse it with around 0.1% of accelerometer. The inclusion of the accelerometer corrects for the gyroscope drift.

Note that the fusion of the gyroscope and accelerometer only allows the roll and pitch angles to be calculated. If you require the yaw angle, you'll also need a magnetometer (compass) sensor and fuse that gyroscope's yaw axis.

By the way, the Mavlink is a protocol is designed for on screen display telemetry and probably isn't well suited to being used for flight control.