I extracted motion acceleration with MPU6050 and removed gravity. Now, the problem is when I put the sensor in no-move status, I read nearly zero acceleration in z-axis but when I turn it 180 degree and then put it in the rest it shows nearly -2. There is a constant of 2 and I don't know how to remove it. I want the sensor to show me a zero acceleration when it is not moving.
1 Answer
You "removed gravity" from the Z axis by subtracting a constant. Obviously, this does not work if the Z axis no longer points "up".
If the sensor cannot be maintained in a particular orientation with respect to the gravity vector, then there is no simple way to remove gravity. You'll have to do a full 6-dimensional motion solution (3 axis accelerometer, 3-axis gyro) to determine position and attitude, and then derive your non-gravity accelerations from that.
Even then, your sensors will have long-term drift, so your solution will also need to have a means for compensating for that.
-
\$\begingroup\$ no i didn't subtract a constant, i remove gravity by using quaternion and rotation matrix and in the beginning of sensor working i see a zero motion acceleration and it's ok but when i turn it 180 deg , instead of showing zero again it shows -2. \$\endgroup\$– Reza KCommented Sep 12, 2019 at 13:03
-
1\$\begingroup\$ Then there's something wrong with your math. We can't help you unless you show it to us. \$\endgroup\$ Commented Sep 12, 2019 at 13:05
-
\$\begingroup\$ If gravity is removed, something is subtracting a constant somewhere. If it's not you, it's the accelerometer. \$\endgroup\$ Commented Sep 12, 2019 at 15:56