# Sensor fusion with accelerometer and gyroscope only

I need to track an object in 3D-space and I can use only accelerometer and gyroscope. I can't use a magnetometer because the object itself has a strong magnet.

• I need to know the orientation of the object (how much gravity there is in $x, y,$ and $z$ components), and how much acceleration there is in $x, y,$ and $z$. I'm not trying to calculate the object's absolute position.

• Is it possible to create sensor fusion that has less than $10\%$ error in gravity and acceleration? At this point I'm just trying to understand if this goal is realistic.

I did a quick experiment with my smartphone and found out that the way it calculates gravity (LPF?) results $\approx 40\%$ error when phone is moved.

This was just a test: I'm not making phone app. I'm designing dedicated HW.

I'm just posting here a pic to show how the "gravity sum" looks like after fixing the math as suggested by Maximilian.

Actually, the plots for the components of gravity look good. What you miss is the fact, that your overall gravity (i.e. gravity sum) is the length of the vector, that is spanned by the three components. Hence, you should calculate

$$G=\sqrt{g_x^2+g_y^2+g_z^2},$$

where $g_x,g_y,g_z$ are the three single components measured by the acelerometer. Looking at your curves, I predict the sum will be quite flat.

• You are right. Fixing the math (to the length of the vector) makes "gravity sum" flat 9.81m/s^2. That closes my question. Thanks! – tipo1000 Feb 7 '17 at 20:14
• @tipo1000 you might consider closing this question by clicking the ckeck-mark next to my answer. Thanks! – Maximilian Matthé Feb 8 '17 at 6:04