Professional Documents
Culture Documents
http://matlabs.wordpress.com
http://matlabs.wordpress.com
F1y
q1
L1
G1
W1
F1x
F1x
A
F1y
F2 y
G2
q2
L2
& &&
B x, x, x
W2
F2x
F2x
F2 y
(1)
F
F
= F1x + F2 x = m2 &&
x2
= F1 y + F2 y + W2 = m2 &&
y2
(2)
http://matlabs.wordpress.com
2g
L2 F1 y sin (q 2 )
2
L2 F1x cos (q 2 )
2
L2 F2 x cos (q 2 )
2
L2 F2 y sin (q 2 )
2
= I 2 gq&&2
(3)
x2 , y2 l ta im G2.
Phng trnh lc ca xe l:
= - F2 x = mx&&
(4)
(5a)
(5b)
L1 sin (q1 ) +
L2
cos (q 2 ) = y2
2
(5c)
L2
sin (q 2 ) = x2
2
(5d)
- L1 cos (q1 ) +
2 21
Lq&&1 cos (q1 ) - L2q&&21 sin (q 2 ) - L1q&12 sin (q1 ) - L2q&22 cos (q 2 ) = 0
(6)
http://matlabs.wordpress.com
- L1 cos (q1 ) + L2 sin (q 2 ) = x
L q& sin (q ) + L q& cos (q ) = x&
1 1
2 21
(7)
L1q&&1 sin (q1 ) + L2q&&21 cos (q 2 ) + L q& cos (q1 ) - L q& sin (q 2 ) = &&
x
2
1 1
2
2 2
(8)
(9)
(10)
Dn ti vn tc gc ca cc khu l:
q&1 L1 cos (q1 )
=
q&2 L1 sin (q1 )
-1
- L2 sin (q 2 ) 0
L2 cos (q 2 ) x&
(11)
L1 sin (q1 )
=
L2 cos (q 2 ) q&&21 &&
x - L1q&12 cos (q1 ) + L2q&22 sin (q 2 )
(12)
http://matlabs.wordpress.com
Dn ti gia tc gc ca khu l:
q&&1 L cos (q1 )
=
&&
q 21 L1 sin (q1 )
- L2 sin (q 2 )
L2 cos (q 2 )
-1
&&
x - L1q&12 cos (q1 ) + L2q&22 sin (q 2 )
(13)
& =
y2 L q& cos (q ) - L2 q& sin (q )
1
21
2
1 1
2
(14)
&& =
y2 Lq&& cos (q ) - L2 q&& sin (q ) - L q& 2 sin (q ) - L2 q& 2 cos (q )
1
21
2
1 1
1
2
2
1
2
2
(15)
(16)
1 2
2
1
2
2
(17)
Dn n;
sin (q1 - q 2 ) =
L2 + x 2 - L12 - L22
2 L1 L2
(18)
t
K=
L2 + x 2 - L12 - L22
2 L1 L2
V vy;
5
(19)
http://matlabs.wordpress.com
q1 - q 2 = sin -1 ( K )
(20)
q1
L1
a2
a3
y a1
L
A
q2
L2
q1 =
(21a)
x
a1 = tan -1
L
(21b)
a 3 = a 2 - a1
(21c)
p
- a 3 and q 2 = q1 - sin -1 ( K )
2
(21d)
1
0
- L2 cos (q 2 ) / 2
- L1 cos (q1 )
0
1
L2 sin (q 2 ) / 2
0
x2
1
0
0 F1 y m2 &&
(22)
&&
0
1
0
F = m y - W2
2x 2 2
L2 cos (q 2 ) / 2 - L2 sin (q 2 ) / 2
0 F2 y I 2 gq&&2
-1
0
0 t mx&&
t
6
1
A= 0
- L2 cos (q 2 ) / 2
http://matlabs.wordpress.com
- L1 cos (q1 )
0
1
L2 sin (q 2 ) / 2
0
1
0
0
0
1
0
L2 cos (q 2 ) / 2 - L2 sin (q 2 ) / 2
0
-1
0
0
0
x2
m2 &&
&&
B = m2 y2 - W2
I 2 gq&&2
mx&&
(23)
http://matlabs.wordpress.com
1
1
V1 = - W1 L1 sin (q1 ) = - m1 gL1 sin (q1 )
2
2
(24)
(25)
(26)
Tnh ng nng
ng nng ca khu OA c tnh nh sau:
T1 =
1 &2
I10q1
2
(27)
1
1
1
I 2 gq&22 + m2 x&22 + m2 y& 22
2
2
2
(28)
1 2
mx&
2
(29)
, m l khi lng ca xe
8
http://matlabs.wordpress.com
1 &2 1
1
1
1
I10q1 + I 2 gq&22 + m2 x&22 + m2 y& 22 + mx& 2
2
2
2
2
2
(30)
(31)
dt q& j
4
L
G
+ li i = Q j
q j i =1 q j
(32)
v Gi , i = 1, 2,3, 4 l cc phng trnh rng buc, trong khi li , i = 1, 2,3, 4 l nhn t Lagrange.
Lc suy rng, Q j , j = 1, 2,3, 4,5 c tnh nh sau (b qua ma st ca cc khp):
Q1 = t
Q2 = 0
Q3 = 0
Q4 = 0
Q5 = 0
http://matlabs.wordpress.com
fq 1 =
L
= fq 1 q1 , q 2 , x2 , y2 , x, q&1 , q&2 , x&2 , y& 2 , x&
q&1
fq 2 =
L
= fq 2 q1 , q 2 , x2 , y2 , x, q&1 , q&2 , x&2 , y& 2 , x&
q&2
f x2 =
L
= f x 2 q1 , q 2 , x2 , y2 , x, q&1 , q&2 , x&2 , y& 2 , x&
x&2
f y2 =
L
= f y 2 q1 , q 2 , x2 , y2 , x, q&1 , q&2 , x&2 , y& 2 , x&
y& 2
fx =
L
= f x q1 , q 2 , x2 , y2 , x, q&1 , q&2 , x&2 , y& 2 , x&
x&
)
)
fq 1 && fq 1 && fq 1
f
f
&&
q1 +
q2 +
x2 + q 1 &&
y2 + q 1 &&
x
x&2
y& 2
x&
q&1
q&2
d L
dt q&2
y
x
1
2
2
2
f
f
f
f
f
+ q 2 q&&1 + q 2 q&&2 + q 2 &&
x2 + q 2 &&
y2 + q 2 &&
x
x&2
y& 2
x&
q&1
q&2
d L
dt x&2
df x 2 f x 2 & f x 2 & f x 2
f
f
=
q1 +
q2 +
x&2 + x 2 y& 2 + x 2 x& +
=
dt
y
x
1
2
2
2
f
f
f
f
f
+ x 2 q&&1 + x 2 q&&2 + x 2 &&
x2 + x 2 &&
y2 + x 2 &&
x
&
&
&
&
x2
y2
x&
q1
q 2
f y 2
f y 2
d L df y 2 f y 2 & f y 2 & f y 2
=
q1 +
q2 +
x&2 +
y& 2 +
x& +
=
&
dt y2
dt
q1
q 2
x2
y2
x
f y 2 && f y 2 && f y 2
f y 2
f y 2
&&
&&
&&
+
q1 +
q2 +
x2 +
y2 +
x
&
&
&
&
y
x&
q
q
1
f
f
d L df x f x & f x & f x
=
=
q1 +
q2 +
x&2 + x y& 2 + x x& +
dt x& dt
q1
q 2
x2
y2
x
+
f x && f x && f x
f
f
&&
q1 +
q2 +
x2 + x &&
y2 + x &&
x
&
&
&
&
y
x&
q1
q 2
2
2
10
(33)
http://matlabs.wordpress.com
Tm cc nhn t Lagrange
Cc nhn t Lagrange li tng ng vi cc phng trnh rng buc Gi . o hm nhng phng
trnh rng buc ny theo cc ta suy rng, dn ti:
G1 G1 G1 G1 G1
,
,
,
,
q1 q 2 x2 y2
x
G 2 G 2 G 2 G 2 G 2
,
,
,
,
q1 q 2 x2
y2
x
G3 G3 G3 G3 G3
,
,
,
,
q1 q 2 x2
y2
x
G 4 G 4 G 4 G 4 G 4
,
,
,
,
q1 q 2 x2
y2
x
Pht trin phng trnh (32) cho cc ta suy rng q 2 , x2 , y2 , x thu c cc phng trnh
sau:
l1
G1
G
G
G
d L
+ l2 2 + l3 3 + l4 4 = -
q 2
q 2
q 2
q 2
dt q&2
L
+ q + Q2
2
(34a)
l1
G1
G
G
G
d L
+ l2 2 + l3 3 + l4 4 = -
x2
x2
x2
x2
dt x&2
L
+ Q3
+
x2
(34b)
l1
G1
G
G
G
d L L
+ l2 2 + l3 3 + l4 4 = -
+ Q4
+
y2
y2
y 2
y2
dt y& 2 y2
(34c)
l1
G
G1
G
G
d L L
+ l2 2 + l3 3 + l4 4 = - +
+ Q5
x
x
x
x
dt x& x
(34d)
11
http://matlabs.wordpress.com
,
G1
q
2
G1
x
A= 2
G1
y2
G
1
x
G 2
q 2
G 3
q 2
G 2
x2
G3
x2
G 2
y2
G3
y2
G 2
x
G3
x
d L L
G 4
- Q2
- & +
dt q 2 q 2
q 2
G 4
- d L + L - Q
3
dt x&2 x2
x2
, B=
G 4
d L L
- Q4
-
+
y2
&
dt y2 y2
G 4
- d L + L - Q5
x
dt x& x
G
G
G
d L L G1
+ l1
+ l2 2 + l3 3 + l4 4
& dt q1 q1 q1
q1
q1
q1
(35)
200
300
350
200
250
600
0.03
0.04
9.81
12
http://matlabs.wordpress.com
Hnh 3 Qu o ca xe
Kt qu ca phng php ng lc hc Newton
http://matlabs.wordpress.com
14
http://matlabs.wordpress.com
Kt lun
Kt qu m phng trn phn mm Matlab cho thy, cc m men ch ng ca khu OA quanh
gc O ging nhau i vi c hai phng php ng lc hc Newton v Lagrange. Nh vy
phng trnh ng lc hc ca c cu trn hnh 1 c th c s dng phn tch v thit k h
thng iu khin.
15
http://matlabs.wordpress.com
0.5*L2*cos(th2(i))]*dth;
-0.5*L2*sin(th2(i))]*dth;
16
http://matlabs.wordpress.com
A3 = [-L1*sin(th1(i))
-L1*cos(th1(i))
1
0
0
1
-0.5*L2*cos(th2(i))
0.5*L2*sin(th2(i))
0
0
W1 = m1*g;
W2 = m2*g;
B3 = [I0*ddth1(i) - 0.5*L1*W1*cos(th1(i));
m2*ddx2(i);
m2*ddy2(i) - W2;
I2g*ddth2(i);
m*ddx];
0
1
0
0.5*L2*cos(th2(i))
-1
0
0
1
-0.5*L2*sin(th2(i))
0
if det(A3) == 0
s = zeros(5,1);
else
s = inv(A3)*B3;
end
f1x(i) = s(1);
f1y(i) = s(2);
f2x(i) = s(3);
f2y(i) = s(4);
tou1n(i) = s(5); % torque
end
figure(1)
plot(tf,tou1n)
xlabel('time(sec)')
ylabel('torque of joint 1 (Nm)')
legend('Newton method')
17
1;
0;
0;
0;
0];
http://matlabs.wordpress.com
-L2*sin(th2(i));
L2*cos(th2(i))];
dth1(i) = dth(1);
dth2(i) = dth(2);
% acceleration
xdd = addx(i);
A2 = [L1*cos(th1(i))
-L2*sin(th2(i));
L1*sin(th1(i))
L2*cos(th2(i))];
B2 = [L1*dth1(i)^2*sin(th1(i)) + L2*dth2(i)^2*cos(th2(i));
xdd - L1*dth1(i)^2*cos(th1(i)) + L2*dth2(i)^2*sin(th2(i))];
if det(A2) == 0
ddth = zeros(2,1);
else
ddth = inv(A2)*B2;
end
ddth1(i) = ddth(1);
ddth2(i) = ddth(2);
dx2(i) = [L1*sin(th1(i))
dy2(i) = [L1*cos(th1(i))
0.5*L2*cos(th2(i))]*dth;
-0.5*L2*sin(th2(i))]*dth;
figure(2)
plot(tf,tou1t)
xlabel('time(sec)')
ylabel('torque of joint 1 (Nm)')
legend('Lagrange method')
C. Thit k qu o ca xe
% This file is to generate trajectory of vehicle
function [theta, velocity, acc]=inter_2point(th, vel, acc, t0, t1, step_t )
t0,
1,
0,
t0^2,
t0^3,
t0^4,
t0^5;
2*t0, 3*t0^2,
4*t0^3,
5*t0^4;
2,
6*t0, 12*t0^2, 20*t0^3;
18
t1,
1,
0,
t1^2,
2*t1,
2,
t1^3,
3*t1^2,
6*t1,
http://matlabs.wordpress.com
t1^4,
4*t1^3,
12*t1^2,
t1^5;
5*t1^4;
20*t1^3];
theta=a(1)+a(2).*t+a(3).*t.^2+a(4).*t.^3+a(5).*t.^4+a(6).*t.^5;
velocity=a(2)+2.*a(3).*t+3.*a(4).*t.^2+4.*a(5).*t.^3+5.*a(6).*t.^4;
acc=2.*a(3)+6.*a(4).*t+12.*a(5).*t.^2+20.*a(6).*t.^3;
19