Complementary filter (Gyro + accel) with Android

后端 未结 4 620
旧时难觅i
旧时难觅i 2021-01-31 06:36

Recently I have made some research to use both the accelerometer + Gyroscope to use those senser to track a smartphone without the help of the GPS (see this post) Indoor Positi

4条回答
  •  隐瞒了意图╮
    2021-01-31 07:06

    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);
    

提交回复
热议问题