UKF 无迹卡尔曼滤波

news2024/9/28 13:22:58

目录

    • 参考:
    • UKF数学原理:
      • UKF的基本非线性系统描述:
      • 计算sigma point和权重参数
      • UKF的基本预测步和更新步:
    • 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实现仿真:

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/129255.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

vue element-ui 手机号校验 验证码校验 获取验证码倒数60秒无样式实现模板

上一篇其实发过了。。。 但是实在真的是太丑了 丑到自己看不下去了 加个对话框好看很多&#xff0c;再发一次 原链接为&#xff1a;https://blog.csdn.net/ZZDT099/article/details/128496693?spm1001.2014.3001.5502 <template><el-dialog title"校验手机号…

算法:反转图像(旋转的矩阵)

前言 今天要介绍的是一个较为经典的算法题&#xff1a;反转图像或者旋转矩阵。这道题的原题是Leetcode上的一道题&#xff0c;在题库序号为48。具体内容粘贴如下&#xff1a; 这种题目就是一个典型的倒置矩阵的思路&#xff0c;大体内容就是将一个矩阵逆向反转90度。首先针对…

Spring Boot学习篇(四)

Spring Boot学习篇(四) 1 BLOB(二进制大类型) 1.1 创建tb_blob表,其sql语句如下所示 CREATE TABLE tb_blob(id number primary key,fname VARCHAR2(50) NOT NULL,f blob )1.2 在entity包下面创建TbBlob实体类 package com.zlz.entity;import lombok.AllArgsConstructor; im…

【嵌入式】NXP/LPC使用GPIO+定时器模拟UART串口接收

目录 一 项目背景 二 原理说明 三 设计实现--GPIO部分 四 设计实现--定时器部分 五 总结 一 项目背景 项目需要使用485串口编码器&#xff0c;编码器的数据以波特率9600持续向外发送。接收端计划使用485转换芯片MCU串口。但是片上的外设资源已经被占用了&#xff0c;没有多…

19.删除链表的倒数第N个结点

给你一个链表&#xff0c;删除链表的倒数第 n 个结点&#xff0c;并且返回链表的头结点。 示例 1&#xff1a; 输入&#xff1a;head [1,2,3,4,5], n 2 输出&#xff1a;[1,2,3,5] 示例 2&#xff1a; 输入&#xff1a;head [1], n 1 输出&#xff1a;[] 示例 3&#…

车辆未冲洗抓拍识别 工地车辆冲洗监测 opencv

车辆未冲洗抓拍识别 工地车辆冲洗监测系统t通过opencvpython可以对进出车辆冲洗情况进行自动识别&#xff0c;发现冲洗不合格自动进行抓拍存档。OpenCV基于C实现&#xff0c;同时提供python, Ruby, Matlab等语言的接口。OpenCV-Python是OpenCV的Python API&#xff0c;结合了Op…

如何对美国服务器响应速度进行优化

决定一个网站加载速度的最大因素之一是服务器的响应时间。服务器响应时间是你的服务器响应用户请求的速度&#xff0c;它可以大大影响你网站的用户体验。本文中&#xff0c;我们将讨论如何确定美国服务器响应时间慢的原因&#xff0c;尤其是如何对美国服务器响应速度进行优化。…

初探Lua脚本

1、什么是Lua Lua脚本是一个由C语言编写的小巧脚本语言&#xff0c;在所有脚本引擎中&#xff0c;Lua的速度是最快的。Lua的核心代码不过一万多行&#xff0c;因为是C语言编写的&#xff0c;因此Lua可以在几乎所有的操作系统和平台进行编译运行 2、Lua适用场景 1&#xff09;…

minio分布式集群部署

minio分布式集群部署 分布式 Minio 可以让你将多块硬盘或者多台服务器组成一个对象存储服务。由于硬盘分布在不同的节点上&#xff0c;分布式 Minio 避免了单点故障。MinioMinio分布式模式可以帮助你搭建一个高可用的对象存储服务&#xff0c;你可以使用这些存储设备&#xff…

七种分布式系统的解决方案,一次性讲给你听!

