net/publication/320146369
Sistem Dinamik
CITATIONS READS
0 1,659
1 author:
Indrazno Siradjuddin
Politeknik Negeri Malang
122 PUBLICATIONS 401 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Indrazno Siradjuddin on 01 October 2017.
L = T −V (1)
dimana L adalah fungsi Lagrange, T adalah energi kinetik dan V adalah energi
potensial. Untuk sistem konservatif (tidak ada energi yang hilang) maka per-
samaan gerak (an equation of motion) dapat dihasilkan dari diferensial dari fungsi
Lagrange, hasil persamaan berikut ini disebut juga Lagrange’s equation
d ∂L ∂L
− = 0 (2)
dt ∂ q̇i ∂qi
1
tanpa mengihangkan arti, untuk itu koordinat dari sistem pegas q1 = q = x.
Persamaan Lagrange untuk kasus sistem pegas menjadi
d ∂L ∂L
− = 0 (3)
dt ∂ ẋ ∂x
dimana ẋ adalah turunan pertama dari x. Energi kinetik T dari sistem pegas
adalah
1
T = mẋ2 (4)
2
sedangkan energi potensial V dari sistem pegas adalah
1 2
V = kx − mg(l + x) (5)
2
dimana k adalah konstanta pegas dengan satuan N/m dan l adalah panjang pegas.
Lebih lanjut, turunan pertama fungsi Lagrange didapatkan persamaan sebagai
berikut:
!
d ∂ 21 mẋ2 − 12 kx2 + mg(l + x)
d ∂L
= (6)
dt ∂ ẋ dt ∂ ẋ
= mẍ (7)
∂ 12 mẋ2 − 21 kx2 + mg(l + x)
∂L
= (8)
∂x ∂x
= −kx + mg (9)
mẍ + kx − mg = 0 (10)
mẍ = mg − kx (11)
3
1.4 Gaya redaman
Model dan simulasi sistem pegas diatas adalah diturunkan berdasarkan asumsi
tidak ada gaya eksternal yang mempengaruhi sistem. Sesungguhnya, pendekatan
yang lebih realistis adalah bahwa sistem pegas tidak selamanya akan berosilasi
terus menerus, melainkan lambat laun osilasi akan berkurang/teredam sehingga
pegas akan kembali pada posisi normal (rest). Oleh sebab itu sistem pegas bukan
merupakan sistem konservatif. Gaya redaman yang dinotasikan fd adalah propor-
sional dengan kecepatan, dapat dirumuskan sebagai berikut
fd = −cẋ (16)
dimana Qi adalah gaya eksternal. Sebagai perbandingan dengan sistem yang kon-
servatif, nilai Qi adalah sama dengan nol. Untuk kasus sistem pegas maka
d ∂L ∂L
− = −cẋ (18)
dt ∂ ẋ ∂x
dengan cara yang sama seperti diatas, maka diperoleh persamaan gerak dinamik
pegas sebagai berikut
4
15 r e t u r n [ xd , xdd ]
16
5
2 Sistem Pergerakan Pendulum Pegas
Energi kinetik total sistem pendulum pegas adalah merupakan gabungan antara
energi kinetik translasi (tangensial atau translational) dan rotasi (radial atau ro-
tational)
1 2 2 2
T = m ẋ + (l + x) θ̇ (20)
2
Catatan: Energi kinetik untuk benda berputar dengan jarak dari titik pusat r
adalah
1 2
Tr = Iω (21)
2
dimana I adalah momen inersia dan ω adalah kecepatan putaran (ω = θ̇). Jika
masa pegas diabaikan, maka momen inersia dari pendulum pegas adalah
I = mr2 (22)
untuk kasus pendulum pegas, r = (l + x). Energi potensial sistem pendulum pegas
diakibatkan oleh gravitasi dan sifat pegas itu sendiri, dituliskan sebagai berikut
1
V = −mg(l + x) cos θ + kx2 (23)
2
Fungsi Lagrange sistem pendulum pegas dapat diformulasikan sebagai berikut
1 2 1
L = m ẋ + (l + x) θ̇ + mg(l + x) cos θ − kx2
2 2
(24)
2 2
6
Dapat diketahui dari persamaan diatas bahwa terdapat dua sistem koordinat pada
sistem pendulum pegas yaitu sistem koordinat translasi yang direpresentasikan
oleh x dan sistem koordinat rotasi yang direpresentasikan oleh θ. Sehingga per-
samaan Lagrange pada kedua koordinat tersebut dapat diformulasikan sebagai
berikut, terhadap x
d ∂L ∂L
− = 0 (25)
dt ∂ ẋ ∂x
(mẍ) − (m(l + x)θ̇2 + mg cos θ − kx) = 0 (26)
2 kx
ẍ = (l + x)θ̇ − g cos θ + (27)
m
dan terhadap θ
d ∂L ∂L
= (28)
dt ∂ θ̇ ∂θ
d
m(l + x)2 θ̇ = −mg(l + x) sin θ (29)
dt
2
m(l + x) θ̈ + 2m(l + x)ẋθ̇ = −mg(l + x) sin θ (30)
(l + x)θ̈ + 2ẋθ̇ = −g sin θ (31)
(g sin θ + 2ẋθ̇)
θ̈ = − (32)
(l + x)
3 DO NEXT!!!
1. Python code to simulate the spring pendulum
3. Python code to simulate the spring pendulum with the damping force
7
4 Single Joint Elbow Kinematic
Kinematic terdiri dari forward kinematic dan inverse kinematic. Dalam kinemat-
ics, akan dipelajari hubungan atau fungsi yang memetakan input (input space)
atau join robot (joint space) untuk robot manipulator menjadi output (output
space) atau task space atau work space. Gambar 5 adalah contoh sederhana dari
sistem 1 DOF (degrees of freedom) dimana jumlah input hanya satu yaitu sebuah
motor pada posisi (0, 0) atau base, yang menggerakkan lengan l. Gerakkan putaran
motor (dalam hal ini ditunjukkan oleh posisi sudut θ) ditujukan untuk mempo-
sisikan ujung lengan (end-effector) pada posisi koordinat tertentu yang dinotasikan
oleh (xe , ye ). Dengan trigonometri dapat dengan mudah didapatkan
xe = l cos θ (33)
ye = l sin θ (34)
Problem pada inverse kinematic adalah untuk mencari posisi sudut motor θ jika
dinginkan posisi end-effector pada (xe , ye ). Inverse kinematic dari kasus ini dapat
dihitung dengan
ye
tan θ = (35)
xe
ye
θ = arctan (36)
xe
8
4 theta = s i n (2∗ pi ∗ t /4)
5 figure ()
6 subplot (2 ,4 ,(1 ,2) )
7 p l o t ( t , t h e t a ∗180/ p i )
8 x l a b e l ( ’TIME ( s e c ) ’ )
9 y l a b e l ( ’ELBOW ANGLE ( deg ) ’ )
10 # compute hand p o s i t i o n Hx , Hy
11 l = 0.45
12 Hx = l ∗ c o s ( t h e t a )
13 Hy = l ∗ s i n ( t h e t a )
14 subplot (2 ,4 ,(5 ,6) )
15 p l o t ( t , Hx , ’ b− ’ )
16 p l o t ( t , Hy , ’ r− ’ )
17 x l a b e l ( ’TIME ( s e c ) ’ )
18 y l a b e l ( ’HAND POSITION (m) ’ )
19 l e g e n d ( ( ’Hx ’ , ’Hy ’ ) , l o c= ’ l o w e r r i g h t ’ )
20 subplot (2 ,4 ,(3 ,8) )
21 p l o t ( ( 0 , Hx [ 0 ] ) , ( 0 , Hy [ 0 ] ) , ’ g− ’ )
22 p l o t ( ( 0 , Hx[ − 1 ] ) , ( 0 , Hy[ − 1 ] ) , ’ r− ’ )
23 p l o t (Hx [ 0 : − 1 : 1 0 ] , Hy [ 0 : − 1 : 1 0 ] , ’ k . ’ )
24 x l a b e l ( ’X (m) ’ )
25 y l a b e l ( ’Y (m) ’ )
26 axis ( ’ equal ’ )
27 pylab . s a v e f i g ( ” t e s t 1 d o f . svg ” )
Program 3: Simulasi kinematics 1 DOF
9
5 2 DOF Kinematic
x1 = l1 cos θ1 (37)
y1 = l1 sin θ1 (38)
x2 = l1 cos θ1 + l2 cos(θ1 + θ2 ) (39)
y2 = l1 sin θ1 + l2 sin(θ1 + θ2 ) (40)
10
19 # sample a l l c o m b i n a t i o n s and p l o t j o i n t and hand c o o r d i n a t e s
20 f=f i g u r e ( f i g s i z e =(8 ,12) )
21 f o r i in range ( n1steps ) :
22 f o r j in range ( n2steps ) :
23 subplot (2 ,1 ,1)
24 p l o t ( a 1 r a n g e [ i ] ∗ 1 8 0 / pi , a 2 r a n g e [ j ] ∗ 1 8 0 / pi , ’ r+ ’ )
25 ex , ey , hx , hy = j o i n t s t o h a n d ( a 1 r a n g e [ i ] , a 2 r a n g e [ j ] , l 1 , l 2 )
26 subplot (2 ,1 ,2)
27 p l o t ( hx , hy , ’ r+ ’ )
28 subplot (2 ,1 ,1)
29 x l a b e l ( ’ S h o u l d e r Angle ( deg ) ’ )
30 y l a b e l ( ’ Elbow Angle ( deg ) ’ )
31 t i t l e ( ’ J o i n t Space ’ )
32 subplot (2 ,1 ,2)
33 x l a b e l ( ’ Hand P o s i t i o n X (m) ’ )
34 y l a b e l ( ’ Hand P o s i t i o n Y (m) ’ )
35 t i t l e ( ’ Hand Space ’ )
36 a1 = a 1 r a n g e [ n 1 s t e p s / 2 ]
37 a2 = a 2 r a n g e [ n 2 s t e p s / 2 ]
38 ex , ey , hx , hy = j o i n t s t o h a n d ( a1 , a2 , l 1 , l 2 )
39 subplot (2 ,1 ,1)
40 p l o t ( a1 ∗180/ pi , a2 ∗180/ pi , ’ bo ’ , m a r k e r s i z e =5)
41 axis ( ’ equal ’ )
42 x l = g e t ( g e t ( f , ’ a x e s ’ ) [ 0 ] , ’ xlim ’ )
43 y l = g e t ( g e t ( f , ’ a x e s ’ ) [ 0 ] , ’ ylim ’ )
44 p l o t ( ( x l [ 0 ] , x l [ 1 ] ) , ( a2 ∗180/ pi , a2 ∗180/ p i ) , ’ b− ’ )
45 p l o t ( ( a1 ∗180/ pi , a1 ∗180/ p i ) , ( y l [ 0 ] , y l [ 1 ] ) , ’ b− ’ )
46 subplot (2 ,1 ,2)
47 p l o t ( ( 0 , ex , hx ) , ( 0 , ey , hy ) , ’ b− ’ )
48 p l o t ( hx , hy , ’ bo ’ , m a r k e r s i z e =5)
49 axis ( ’ equal ’ )
50 x l = g e t ( g e t ( f , ’ a x e s ’ ) [ 1 ] , ’ xlim ’ )
51 y l = g e t ( g e t ( f , ’ a x e s ’ ) [ 1 ] , ’ ylim ’ )
52 p l o t ( ( x l [ 0 ] , x l [ 1 ] ) , ( hy , hy ) , ’ b− ’ )
53 p l o t ( ( hx , hx ) , ( y l [ 0 ] , y l [ 1 ] ) , ’ b− ’ )
54 pylab . s a v e f i g ( ” t e s t 2 d o f . svg ” )
Program 4: Simulasi kinematics 1 DOF
11
Gambar 8: Hasil simulasi 2 DOF lengan robot
5.2 Jacobian
Working space atau task space ξ = [x, y]T dan input space atau joint space θ =
[θ1 , θ2 ]T . Forward kinematic
ξ = f (θ) (41)
merupakan hubungan posisi sudut pada join θ dengan posisi end-effector ξ pada
Euclidean space. Dengan mencari turunan pertama dari fungsi forward kine-
matic, hubungan kecepatan sudut pada join dengan kecepatan end-effector pada
12
taskspace dapat diketahui
dξ df (θ)
= (42)
dt dt
dξ ∂f (θ) dθ
= (43)
dt ∂θ dt
ξ̇ = Jθ̇ (44)
dimana J disebut sebagai matriks Jacobian. Untuk kasus 2 DOF, matriks Jacobian
dapat dicari dengan
∂f (θ)x ∂f (θ)x
∂θ1 ∂θ2
J = (45)
∂f (θ) ∂f (θ)
y y
∂θ1 ∂θ2
Tuliskan program Python dibawah ini untuk menghitung secara simbolik kompo-
nen matriks J
1 # import sympy
2 from sympy import ∗
3 # d e f i n e t h e s e v a r i a b l e s a s s y m b o l i c ( not numeric )
4 a1 , a2 , l 1 , l 2 = symbols ( ’ a1 a2 l 1 l 2 ’ )
5 # a1 and a2 r e p r e s e n t t h e t a 1 and t h e t a 2 , r e s p e c t i v e l y
6 # f o r w a r d k i n e m a t i c s f o r Hx and Hy
7 f x = l 1 ∗ c o s ( a1 ) + l 2 ∗ c o s ( a1+a2 )
8 f y = l 1 ∗ s i n ( a1 ) + l 2 ∗ s i n ( a1+a2 )
9 # u s e sympy d i f f ( ) t o g e t p a r t i a l d e r i v a t i v e s f o r J a c o b i a n matrix
10 J11 = d i f f ( fx , a1 )
11 J12 = d i f f ( fx , a2 )
12 J21 = d i f f ( fy , a1 )
13 J22 = d i f f ( fy , a2 )
14 p r i n t J11
15 p r i n t J12
16 p r i n t J21
17 p r i n t J22
Program 5: Menghitung secara simbolik komponen matrix J
akan didapatkan hasil matriks Jacobian J sebagai berikut
−l1 sin(θ1 ) − l2 sin(θ1 + θ2 ) −l2 sin(θ1 + θ2 )
J = (46)
l1 cos(θ1 ) + l2 cos(θ1 + θ2 ) l2 cos(θ1 + θ2 )
13
1 from sympy import ∗
2 from numpy import ∗
3 d e f j a c o b i a n (A, aparams ) :
4 ”””
5 Given j o i n t a n g l e s A=(a1 , a2 )
6 r e t u r n s t h e J a c o b i a n matrix J ( q ) = d f /dA
7 ”””
8 l 1 = aparams [ ’ l 1 ’ ]
9 l 2 = aparams [ ’ l 2 ’ ]
10 dFxdA1 = −l 1 ∗ s i n (A [ 0 ] ) − l 2 ∗ s i n (A[ 0 ] +A [ 1 ] )
11 dFxdA2 = −l 2 ∗ s i n (A[ 0 ] +A [ 1 ] )
12 dFydA1 = l 1 ∗ c o s (A [ 0 ] ) + l 2 ∗ c o s (A[ 0 ] +A [ 1 ] )
13 dFydA2 = l 2 ∗ c o s (A[ 0 ] +A [ 1 ] )
14 J = matrix ( [ [ dFxdA1 , dFxdA2 ] , [ dFydA1 , dFydA2 ] ] )
15 return J
16
17 aparams = { ’ l 1 ’ : 0 . 3 3 8 4 , ’ l 2 ’ : 0 . 4 5 5 4 }
18 A = a r r a y ( [ 4 5 . 0 , 9 0 . 0 ] ) ∗ p i /180 # joint angles
19 Ad = matrix ( [ [ − 5 . 0 ] , [ 3 . 0 ] ] ) ∗ p i /180 # j o i n t v e l o c i t i e s
20 J = j a c o b i a n (A, aparams )
21 Hd = J∗Ad
22 p r i n t Hd
Program 6: Velocity kinematic
Kecepatan end-effector dihitung jika diketahui θ1 = 45◦ , θ2 = 90◦ , θ̇1 = −5◦ s−1
dan θ̇2 = 3◦ s−1 dan dihasilkan ẋ = 0.03212204 m s−1 dan ẋ = −0.00964106 m s−1 .
d d
ξ̇ = ξ̈ = Jθ̇ (47)
dt dt
d d
= J θ̇ + θ̇ (J) (48)
dt dt
= Jθ̈ + J̇θ̇ (49)
14
dimana
d d
(j1,1 ) = (−l1 sin(θ1 ) − l2 sin(θ1 + θ2 )) (51)
dt dt
= −l1 cos(θ1 )θ˙1 − l2 cos(θ1 + θ2 )θ˙1 − l2 cos(θ1 + θ2 )θ˙2 (52)
d d
(j1,2 ) = (−l2 sin(θ1 + θ2 )) (53)
dt dt
= −l2 cos(θ1 + θ2 )θ̇1 − l2 cos(θ1 + θ2 )θ̇2 (54)
d d
(j2,1 ) = (l1 cos(θ1 ) + l2 cos(θ1 + θ2 )) (55)
dt dt
= −l1 sin(θ1 )θ̇1 − l2 sin(θ1 + θ2 )θ̇1 − l2 sin(θ1 + θ2 )θ̇2 (56)
d d
(j2,2 ) = (l2 cos(θ1 + θ2 )) (57)
dt dt
= −l2 sin(θ1 + θ2 )θ̇1 − l2 sin(θ1 + θ2 )θ̇2 (58)
15
Linear/Translational Kinetic Energy:
1 2
T1 = mv (61)
2
1
= m(ẋ2 + ẏ 2 ) (62)
2
Rotational Kinetic Energy:
1 2
T2 = I θ̇ (63)
2
Total Kinetic Energy:
T = T1 + T2 (64)
1 1
= m(ẋ2 + ẏ 2 ) + I θ̇2 (65)
2 2
Dengan mentransformasikan koordinat titik pusat massa m, (x, y) → (r, θ) yang
dapat diperoleh dengan cara sebagai berikut,
x = r sin(θ) (66)
y = −r cos(θ) (67)
ẋ = r cos (θ)θ̇ (68)
ẏ = r sin (θ)θ̇ (69)
V = mgh (73)
16
Dengan demikian fungsi Lagrange dapat ditulis sbg berikut
L = T −V (75)
1 2 2 1 2
= mr θ̇ + I θ̇ − mgr(1 − cos(θ)) (76)
2 2
Untuk dapat merumuskan derivative dari fungsi Lagrange, perlu diketahui
∂L
= mgr sin(θ) (77)
∂θ
dan
∂L
= mr2 θ̇ + I θ̇ (78)
∂ θ̇
dan
d ∂L
= mr2 θ̈ + I θ̈ (79)
dt ∂ θ̇
Dalam kasus ini koordinat system hanya satu yaitu θ, persamaan EULER-LAGRANGE
dapat ditulis sebagai berikut
d ∂L ∂L
− = Q (80)
dt ∂ θ̇ ∂θ
dalam hal Q adalah torque yang diberikan kepada system. Dengan kata lain, hal
ini dapat digunakan untuk menjawab pertanyaan, ”berapa torque yang dibutuhkan
untuk mengahasilkan state dinamik yang diinginkan”.
17
9 i = 0.025 # moment o f i n e r t i a ( kg m m)
10 t h e t a d d o t = −(m∗g ∗ r ∗ s i n ( t h e t a ) ) / ( i + (m∗ r ∗ r ) )
11 return [ theta dot , theta ddot ]
12
13 t = linspace (0.0 ,10.0 ,1001) # 10 s e c o n d s sampled a t 1000 Hz
14 s t a t e 0 = [ 9 0 . 0 ∗ p i / 1 8 0 . 0 , 0 . 0 ] # 90 deg i n i t i a l a n g l e , 0 deg / s e c
i n i t i a l velocity
15 s t a t e = odeint ( onejointarm , state0 , t )
16 print state
17 figure ()
18 p l o t ( t , s t a t e ∗180/ p i )
19 legend (( ’ thetadot ’ , ’ thetaddot ’ ) )
20 x l a b e l ( ’TIME ( s e c ) ’ )
21 y l a b e l ( ’THETA DOT ( deg ) & THETA DDOT ( deg / s e c ) ’ )
22 pylab . s a v e f i g ( ” t e s t 1 d o f d y n a m i c . svg ” )
Program 7: Simulasi dinamik 1 DOF
Hasil plot
18
12 step = 3
13 f o r i i n xrange ( 1 , shape ( s t a t e ) [ 0 ] − 1 0 , s t e p ) :
14 p . set xdata ((0 , l ∗ sin ( state [ i , 0 ] ) ) )
15 p . s e t y d a t a ((0 , − l ∗ c o s ( s t a t e [ i , 0 ] ) ) )
16 t t . s e t t e x t ( ” %4.2 f s e c ” % ( i ∗ 0 . 0 1 ) )
17 draw ( )
18
19 t = linspace (0.0 ,10.0 ,1001)
20 s t a t e = odeint ( onejointarm , state0 , t )
21 animate arm ( s t a t e , t )
Program 8: Simulasi dinamik 1 DOF
19
8 Motor Control: Muscle
20