Complementary filter (Gyro + accel) with Android

∥☆過路亽.° 提交于 2019-12-02 17:48:32
Ali

I can only repeat myself.

You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice. In other words, you are trying to solve the impossible.

What you actually can do is to track just the orientation.

Roll, pitch and yaw are evil, do not use them. Check in the video I already recommended, at 38:25.

Here is an excellent tutorial on how to track orientation with gyros and accelerometers.

Similar questions that you might find helpful:

track small movements of iphone with no GPS
What is the real world accuracy of phone accelerometers when used for positioning?
how to calculate phone's movement in the vertical direction from rest?
iOS: Movement Precision in 3D Space
How to use Accelerometer to measure distance for Android Application Development
Distance moved by Accelerometer
How can I find distance traveled with a gyroscope and accelerometer?

I wrote a tutorial on the use of the Complementary Filter for oriëntation tracking with gyroscope and accelerometer: http://www.pieter-jan.com/node/11 maybe it can help you.

I test your code and found that probably the scale factor is not consistent. Convert the pitch to 0-pi gives better result. In my test, the filtered result is ~90 degrees.

pitch = (float) Math.toDegrees(Math.atan2(accel[1], Math.sqrt(Math.pow(accel[2], 2) + Math.pow(accel[0],   2))));
pitch = pitch*PI/180.f;

filtered_angle = weight * (filtered_angle + event.values[0] * dT) + (1.0f-weight)* (pitch);

i tried and this will give you angle 90...

filtered_angle = (filtered_angle / 83) * 90;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!