What are the differences between a gyroscope, accelerometer and magnetometer?

What is the difference between a 3-axis gyroscope, 3-axis accelerometer and 3-axis magnetometer? How do these sensors work? Why are all 3 used in some devices like smartphones, tablets, quadcopters etc.?

They are three sensors that are useful for determining position and orientation, but they measure different things.

• A magnetometer measures magnetic fields. Because the earth has a significant magnetic field, the magnetometer can be used as a compass. As such it is useful to determine absolute orientation in the NESW plane.
• An accelerometer measures accelerations. This is useful to measure changes in velocity (directly, as the acceleration is the first time derivative of the velocity) and changes in position (by integrating the signal). They are usually used for measuring small movements. Also note that gravity acts like a continuous acceleration upward (via Einstein's equivalency principle), so a multiple-axis accelerometer can also be used as an absolute orientation sensor in the UP-DOWN plane.
• A gyroscope measures either changes in orientation (regular gyro or integrating rate gyro) or changes in rotational velocity (rate gyro).

The reason these sensors are combined is because they excel at different things. For example, for orientation, a magnetometer has poor accuracy for fast movement, but pretty much zero drift over time. An integrating scheme using gyros on the other hand reacts quickly and accurately to changes, but accumulates vast error over time. It also requires to start from a known orientation, as it only reacts to changes.

Combining the inputs to these sensors allows for quick and accurate position and orientation determination with a low amount of drift over time.

Together, these sensors are also referred to as an Inertial Measurement Unit, or IMU. You can find more information on the wikipedia page for this term. Note that the unit is not strictly speaking purely inertial when you add magnetometers, but this nomenclature is widely used.

• It makes perfect sense for me that an accelerometer is able to sense gravity, but the link in your answer says that "Linear accelerometers measure non-gravitational accelerations". How is that possible? Dec 28, 2015 at 14:49
• Gravitation is usually removed through filtering, either in hardware or in post processing, by feeding the signal through a high-pass filter. Dec 29, 2015 at 9:21
• but if it's filtered out, how do they know if the phone is in portrait or landscape? Dec 30, 2015 at 8:37
• Specifically when talking about phones, there are several different version of the measurements that you can access e.g. on Android. Usually they include raw values, filtered values (e.g. "linear") and valued fused with other sensors, such as magnetometers. See for example the answer to this question: stackoverflow.com/questions/7858759/… Dec 30, 2015 at 23:03