您好,欢迎来到九壹网。
搜索
您的当前位置:首页卡尔曼滤波在单片机上的使用

卡尔曼滤波在单片机上的使用

来源:九壹网
卡尔曼滤波在单片机上的使用

2011-04-13 13:43:43| 分类: 默认分类 | 标签: |字号大中小 订阅

#ifndef _KALMAN_H_ #define _KALMAN_H_

extern KalmanGain; //卡尔曼增益 extern EstimateCovariance; //估计协方差 extern MeasureCovariance; //测量协方差 extern EstimateValue; //估计值 extern void KalmanFilterInit( void ); extern KalmanFilter( Measure ); #endif

#include \"config.h\" #include \"math.h\"

KalmanGain; //卡尔曼增益 EstimateCovariance; //估计协方差 MeasureCovariance; //测量协方差 EstimateValue; //估计值 void KalmanFilterInit( void );

extern float KalmanFilter( float Measure );

void KalmanFilterInit( void ) {

EstimateValue = 0; EstimateCovariance = 0.1; MeasureCovariance = 0.02; }

KalmanFilter( Measure ) {

//计算卡尔曼增益

KalmanGain = EstimateCovariance * sqrt( 1 / ( EstimateCovariance * EstimateCovariance + MeasureCovariance * MeasureCovariance )); //计算本次滤波估计值

EstimateValue = EstimateValue + KalmanGain*( Measure – EstimateValue ); //更新估计协方差

EstimateCovariance = sqrt(1 - KalmanGain) * EstimateCovariance; //更新测量方差

MeasureCovariance = sqrt(1 - KalmanGain) * MeasureCovariance; //返回估计值

return EstimateValue; }

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务