[英]How to add a complementary filter for the gyro z axis using a magnetometer?
I am using a complementary filter for my gyro X and gyro Y values: 我为陀螺仪X和陀螺仪Y值使用了互补滤波器:
float angle_x = alpha*gyro_angle_x + (1.0 - alpha)*accel_angle_x;
However, due to Gyro Z drift, I am using a magnetometer to try and eliminate it. 但是,由于陀螺仪Z漂移,我正在使用磁力计来尝试消除它。
I have my local inclination angle and the z-axis magnetometer reading but I am not sure how to implement this into the complementary filter. 我有我的局部倾斜角和z轴磁力计读数,但是我不确定如何将其应用于互补滤波器。
I've tried guessing (which I know doesn't help) to try this: 我尝试猜测(我知道这无济于事)来尝试以下操作:
float angle_z = alpha*gyro_angle_z + ((1.0 -alpha)*accel_angle_y*InclinationAngle)/magZ;
However, it just increases gyro z value when moving and then brings it back to 0 when stationary. 但是,它只是在移动时增加陀螺仪z值,然后在静止时将其恢复为0。
Using the Madgwick filter will work best. 使用Madgwick滤镜效果最佳。 The link can be found here .
链接可以在这里找到。 It is easy to implement (if using the correct library and the readings are pretty accurate. The only downside at the moment is that you will have to calibrate the magnetometer every time you want to use the device in a new direction).
这很容易实现(如果使用正确的库并且读数非常准确。目前唯一的缺点是每次您要在新方向上使用设备时都必须校准磁力计)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.