forked from rodralez/NaveGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pos_update.m
executable file
·71 lines (63 loc) · 1.96 KB
/
pos_update.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function pos = pos_update(pos, vel, dt)
% pos_update: updates position in the navigation frame.
%
% Copyright (C) 2014, Rodrigo Gonzalez, all rights reserved.
%
% This file is part of NaveGo, an open-source MATLAB toolbox for
% simulation of integrated navigation systems.
%
% NaveGo is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License (LGPL)
% version 3 as published by the Free Software Foundation.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this program. If not, see
% <http://www.gnu.org/licenses/>.
%
% References:
% Titterton, D.H. and Weston, J.L. (2004). Strapdown
% Inertial Navigation Technology (2nd Ed.). Institution
% of Engineering and Technology, USA. Eq. 3.79-3.81.
%
% R. Gonzalez, J. Giribet, and H. Patiño. NaveGo: a
% simulation framework for low-cost integrated navigation systems,
% Journal of Control Engineering and Applied Informatics, vol. 17,
% issue 2, pp. 110-120, 2015. Eq. 18.
%
% Version: 002
% Date: 2015/07/18
% Author: Rodrigo Gonzalez <rodralez@frm.utn.edu.ar>
% URL: https://github.com/rodralez/navego
lat_old = pos(1);
lon_old = pos(2);
hc = (pos(3));
v_n = vel(1);
v_e = vel(2);
v_d = vel(3);
%% Altitude
h = (hc - (v_d * dt));
if h < 0
h = 0;
end
%% Latitude
if (isa(hc,'single'))
[RM,~] = radius(lat_old, 'single');
else
[RM,~] = radius(lat_old, 'double');
end
lat = (lat_old + ( v_n / (RM + (h)) ) * dt);
%% Longitude
if (isa(hc,'single'))
[~, RN] = radius(lat, 'single');
else
[~, RN] = radius(lat, 'double');
end
lon = (lon_old + (v_e / ((RN + h) * cos (lat))) * dt );
%% Pos
pos = [lat lon h]';
end