-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDRONE_SANTANA.m
35 lines (25 loc) · 1.2 KB
/
DRONE_SANTANA.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
function dSTATE = DRONE_SANTANA(t,STATE,Simu)
global small_k;
gamma = Simu.sys.param;
psi=STATE(8);
M = [ gamma(1)*cos(psi), -gamma(3)*sin(psi), 0, 0;
gamma(1)*sin(psi), gamma(3)*cos(psi), 0, 0;
0, 0, gamma(5), 0;
0, 0, 0, gamma(7)];
N = [ gamma(2)*cos(psi), -gamma(4)*sin(psi), 0, 0;
gamma(2)*sin(psi), gamma(4)*cos(psi), 0, 0;
0, 0, gamma(6), 0;
0, 0, 0, gamma(8)];
R = [ cos(psi), -sin(psi), 0, 0;
sin(psi), cos(psi), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
n=length(N);
A=[-N*R' zeros(n);
eye(n) zeros(n)];
B=[M;zeros(n)];
[q_d,dq_d,ddq_d]=CalcDesTrajectory(Simu.trajectory,t);
V = CalcVirtControlLaw(Simu.controller,t,STATE,[dq_d;q_d]);
U=M\(V + N*R'*dq_d + ddq_d - small_k*(STATE(5:8)-q_d));
dSTATE = A*STATE + B*U;
end