# Why would a drone need a magnetometer? Are an accelerometer and a gyroscope not sufficient?

Why would a drone need a magnetometer? What would the drone do with this information? I think it would be to tell direction, but why would it need this if it has an accelerometer and a gyroscope?

The main difference between accelerometer and gyroscope vs magnetometer is that first two give only relative information - you may calculate heading relative to your starting position, but you won't have any idea how this heading relates to world directions.

What's more, as both gyroscope and accelerometer give you only accelerations values, calculation of pose and heading basing on their readings is incremental. That means that pose estimation error increases over time. Magenetometer can be used to correct these data.

Edit: As Jakob stated in the comment, accelerometer can also be used to estimate pose (roll and pitch angles), but only when your drone doesn't accelerate and you measure gravity only. When drone accelerates, you won't know for sure how much of the acceleration comes from its movement and how much from gravity force.

Generally, more sensors let you account for errors more easily and make pose estimation more accurate. If you want more information, "sensor fusion' is a good keyword to start. Also this question on Kalman filter is worth reading.

• One component of the accelerometer measurement is the acceleration against gravitation, which is also an absolute reading, which can provide you with information on your pose - but not the heading component of course. Mar 17, 2016 at 7:33

A magnometer lets the drone control its geographical heading. It's really the accelerometer that tells direction (not the gyroscope) and, in this case, the direction is down-wards. This provides feedback to manipulate the drone's pitch-and-roll positions. A magnometer tells another direction - feedback used to manipulate the angular yaw position.

At its most basic, any autopilot system needs to control the aircraft's flight dynamics: pitch, roll and yaw (or azimuth).

A gyroscope senses angular velocity across the pitch-, roll- and yaw-axis. A system could use this feedback to manipulate the speeds of the motors such that desired angular velocities are maintained across all axes.

An accelerometer senses force along the pitch-, roll- and yaw-axis. A system could use this data, combined with data from the gyroscope (see "sensor-fusion"), to estimate the aircraft's orientation relative to the ground and use this feedback to manipulate angular velocities such that desired angular positions are maintained in the pitch-and-roll axes.

A magnometer senses magnetic flux density across the pitch-, roll- and yaw-axis. A system could use this data, combined with data from the accelerometer and gyroscope, to estimate the aircraft's orientation relative to the Magnetic North Pole and use this feedback to manipulate angular velocity such that a desired angular position is maintained in the yaw-axis.

Without a magnometer, only the angular velocity can be maintained in the yaw-axis (not the angular position, which exists only relative to some known direction). In theory, provided that such direction is given upfront as an initial vector, it is possible to use the gyroscope data as feedback to track the aircraft's relative orientation as it rotates over time. In practice, however, this integration accumulates error (see "gyroscope drift") and the method soon becomes impractical without also incorporating feedback from other sensors (that provide a means of some direction relative to the aircraft).

As other people have said, in a steady-state condition, a gyroscope+accelerometer sensor suite can successfully estimate the roll and pitch values of the UAV, but not its yaw angle.

However, there have been early successful fixed-wing UAV autopilots which managed to solve the yaw value through differentiation of the GPS signal. One such example is the MatrixPilot system.

This was possible since an airplane is aligned with the GPS track, more or less, with the roll and pitch values being independent of that solution. Naturally, this is not possible with a multirotor which can move at any direction regardless of heading.

But in the case of sustained turns, the additive Corriolis force dubs the accelerometer into thinking that the aircraft is inclined in a different pose than the actual one. Gradually, the solution from an AHRS filter diverges and gets tricked into thinking that the plane is banked less than the actual angle.

When coming out of the turn, the AHRS solution is badly corrupted and takes a long time to get re-adjusted by the GPS track.

The magnetometer can solve this problem, by providing a stable reference vector, throughout the turn.