-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfx
More file actions
59 lines (48 loc) · 1.23 KB
/
fx
File metadata and controls
59 lines (48 loc) · 1.23 KB
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
% define system
% x = [px, py, vx, vy]'
% y = [range, bearing]'
% n = [nx, ny]'
% u = [ux, uy]'
% r = [rd, ra]'
% px+ = px + vx *dt
% py+ = py + vy * dt
% vx+ = vx + ax*dt + nx
% vy+ = vy + ay*dt + ny
%
% range = sqrt(px^2 + py^2) + rd
% bearing = atan2(py, px) + ra
function [xo, XO_x, XO_u, XO_n] = ex02_f(x, u, n, dt)
px = x(1);
py = x(2);
vx = x(3);
vy = x(4);
ax = u(1);
ay = u(2);
nx = n(1);
ny = n(1);
px = px + vx * dt
py = py + vy * dt
vx = vx + ax * dt + nx
vy = vy + ay * dt + ny
xo = [px;py;vx;vy];
if nargout > 1 % we want jacobians
% transition jacobians
XO_x = [...
1 0 dt 0
0 1 0 dt
0 0 1 0
0 0 0 1];
% control jacobians
XO_u = [...
0 0
0 0
dt 0
0 dt];
% perturbation Jacobias
XO_n = [...
0 0
0 0
1 0
0 1];
end
end