V-xin&#xff1a;ruyuan0330 获得600页原创精品文章汇总PDF 目录 TB级数据放在一台机器上&#xff1a;难啊&#xff01;到底啥是分布式存储&#xff1f;那啥又是分布式存储系统呢&#xff1f;天哪&#xff01;某台机器宕机了咋办&#xff1f;Master节点如何感知到数据副本消失…

nps内网穿透

nps服务端: linux, 公网ip npc客户端: windows, 内网 文件提取 链接&#xff1a;https://pan.baidu.com/s/1HgujpVoXpLxQ-IgAnI2Izg 提取码&#xff1a;8hyl nps安装 1.上传压缩包到服务器, 解压 2.修改conf文件夹下nps.conf文件 #HTTP(S) proxy port, no startup if em…

vue3 antd项目实战——Form表单使用【v-model数据的双向绑定,form表单嵌套input输入框、Radio单选框】

vue3 ant design vue项目实战——单选框&#xff08;Radio&#xff09;的使用以及Form表单的双向绑定知识调用&#xff08;form表单的源代码附在文章最后&#xff09;场景复现实现需求form表单整体架构的搭建input输入框文本域的嵌套单选组合Radio的嵌套button按钮组合的嵌套fo…

JVM 面试题

✅作者简介&#xff1a;热爱国学的Java后端开发者&#xff0c;修心和技术同步精进。 &#x1f34e;个人主页&#xff1a;Java Fans的博客 &#x1f34a;个人信条&#xff1a;不迁怒&#xff0c;不贰过。小知识&#xff0c;大智慧。 &#x1f49e;当前专栏&#xff1a;Java面试题…

C语言:预处理(1)

程序的翻译环境和执行环境 在ANSI C的任何一种实现中&#xff0c;存在两个不同的环境&#xff1a; 第一种是翻译环境&#xff0c;在这个环境中源代码被转换为可执行的机器指令。 第二种是执行环境&#xff0c;它用于实际执行代码。 翻译环境&#xff1a; 组成一个程序的每个…

MySQL 数据库练习题记录01

文章目录前言一、数据库练习题一1.1 表结构1.2 查询所有学生的信息(学号&#xff0c;姓名&#xff0c;性别&#xff0c;班级名称)1.3 查询所有人(包括没有成绩的学生)的课程分数(学号&#xff0c;姓名&#xff0c;性别&#xff0c;班级名称&#xff0c;语文分数&#xff0c;数学…

改进YOLOv5 | 引入密集连接卷积网络DenseNet思想 | 搭建密集连接模块

YOLOv5引入密集连接卷积网络DenseNet思想 CVPR 2017最佳论文 D e n s e N e t DenseNet DenseNet 论文地址:h

SpringBoot快速入门篇

&#x1f49f;&#x1f49f;前言 ​ 友友们大家好&#xff0c;我是你们的小王同学&#x1f617;&#x1f617; 今天给大家打来的是 SpringBoot快速入门篇 希望能给大家带来有用的知识 觉得小王写的不错的话麻烦动动小手 点赞&#x1f44d; 收藏⭐ 评论&#x1f4c4; 小王的主页…

手写 mini 版 Webpack

目录 1. mini 版 Webpack 打包流程 2. 创建 minipack.js 2.1 需要用到的插件库 2.1.1 babylon —— 解析 JavaScript 语法&#xff0c;生产 AST 语法树 2.1.2 babel-traverse —— 对 AST 进行遍历、转换的工具 2.1.3 transformFromAst —— 将 ES6、ES7 等高级的语法&am…

[Verilog]有限状态机设计举例

有限状态机设计举例 摘要&#xff1a;有限状态机&#xff08;FSM&#xff09;是许多数字系统中用来控制系统和数据流路径行为的时序电路。FSM的实例包括控制单元和时序。 本实验介绍了两种类型的FSM&#xff08;Mealy和Moore&#xff09;的概念&#xff0c;以及开发此类状态机的…

Codeforces Round #837 (Div. 2)

A. Hossam and Combinatorics 题目链接&#xff1a;Problem - A - Codeforces 样例输入&#xff1a; 2 5 6 2 3 8 1 6 7 2 8 3 2 10样例输出&#xff1a; 2 4题意&#xff1a;给定一个有n个元素的数组&#xff0c;然后让我们求出有多少对(i,j)满足|a[i]-a[j]|max|a[p]-q[q]…