function [phi theta psi] = EulerEKF(z, rates, dt)
%
%
persistent H Q R
persistent x P
persistent firstRun
if isempty(firstRun)
H = [ 1 0 0;
0 1 0 ];
Q = [ 0.0001 0 0;
0 0.0001 0;
0 0 0.1 ];
R = [ 6 0;
0 6 ];
x = [0 0 0]';
P = 10*eye(3);
firstRun = 1;
end
A = Ajacob(x, rates, dt);
xp = fx(x, rates, dt);
Pp = A*P*A' + Q;
K = Pp*H'*inv(H*Pp*H' + R);
x = xp + K*(z - H*xp);
P = Pp - K*H*Pp;
phi = x(1);
theta = x(2);
psi = x(3);
%------------------------------
function xp = fx(xhat, rates, dt)
%
%
phi = xhat(1);
theta = xhat(2);
p = rates(1);
q = rates(2);
r = rates(3);
xdot = zeros(3, 1);
xdot(1) = p + q*sin(phi)*tan(theta) + r*cos(phi)*tan(theta);
xdot(2) = q*cos(phi) - r*sin(phi);
xdot(3) = q*sin(phi)*sec(theta) + r*cos(phi)*sec(theta);
xp = xhat + xdot*dt;
%------------------------------
function A = Ajacob(xhat, rates, dt)
%
%
A = zeros(3, 3);
phi = xhat(1);
theta = xhat(2);
p = rates(1);
q = rates(2);
r = rates(3);
A(1,1) = q*cos(phi)*tan(theta) - r*sin(phi)*tan(theta);
A(1,2) = q*sin(phi)*sec(theta)^2 + r*cos(phi)*sec(theta)^2;
A(1,3) = 0;
A(2,1) = -q*sin(phi) - r*cos(phi);
A(2,2) = 0;
A(2,3) = 0;
A(3,1) = q*cos(phi)*sec(theta) - r*sin(phi)*sec(theta);
A(3,2) = q*sin(phi)*sec(theta)*tan(theta) + r*cos(phi)*sec(theta)*tan(theta);
A(3,3) = 0;
A = eye(3) + A*dt;
Matlab实现多类型卡尔曼滤波实例代码
需积分: 5 64 浏览量
2023-07-04
16:35:39
上传
评论
收藏 2.9MB ZIP 举报
缓下脚步
- 粉丝: 6125
- 资源: 23
最新资源
- Leawo Prof. Media 是一款全面的多媒体处理软件套装,旨在提供用户高效、全面的视频、音频和光盘工具
- 2405-1.09818
- OpenWrtImmortalWrt 官方 ImageBuilder 的自定义固件,使用 Docker 编译,无需配置编译环境
- Filmworkz Phoenix 是一款功能强大的视频编辑和后期处理软件,专为专业用户和电影制作人员设计
- 创建一个简单的待办事项(Todo)应用,其中包括添加、编辑和删除待办事项的功能
- 2018年国赛数模相关资料C题
- 2018年国赛数模相关资料D题
- 基于Node.js+MySQL开发的开源微信小程序商城(微信小程序)
- CyberLink ColorDirector Ultra 是一款专业的视频色彩校正与调整软件,旨在帮助用户轻松实现高质量的视频
- 跨平台WEB前端开发框架.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