高级会员
- 积分
- 554
- 威望
- 267
- 贡献
- 137
- 兑换币
- 171
- 注册时间
- 2013-9-22
- 在线时间
- 75 小时
|
我的三个零点值也是平衡时的输出值 我滤出来波如下
黄色是加速度算出来的
红色是角速度 紫色是卡尔曼算出来得角度值
感觉滤出来的波形 粗糙而且还有尖峰
你帮我看看是哪里出问题
程序是这个
Gyro = g_ADvalue[0];
Acc_x = g_ADvalue[2];
Acc_z = g_ADvalue[1];
OutData[1]=Acc_z;
if(Gyro > 4090) Gyro += 1000;
else
if(Gyro > 4084) Gyro += 500;
if(Gyro < 55) Gyro -= 1000;
else
if(Gyro < 60) Gyro -= 500;
Acc_x = Acc_x - 1389.6;
Acc_z = Acc_z - 2450.0;
Gyro = Gyro - 2860.4;
Gyro_Data = Gyro;
OutData[0] = Gyro_Data;
accelerometer_angle =atan2f(Acc_z,Acc_x);
OutData[2] = accelerometer_angle*1000;
gyroscope_rate = Gyro*0.0023; //参考电压3.3v 12位ADC 放大9.1倍 enc-03 0.67mv/deg./sec.
//(3300/4096)/(0.67*9.1)*(3.14/180) = 0.0023
NowData = RealData + gyroscope_rate*0.04; //1.预估计 X(k|k-1) = A(k,k-1)*X(k-1|k-1) + B(k)*u(k)
NowData_P = sqrt(Q*Q+RealData_P*RealData_P); //2.计算预估计协方差矩阵 P(k|k-1) = A(k,k-1)*P(k-1|k-1)*A(k,k-1)'+Q(k)
Kg = sqrt(NowData_P*NowData_P/(NowData_P*NowData_P+R*R)); //3.计算卡尔曼增益矩阵 K(k) = P(k|k-1)*H(k)' / (H(k)*P(k|k-1)*H(k)' + R(k))
RealData = NowData + Kg*(accelerometer_angle - NowData); //4.更新估计 X(k|k) = X(k|k-1)+K(k)*(Z(k)-H(k)*X(k|k-1))
RealData_P = sqrt((1-Kg)*NowData_P*NowData_P); //5.计算更新后估计协防差矩阵 P(k|k) =(I-K(k)*H(k))*P(k|k-1)
QingJiao = RealData;
OutData[3] = QingJiao*1000;//*180/3.141592653;
// OutPut_Data();
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|