Kalman filter and its application in vehicle postion estimate

1prepare

you should read :An Introduction to the Kalman Filter 

Of course  you can read other example :https://blog.csdn.net/App_12062011/article/details/51758989 (easy for you understanding)

 https://blog.csdn.net/zengxiantao1994/article/details/71170728 (with matlab code)

2Problem

 Taking speed as system input and GPS position as system measurement, write down the whole process model. Design a Kalman filter to estimate the position x

xk^-=x(k-1)+u

z(k)=1.xk^-;

 

 

 

speed:--u /m/s

gps:--z /m

polyfit

%ployfit gps with pos and get the sd value
sz=size(z)
t=1:sz(1);
p = polyfit(t',z,1)
y=polyval(p,t');
plot(t',y,'r',t',z,'k.'),xlabel('time/s'),ylabel('position/m'),title('polyfit the gps position')
legend('polyfit curve','GPS point')
delt=y-z;
%standard derivation
R=std(delt)

R=1.354

follow the  kalman procedure to code it

%R=std(z)
%x(k)=x(k-1)+1*u
%z(k)=x(k)+sqr(R)*rdn


%%
A=1;B=1;H=1;
Q=0.2; 
sz=size(z);
xk=zeros(sz);% prior estimate
xpk=zeros(sz);%post estimate value;
Pmins=zeros(sz);% post covinrance 
pk=zeros(sz);%prior convinrance
kg=zeros(sz);kg(1)=1;
for k=2:sz(1)
    xpk(k)=A*xk(k-1)+B*u(k-1);
    Pmins(k)=A*pk(k-1)*A'+Q;
    kg(k)=Pmins(k)*H'/(H*Pmins(k)*H'+R);
    xk(k)=xpk(k-1)+kg(k)*(z(k)-H*xpk(k-1));
    pk(k)=(1-kg(k)*H)*Pmins(k);    
end
plot(1:sz(1),z,'k',1:sz(1),xk,'r')
legend('GPS','estimate position')
xlabel('time/s')
ylabel('distance/m')
title('speed with gps to estimate kanlman')

Edit:   xk(k)=xpk(k)+kg(k)*(z(k)-H*xpk(k));

 

As shown in the code,

xk(k-1) --GPS position,

xpk(k)-- the posteriori estimate value.

Pmins(k)--

pk(k-1)--

kg(k):kalman gain

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

做一个码农都是奢望

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值