久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

新聞中心

EEPW首頁 > 嵌入式系統 > 設計應用 > 卡爾曼濾波在單片機上的使用

卡爾曼濾波在單片機上的使用

作者: 時間:2016-11-29 來源:網絡 收藏






#ifndef _KALMAN_H_
#define _KALMAN_H_

本文引用地址:http://cqxgywz.com/article/201611/323547.htm

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



關鍵詞: 卡爾曼濾波單片

評論


技術專區

關閉