CCNYRoboticsLab / imu_tools

ROS tools for IMU devices
Other
907 stars 428 forks source link

orientation error accumulated by complementary filter #168

Closed Excurrybang closed 2 years ago

Excurrybang commented 2 years ago

I use Raspberry Pi 4 with navio2 which contains the IMU mpu 9250. the IMU was not calibrated. yesterday I tried complementary filter with IMU. during the test, I didnt touch or move the IMU, but the calculated orientation from complementary filter incresed with time as you can see in the pictures below. Before the complementary filter I used magdwick, the calculated orientation from magdwick would not accumulated.

1 2 3

mintar commented 2 years ago

This sounds like a question for @robertogl .

robertogl commented 2 years ago

Are you sure you are using the accelerometer for correcting the prediction from angular velocity? In that case try to change the gains to give more weight to the accelerometer readings, perhaps your gyro has too much bias.

Excurrybang commented 2 years ago

thanks @robertogl

I tried to increase the gain of accelerometer, after that the value of x and y can stay in a certain numer but z value still continue to increse and w decrese.

Further more, I did other test:

increase the acc gain to 0.5, x, y value can stay in a certain number but z increse set use_mag to true, with gain_acc = 0.5, x, y stay in a certain number, z start to decrease

as a result, the calculated pitch and roll angle have about 2 degree bias but the yaw angle increse with time.

would you think the problem come from the uncalibrated imu ?

robertogl commented 2 years ago

The z angle (yaw) is not corrected by the accelerometer but by the magnetometer. However, magnetic readings are likely to be inaccurate indoors and even worsen the yaw estimation. Moreover, by giving more weight to the accelerometer, roll and pitch become more noisy, although stable.

I do not remember if by default the bias estimation is enabled in the filter. My suggestion would be to enable the bias estimation and/or tune the bias estimation parameters. With a good bias estimation the predicted angles would be drifting much slower and thus you can change the acc gain back to a smaller value but still obtain stable roll and pitch and smoother at the same time.

Excurrybang commented 2 years ago

thanks a lot, I gonna try first to calibrate the imu and then if necessary, do a bias estimation.