UKF 无迹卡尔曼滤波

参考:

UKF数学原理:

UKF的基本非线性系统描述:

The UKF takes in a simple way the unscented transformation to obtain the covariance matrices used to compute the Kalman gains. Like the standard Kalman filter, UKF proceeds with a repeated two step algorithm. The details of the UKF algorithm are as follows. Given the (nonlinear) system:

在这里插入图片描述

Define a set of sigma points x(i) s according with the scaled unscented transform previously described. Now, repeat the following steps.

计算sigma point和权重参数

It has been noticed that the distance of the lateral sigma points to the central point increases as N increases. This is not convenient, and a scaling scheme has been devised to circumvent this problem:

在这里插入图片描述

where (matrix)i means the i-th column of the matrix, and λ is a scaling parameter, such that:

在这里插入图片描述

The parameter α determines the spread of the sigma points around the centre, and usually takes a small positive value equal or less than one. The parenthesis term (N + κ) is usually equal to 3. The weighting factors are chosen as follows:

在这里插入图片描述

The parameter β is an added degree of freedom to include a priori knowledge on the original PDF. In the case of a Gaussian PDF, β = 2 is optimal.

UKF的基本预测步和更新步:

(a) Prediction

• Use the transition equation to propagate the sigma points:

在这里插入图片描述

• Obtain the mean of the propagated sigma points:

在这里插入图片描述

• Compute the a priori covariance matrix:

在这里插入图片描述

(b) Update • Use the measurement equation to obtain measurements of the propagated sigma points:

在这里插入图片描述

• Obtain the mean of the measurements:

在这里插入图片描述

• Compute the measurement covariance matrix:

在这里插入图片描述

• Obtain the Kalman gain as follows

在这里插入图片描述

• And obtain the remaining terms:

在这里插入图片描述

UKF代码实现:

%Unscented Kalman filter example
%Radar monitoring of falling body
%------------------------------------------
%Prepare for the simulation of the falling body
T=0.4; %sampling period
g=-9.81;
rho0=1.225; %air density, sea level
k=6705.6; %density vs. altitude constant
L=100; %horizontal distance radar<->object
L2=L^2;
Nf=100; %maximum number of samples

