# 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.

$$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.