电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

卡尔曼滤波算法代码总结(20150311)VIP免费

卡尔曼滤波算法代码总结(20150311)_第1页
卡尔曼滤波算法代码总结(20150311)_第2页
卡尔曼滤波算法代码总结(20150311)_第3页
/***************************************************************************//*kalman.c*//*1-DKalmanfilterAlgorithm,usinganinclinometerandgyro*//*Author:RichChiOoi*//*Version:1.0*//*Date:30.05.2003*//*AdaptedfromTrammelHudson(hudson@rotomotion.com)*//*-------------------------------*//*Compilationprocedure:*//*Linux*//*gcc68-cXXXXXX.c(tocreateobjectfile)*//*gcc68-oXXXXXX.hexXXXXXX.oppwa.o*//*Uploaddata:*//*ulfilename.txt*//***************************************************************************//*Inthisversion:*//***************************************************************************//*Thisisafreesoftware;youcanredistributeitand/ormodify*//*itunderthetermsoftheGNUGeneralPublicLicenseaspublished*//*bytheFreeSoftwareFoundation;eitherversion2oftheLicense,*//*or(atyouroption)anylaterversion.*//**//*thiscodeisdistributedinthehopethatitwillbeuseful,*//*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof*//*MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe*//*GNUGeneralPublicLicenseformoredetails.*//**//*YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense*//*alongwithAutopilot;ifnot,writetotheFreeSoftware*//*Foundation,Inc.,59TemplePlace,Suite330,Boston,*//*MA02111-1307USA*//***************************************************************************/#include#include"eyebot.h"/**Thestateisupdatedwithgyroratemeasurementevery20ms*changethisvalueifyouupdateatadifferentrate.*/staticconstfloatdt=0.02;/**Thecovariancematrix.Thisisupdatedateverytimestepto*determinehowwellthesensorsaretrackingtheactualstate.*/staticfloatP[2][2]={{1,0},{0,1}};/**Ourtwostates,theangleandthegyrobias.Asabyproductofcomputing*theangle,wealsohaveanunbiasedangularrateavailable.Theseare*read-onlytotheuserofthemodule.*/floatangle;floatq_bias;floatrate;/**TheRrepresentsthemeasurementcovariancenoise.R=E[vvT]*Inthiscase,itisa1x1matrixthatsaysthatweexpect*0.1radjitterfromtheinclinometer.*fora1x1matrixinthiscasev=0.1*/staticconstfloatR_angle=0.001;/**Qisa2x2matrixthatrepresentstheprocesscovariancenoise.*Inthiscase,itindicateshowmuchwetrusttheinclinometer*relativetothegyros.*/staticconstfloatQ_angle=0.001;staticconstfloatQ_gyro=0.0015;/**state_updateiscalledeverydtwithabiasedgyromeasurement*bytheuserofthemodule.Itupdatesthecurrentangleand*rateestimate.**Thepitchgyromeasurementshouldbescaledintorealunits,but*doesnotneedanybiasremoval.Thefilterwilltrackthebias.**A=[0-1]*[00]*/voidstateUpdate(constfloatq_m){floatq;floatPdot[4];/*Unbiasourgyro*/q=q_m-q_bias;//当前角速度:测量值-估计值/**Computethederivativeofthecovariancematrix*(equation22-1)*Pdot=A*P+P*A'+Q**/Pdot[0]=Q_angle-P[0][1]-P[1][0];/*0,0*/Pdot[1]=-P[1][1];/*0,1*/Pdot[2]=-P[1][1];/*1,0*/Pdot[3]=Q_gyro;/*1,1*//*Storeourunbiasgyroestimate*/rate=q;/**Updateourangleestimate*angle+=angle_dot*dt*+=(gyro-gyro_bias)*dt*+=q*dt*/angle+=q*dt;//角速度积分累加到估计角度/*Updatethecovariancematrix*/P[0][0]+=Pdot[0]*dt;P[0][1]+=Pdot[1]*dt;P[1][0]+=Pdot[2]*dt;P[1][1]+=Pdot[3]*dt;}/**kalman_updateiscalledbyauserofthemodulewhenanew*inclinoometermeasurementisavailable.**Thisdoesnotneedtobecalledeverytimestep,butcanbeif*theaccelerometerdataareavailableatthesamerateasthe*rategyromeasurement.**H=[10]**becausetheanglemeasurementdirectlycorrespondstotheangle*estimateandtheanglemeasurementhasnorelationtothegyro*bias.*/voidkalmanUpdate(constfloatincAngle){/*Computeo...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

文章天下+ 关注
实名认证
内容提供者

各种文档应有尽有

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部