Sensor Fusion

Sensor Fusion is a process by which IMU data from several different sensors (such as Accelo, Gyro and Magnto) are “fused” to compute something more than could be determined by any one sensor alone or improve accuracy, reliability and filtering IMU sensors data. An example is computing or estimating position and orientation of a body segment in three dimensional space.

  • An accelerometer measures inertial force, such as gravity (and ideally only by gravity), but it might also be caused by acceleration (movement) of the device. Even if the accelerometer is relatively stable, it is very sensitive to vibration and mechanical noise.
  • A gyroscope is less sensitive to linear mechanical movements, the type of noise that accelerometer suffers from. Gyroscopes have other types of problems like drift (not coming back to zero-rate value when rotation stops).
  • Averaging the data that comes from accelerometers and gyroscopes can produce a better estimate of orientation than obtained using accelerometer data alone.

A prerequisite for sensor fusion, is that of calibration: the sensors themselves have to be calibrated and provide measurement in known units. Furthermore, whenever multiple sensors are combined additional calibration issues arise, since the measurements are seldom acquired in the same physical location and expressed in a common coordinate reference frame.

Here, there are using 3 types of sensors. Each of these sensor types provides unique functionality, but also has limitations:

  • Accelerometer: x-, y- and z-axis linear motion sensing, but sensitive to vibration and mechanical noise.
  • Gyroscope: pitch, roll and yaw rotational sensing, gyroscope drift (not coming back to zero-rate value when rotation stops).
  • Magnetometer: x-, y- and z-axis magnetic field sensing, but sensitive to magnetic interference
Accelerometers sense Gyroscopes sense
Accelo changes in direction or orientation/inclination with respect to gravity force Gyroscope to a more exact angular displacement.
Accelerometers are more accurate in static calculations, when the system is closer to its fixed reference point. Gyroscopes are better at detecting orientation when the system is already in motion.
Accelerometers tend to distort accelerations due to external forces as gravitational forces in motion; which accumulates as noise in the system and erroneous spikes in resulting outputs. With the addition of the long-term accuracy of a gyroscope combined with the short-term accuracy of the accelerometer, these sensors can be combined to obtain more accurate orientation readings by utilizing the benefits of each sensor. Gyroscopes sense orientation through angular velocity changes and therefore find orientation, but they have a tendency to drift over time because they only sense changes and have no fixed frame of reference.

Fundamental of  developing sensor fusion algorithm


1. Complementary Filtering

Combine orientation estimated from Accelerometer readings with that estimated from the Gyroscope readings

I want to explain briefly how the sensor fusion approach works. In simple terms, the acceletometer sensor data provides the gravity vector (the vector pointing towards the centre of the earth) and the magnetometer works as a compass. The Information from both sensors suffice to calculate the device’s orientation. However both sensor outputs are inaccurate, especially the output from the magnetic field sensor which includes a lot of noise.

The gyroscope in the device is far more accurate and has a very short response time. Its downside is the dreaded gyro drift. The gyro provides the angular rotation speeds for all three axes. To get the actual orientation those speed values need to be integrated over time.  This is done by multiplying the angular speeds with the time interval between the last and the current sensor output. This yields a rotation increment. The sum of all rotation increments yields the absolute orientation of the device. During this process small errors are introduced in each iteration. These small errors add up over time resulting in a constant slow rotation of the calculated orientation, the gyro drift.

To avoid both, gyro drift and noisy orientation, the gyroscope output is applied only for orientation changes in short time intervals, while the magnetometer/acceletometer data is used as support information over long periods of time. This is equivalent to low-pass filtering of the accelerometer and magnetic field sensor signals and high-pass filtering of the gyroscope signals.

Sensor fusion using Complementary Filter and Remove Gyro Drift error

What exactly does high-pass and low-pass filtering of the sensor data mean?

Sensor fusion – gyroscope and accelometer signal data

Combine orientation estimated from Magnetometer readings with that estimated from the Gyroscope readings

  • Rmag – current readings from Magnetometer
  • Rgyro – obtained from Rest(n-1) and current gyroscope readings

The sensors provide their data at (more or less) regular time intervals. Their values can be shown as signals in a graph with the time as the x-axis. The low-pass filtering of the noisy accelerometer/magnetometer signal are orientation angles averaged over time within a constant time window.

Assuming that the device is turned 90° in one direction and after a short time turned back to its initial position, the intermediate signals in the filtering process would look something like this:

Notice the gyro drift in the integrated gyroscope signal. It results from the small irregularities in the original angular speed. Those little deviations add up during the integration and cause an additional undesireable slow rotation of the gyroscope based orientation.

2. Kalman Filter

A Quick Insight of Kalman Filering

It’s nearly not hard to get the full meaning of Kalman Filter by starting from definitions and complicated equations (at least for us mere mortals) whatever you have come across from many resources or books.

For most cases and ref. materials, the state matrices drop out and we obtain the below Kalman filtering equation, which is much easier to start with in simple way to understood.
Kalman Filter - quick insight
Remember, the k‘s on the subscript are states. Here we can treat it as discrete time intervals, such as k=1 means 1ms, k=2 means 2ms.

Iterate steps

Kalman Filter - Iteration Process


Kalman Filtering ref. link

Ref. Study Link