rx=zeros(3,Nf); %space for state record
rd=zeros(1,Nf); %space for drag record
ry=zeros(1,Nf); %space for measurement record
tim=0:T:(Nf-1)*T; %time
%process noise
Sw=[10^5 0 0; 0 10^3 0; 0 0 10^2]; %cov
bn=randn(3,Nf); sn=zeros(3,Nf);
sn(1,:)=sqrt(Sw(1,1))*bn(1,:); %state noise along simulation
sn(2,:)=sqrt(Sw(2,2))*bn(2,:); %" " "
sn(3,:)=sqrt(Sw(3,3))*bn(3,:); %" " "
%observation noise
Sv=10^6; %cov.
on=sqrt(Sv)*randn(1,Nf); %observation noise along simulation
%------------------------------------------
%Prepare for filtering
%space for matrices
K=zeros(3,Nf); M=zeros(3,3,Nf); P=zeros(3,3,Nf);
%space for recording er(n), xe(n)
rer=zeros(3,Nf); rxe=zeros(3,Nf);
%UKF parameters (to be edited here)
N=3; %space dimension
alpha=0.7; kappa=0; beta=2;
%pre-computation of constants
lambda= ((alpha^2)*(N+kappa))-N;
aab=(1-(alpha^2)+beta);
lN=lambda+N; LaN=lambda/lN; aaN=aab+LaN;
%------------------------------------------
%Behaviour of the system and the filter after initial state
x=[10^5; -5000; 400]; %initial state
xe=x; % initial value of filter state
xa=xe; %initial intermediate state
xs=zeros(3,7); %space for sigma points
xas=zeros(3,7); %space for propagated sigma points
yas=zeros(1,7); %" " "
P(:,:,1)=0.001*eye(3,3); %cov. non-zero init.
nn=1;
while nn<Nf+1
    %estimation recording
    rxe(:,nn)=xe; %state
    rer(:,nn)=x-xe; %error
    %system
    rx(:,nn)=x; %state recording
    rho=rho0*exp(-x(1)/k); %air density
    d=(rho*(x(2)^2))/(2*x(3)); %drag
    rd(nn)=d; %drag recording
    %next system state
    x(1)=x(1)+(x(2)*T)+sn(1,nn);
    x(2)=x(2)+((g+d)*T)+sn(2,nn);
    x(3)=x(3)+sn(3,nn);
    
    %system output
    y=on(nn)+sqrt(L2+(x(1)^2));
    ym=y; %measurement
    ry(nn)=ym; %measurement recording
    %Prediction
    %sigma points
    sqP=chol(lN*P(:,:,nn)); %matrix square root
    xs(:,7)=xe;
    xs(:,1)=xe+sqP(1,:)'; xs(:,2)=xe+sqP(2,:)';
    xs(:,3)=xe+sqP(3,:)';
    xs(:,4)=xe-sqP(1,:)'; xs(:,5)=xe-sqP(2,:)';
    xs(:,6)=xe-sqP(3,:)';
    %a priori state
    %propagation of sigma points (state transition)
    for m=1:7
        rho=rho0*exp(-xs(1,m)/k); %air density
        d=(rho*(xs(2,m)^2))/(2*xs(3,m)); %drag
        xas(1,m)=xs(1,m)+(xs(2,m)*T);
        xas(2,m)=xs(2,m)+((g+d)*T);
        xas(3,m)=xs(3,m);
    end
    %a priori state mean (a weighted sum)
    xa=0;
    for m=1:6
        xa=xa+(xas(:,m));
    end
    xa=xa/(2*lN);
    xa=xa+(LaN*xas(:,7));
    %a priori cov.
    aux=zeros(3,3); aux1=zeros(3,3);
    for m=1:6
        aux=aux+((xas(:,m)-xa(:))*(xas(:,m)-xa(:))');
    end
    aux=aux/(2*lN);
    aux1=((xas(:,7)-xa(:))*(xas(:,7)-xa(:))');
    aux=aux+(aaN*aux1);
    M(:,:,nn+1)=aux+Sw;
    %Update
    %propagation of sigma points (measurement)
    for m=1:7
        yas(m)=sqrt(L2+(xas(1,m)^2));
    end
    %measurement mean
    ya=0;
    for m=1:6
        ya=ya+yas(m);
    end
    ya=ya/(2*lN);
    ya=ya+(LaN*yas(7));
    %measurement cov.
    aux2=0;
    for m=1:6
        aux2=aux2+((yas(m)-ya)^2);
    end
    aux2=aux2/(2*lN);
    aux2=aux2+(aaN*((yas(7)-ya)^2));
    Syy=aux2+Sv;
    %cross cov
    aux2=0;
    for m=1:6
        aux2=aux2+((xas(:,m)-xa(:))*(yas(m)-ya));
    end
    aux2=aux2/(2*lN);
    aux2=aux2+(aaN*((xas(:,7)-xa(:))*(yas(7)-ya)));
    Sxy=aux2;
    %Kalman gain, etc.
    K(:,nn+1)=Sxy*inv(Syy);
    P(:,:,nn+1)=M(:,:,nn+1)-(K(:,nn+1)*Syy*K(:,nn+1)');
    xe=xa+(K(:,nn+1)*(ym-ya)); %estimated (a posteriori) state
    nn=nn+1;
end
%------------------------------------------
%display
figure(1)
subplot(1,2,1)
plot(tim,rx(1,1:Nf),'kx'); hold on;
plot(tim,rxe(1,1:Nf),'r');
title('altitude'); xlabel('seconds')
axis([0 Nf*T 0 12*10^4]);
subplot(1,2,2)
plot(tim,rx(2,1:Nf),'kx'); hold on;
plot(tim,rxe(2,1:Nf),'r');
title('velocity'); xlabel('seconds');
axis([0 Nf*T -6000 1000]);

UKF实现仿真:

在这里插入图片描述

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
无迹卡尔曼滤波UKF)是一种改进的卡尔曼滤波方法,它在卡尔曼滤波的基础上进行了扩展以处理非线性系统。UKF通过使用sigma点集来对下一时刻状态进行预测,并通过非线性映射对sigma点集进行扩充,从而避免了复杂非线性函数雅可比矩阵的复杂计算,并保证了对非线性系统的普遍适应性。此外,UKF还通过扩展高斯分布的sigma点集来抑制噪声的影响。因此,UKF在处理非线性系统时具有一定的优势。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [超详细讲解无迹卡尔曼(UKF)滤波(个人整理结合代码分析)](https://blog.csdn.net/jiushizhemekeai/article/details/127453800)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [无迹卡尔曼滤波器(UKF)](https://blog.csdn.net/qq_41011336/article/details/84401691)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [转弯模型(Coordinate Turn,CT)无迹卡尔曼滤波UKF),matlab代码](https://download.csdn.net/download/monologue0622/88218055)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

KPer_Yang

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

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

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

打赏作者

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

抵扣说明:

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

余额充值