Go Down

Topic: does pixhawk update its angles based off airspeed sensor data? (Read 217 times) previous topic - next topic


Hey guys,
Does the pixhawk update the angles (that can be sent over to an arduino via mavlink) when it receives data from an airspeed sensor?
In other words, the angles should get messed up if you induce a high amount of dynamic acceleration, an airspeed sensor would be able to see this acceleration and send information about it to the pixhawks angle calculating algorithm and I would hope it uses it to update the angle output to what they truly are. This way you could feed sustained-acceleration compensated angles to an arduino.
"Hey! How--ah these pretzels suck... How's your day been buddy?"


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.


Thanks for your reply martin,

And thanks for all that great info!

The reason I'm not using a gyro-accel algorithm (whether it be done by the arduino or a DMP) to attain angles is because every filter that I've tried (that only utilizes these two sensors) has succumbed to great inaccuracy when subjected to a great (large magnitude) acceleration  or a sustained acceleration.

So in other words if there's a big acceleration, even linear, the angles can go off by more than 15 deg (albeit only for a few seconds) and it can stray further still if I induce a long sustained acceleration which is typical with drones. And btw, I'm needing these angles for a drone to use in stabilization. I should have mentioned that. Apologies.

I wasn't aware that mavlink is mainly intended for on screen data, well hopefully I can get it to work if I end up using this method.

So, back to the original question: Does the pixhawk update the angles (that can be sent over to an arduino via mavlink) when it receives data from an airspeed sensor?

Thanks for your time martin, you're pretty cool, and that means a lot coming from me.

"Hey! How--ah these pretzels suck... How's your day been buddy?"

Go Up