-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathErrorFeedback.m
38 lines (32 loc) · 1.31 KB
/
ErrorFeedback.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
% -------------------------------------------------------------------------
% KF-GINS-Matlab: An EKF-based GNSS/INS Integrated Navigation System in Matlab
%
% Copyright (C) 2024, i2Nav Group, Wuhan University
%
% Author : Liqiang Wang
% Contact : [email protected]
% Date : 2023.3.3
% -------------------------------------------------------------------------
function [kf, navstate] = ErrorFeedback(kf, navstate)
% position and velocity
DR = diag([navstate.Rm + navstate.pos(3), (navstate.Rn + navstate.pos(3))*cos(navstate.pos(1)), -1]);
DR_inv = inv(DR);
navstate.pos = navstate.pos - DR_inv * kf.x(1:3, 1);
navstate.vel = navstate.vel - kf.x(4:6, 1);
% attitude
qpn = rotvec2quat(kf.x(7:9, 1));
navstate.qbn = quatProd(qpn, navstate.qbn);
navstate.cbn = quat2dcm(navstate.qbn);
navstate.qtt = dcm2euler(navstate.cbn);
% imu error
navstate.gyrbias = navstate.gyrbias + kf.x(10:12, 1);
navstate.accbias = navstate.accbias + kf.x(13:15, 1);
navstate.gyrscale = navstate.gyrscale + kf.x(16:18, 1);
navstate.accscale = navstate.accscale + kf.x(19:21, 1);
% update some parameters
param = Param();
[navstate.Rm, navstate.Rn] = getRmRn(navstate.pos(1), param);
navstate.gravity = getGravity(navstate.pos);
% reset state vector
kf.x = zeros(kf.RANK, 1);
end