forked from Monteeee/LQR_Trees_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clipboard.txt
75 lines (50 loc) · 1.25 KB
/
clipboard.txt
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
72
73
74
75
mode = 1;
if mode == 1
tree_point = [0.1, 0.0; 0.3, -0.05; -0.15, 0.08]';
c_a = norm(xf-tree_point(:, 1)) * norm(xf-tree_point(:, 2)) * norm(xf-tree_point(:, 3));
c_b = [];
elseif mode == 2
tree_point = [d, 0.0, my_pi, 0.0;
d - 0.05, 0.0, my_pi - 0.05, 0.0;
d - 0.1, 0.08, my_pi + 0.03, -0.01 ]';
mul = 1.0;
for i = 1:size(tree_point, 2)
mul = mul * norm(xf-tree_point(:, i));
end
c_a = mul;
c_b = [];
else
c_a = [];
c_b = [];
end
mode = 1;
if mode == 1
x = x(1, :);
v = x(2, :);
k = 0.5;
m = 1.0;
dz = [v; -k/m * x + 1/m * u];
elseif mode == 2
m1 = 1.0;
m2 = 0.1;
g = 9.81;
l = 1.0;
d = 1.0;
dz = [ x(2) ;
( l*m2*sin(x(3))*x(4)^2 + u(1) + m2*g*cos(x(3))*sin(x(3)) ) / ( m1 + m2*(1 - (cos(x(3)))^2) );
x(4) ;
-( l*m2*cos(x(3))*sin(x(3))*x(4)^2 + u(1)*cos(x(3)) + (m1+m2)*g*sin(x(3)) ) / ( l*m1 + l*m2*(1 - (cos(x(3)))^2) ) ];
else
dz = [];
end
mode = 1;
if mode == 1
R = 1.0;
% Want slopes near zero, so minimize slope squared:
f = 1.0 + u.^2*R;
elseif mode == 2
R = 10.0;
f = 1.0 + u.^2*R;
else
f = 1.0 + u.^2;
end