COMPARISON BETWEEN MAHONEY AND COMPLEMENTARY SENSOR FUSION ALGORITHM FOR ATTITUDE DETERMINATION BY RAW SENSOR DATA OF XSENS IMU ON BUOY

The accurate measurement of platform orientation plays a critical role in a range of applications including marine, aerospace, robotics, navigation, human motion analysis, and machine interaction. We used Mahoney filter, Complementary filter and Xsens Kalman filter for achieving Euler angle of a dynamic platform by integration of gyroscope, accelerometer, and magnetometer measurements. The field test has been performed in Kish Island using an IMU sensor (Xsens MTi-G-700) that installed onboard a buoy so as to provide raw data of gyroscopes, accelerometers, magnetometer measurements about 25 minutes. These raw data were used to calculate the Euler angles by Mahoney filter and Complementary filter, while the Euler angles collected by XSense IMU sensor become the reference of the Euler angle estimations. We then compared Euler angles which calculated by Mahoney Filter and Complementary Filter with reference to the Euler angles recorded by the XSense IMU sensor. The standard deviations of the differences between the Mahoney Filter, Complementary Filter Euler angles and XSense IMU sensor Euler angles were about 0.5644, 0.3872, 0.4990 degrees and 0.6349, 0.2621, 2.3778 degrees for roll, pitch, and heading, respectively, so the numerical result assert that Mahoney filter is precise for roll and heading angles determination and Complementary filter is precise only for pitch determination, it should be noted that heading angle determination by Complementary filter has more error than Mahoney filter. * Corresponding author


INTRODUCTION
Different kinds of technologies enable the measurement of orientation, inertial based sensory systems have the advantage of being completely self-contained such that the measurement is independent of motion and environment or location.An IMU (Inertial Measurement Unit) contains gyroscopes and accelerometers enabling the tracking of rotational and transfer movements.In order to measure in three dimensions, tri-axis sensors consisting of 3 mutually orthogonal sensitive axes are required.A MARG (Magnetic, Angular Rate, and Gravity) sensor is a combination of IMU along with tri-axis magnetic sensor.An IMU alone can only measure an attitude relative to the direction of gravity which is sufficient for many applications (Euston et al., 2007;Luinge et al., 2004).MARG systems or AHRS (Attitude and Heading Reference Systems) are able to provide a complete measurement of orientation relative to the direction of gravity and the earth's magnetic field.A gyroscope measures angular velocity which, sensor orientation will be computed over the time if initial conditions are known (Bortz, 1971;Ignagni, 1990).Precision gyroscopes are really expensive and grave for most applications while low accuracy MEMS (Micro Electrical Mechanical System) devices are used in a majority of applications (Yazdi et al. 1998).Accumulating error will occur in computed orientation because of the integration of gyroscope measurement errors.Therefore, gyroscope by itself can not present a complete measurement of orientation.The accelerometer measures the earth's gravitational and magnetometer measures magnetic fields thus, beside a gyroscope they create an absolute reference of orientation.However, these sensors are likely to be subject to high levels of noise; for example, the measured direction of gravity will corrupt by the noise due to the motion of the platform.The task of an orientation filter is to compute a single estimate of orientation through the optimal fusion of gyroscope, accelerometer and magnetometer measurements.These days The Kalman filter (Kalman, 1960) plays important role in majority of orientation filter algorithms (Foxlin, 1996;Luinge et al., 1999;Marins, 2001) and commercial inertial orientation sensors.Different commercial inertial systems have used Kalman-based algorithm;for example, Xsens (Xsens Technologies, 2009), micro-strain (MicroStrain, 2009), VectorNav (VectorNav, 2009), Intersense (InterSense, 2008), PNI (PNI sensor corporation) and Crossbow (Crossbow, 2007).The Kalman-based algorithms for orientation determination from sensor's raw data have a number of disadvantages, however, the widespread use of Kalman-based algorithm has emphesised that they have good accuracy and their effectiveness.Implementation of Kalman-based algorithm can be really complicated (Kallapur et al., 2009;Barshan and Durrant-Whyte, 1995;Foxlin, 1996;Luinge et al., 1999;Marins et al., 2001;Sabatini, 2006;Luinge and Veltink, 2006).(Mahony et al., 2008) developed the complementary filter which is shown to be an efficient and effective solution; however, performance is only validated for an IMU.
We used Mahoney and Complementary Filter for orientation determination from raw data that has been achieved by accelerometer, gyroscope, and magnetometer accelerometer.Their performances are benchmarked against an existing commercial filter (Xsens Kalman Filter (XKF3i)).

The Complementary Filter
When looking for the best way to make use of a IMU-sensor, thus combine the accelerometer and gyroscope data, a lot of people get fooled into using the very powerful but complex Kalman filter.However, the Kalman filter is great, there are 2 big problems with it that make it hard to use: Very complex to understand and Very hard.
Complementary Filter is extremely easy to understand, and even easier to implement.Most IMU's have 6 DOF (Degrees of Freedom).This means that there are 3 accelerometers, and 3 gyrosocopes inside the unit.IMU will be able to measure the precise position and orientation of the object it is attached to.This because an object in free space has 6DOF.So if we can measure them all, we know everything.The sensor data is not good enough to be used in this way.
We will use both the accelerometer and gyroscope data for the same purpose: obtaining the attitude of the object.The gyroscope can do this by integrating the angular velocity over time.To obtain the attitude with the accelerometer, we are going to determine the position of the gravity vector (g-force) which is always visible on the accelerometer.This can easily be done by using an atan2 function.In both these cases, there is a big problem, which makes the data very hard to use without filter.
The problem with accelerometers: As an accelerometer measures all forces that are working on the object, it will also see a lot more than just the gravity vector.Every small force working on the object will disturb our measurement completely.If we are working on an actuated system, then the forces that drive the system will be visible on the sensor as well.The accelerometer data is reliable only on the long term, so a "low pass" filter has to be used.
The problem with gyroscopes: It is possible to obtain the angular position by use of a gyroscope.It is very easy to obtain an accurate measurement that was not susceptible to external forces.The less good news was that, because of the integration over time, the measurement has the tendency to drift, not returning to zero when the system went back to its original position.The gyroscope data is reliable only on the short term, as it starts to drift on the long term.
The complementary filter gives us a "best of both worlds" kind of deal.On the short term, we use the data from the gyroscope, because it is very precise and not susceptible to external forces.
On the long term, we use the data from the accelerometer, as it does not drift.In its most simple form, the filter looks as follows: The gyroscope data is integrated every timestep with the current angle value.After this it is combined with the low-pass data from the accelerometer (already processed with atan2).The constants (0.98 and 0.02) have to add up to 1 but can of course be changed to tune the filter properly.It is very easy to compare Complementary Filter with Kalman filter.
The Complementary filter algorithm is designed in a way that has to be repeated in an infinite loop.Every iteration the pitch and roll angle values are updated with the new gyroscope values by means of integration over time.The filter then checks if the magnitude of the force seen by the accelerometer has a reasonable value that could be the real g-force vector.If the value is too small or too big, we know for sure that it is a disturbance we don't need to take into account.Afterwards, it will update the pitch and roll angles with the accelerometer data by taking 98% of the current value, and adding 2% of the angle calculated by the accelerometer.This will ensure that the measurement won't drift, but that it will be very accurate on the short term (Jan, 2013).

Xsens Kalman Filter (XKF3i)
The orientation of the IMU sensor (Xsens MTi-G-700) is computed by Xsens Kalman Filter.XKF3i uses signals of the rate gyroscopes, accelerometers and magnetometers to compute a statistical optimal 3D orientation estimate of high accuracy with no drift for both static and dynamic movements.XKF3 is a proven sensor fusion algorithm, which can be found in various products from Xsens and partner products.
The design of the XKF3i algorithm can be summarized as a sensor fusion algorithm where the measurement of gravity (by the 3D accelerometers) and Earth magnetic north (by the 3D magnetometers) compensate for otherwise slowly, but unlimited, increasing (drift) errors from the integration of rate of turn data (angular velocity from the rate gyros).This type of drift compensation is often called attitude and heading referencing and such a system is referred to as an Attitude and Heading Reference System (AHRS) (MTi User Manual, 2015).

Study area
A study area was selected in Southern IRAN, Kish Island in Persian Gulf with Coordinates: 26°32′N 53°58′E (Fig. 2).

Data sets
A field test and data acquisition have done in June 2016 in Kish Island beach.As we can see in (fig.3) a lightweight buoy with the onboard inertial Xsens sensor used (fig.4).The inertial sensor needs electrical power supply during the data acquisition, therefore, a boat used for putting a battery on it and to restrain the buoy.It should be noted, we used Xsens Kalman Filter algorithm as the reference algorithm without any drift and bias, so for evaluation of the accuracy and precision of Mahoney and Complementary Filter, as it can be seen in (fig.9) & (fig.10), we compared them with Xsens Kalman filter algorithm.Eventually, can be claimed that Complementary algorithm is not appropriate for heading angle determination, due to greater standard deviation with respect to Mahoney algorithm.

CONCLUSION
In this research, we used Mahoney, Complementary, and XKF3i algorithms for attitude determination from raw data of accelerometer, gyroscope, and magnetometer.In order to collect data, a test field by means of a lightweight buoy with onboard Xsens IMU is done in Kish Island.Each of algorithms for accuracy evaluation is compared with XKF3i, so, due to presented results, it is proved that Complementary algorithm is only sufficient for pitch angle determination, while, Mahoney algorithm is more accurate for roll and heading angles determination.Accordingly, it is suggested that presented algorithm be used for different uses such as Marine Engineering Sciences, Hydrography, and Oceanography.

Fig. 11 :
Fig. 11: Mahoney and Complementary Roll Std But this principle is not true for pitch angle determination (fig.12).Because of the lower standard deviation of the Complementary algorithm, it is more accurate for pitch angle determination.