Lecture5 Dynamics
Lecture5 Dynamics
Autumn 2016
Lecture 5:
Robot dynamics and simulation
Allison Okamura
Stanford University
Robot dynamics
equations of motion
describe the relationship between forces/torques and
motion (in joint space or workspace variables)
@qj
where j = 1, 2, . . . , n , and q̇j = is the generalized
@t
velocity and j is the nonconservative generalized
Q
force corresponding to the generalized coordinate qj
what are generalized coordinates?
• equations of motion can be formalized in a
number of different coordinate systems
@qj
where q̇ = j is the generalized velocity and Q is the nonconservative
j
If there is more than one set of variables in the functional f (e.g. yi and ẏi )
then you get one equation for each set.
T = 2 q̇ M q̇
L=T V
Substitute:
@L @T @V
@ q̇j = @ q̇j @ q̇j
@L @T
Last term is zero because P.E. is not dependent on velocities ! @ q̇j = @ q̇j
@L @T @V
@qj = @qj @qj
d @T @T @V
dt ( @ q̇j ) @qj + @qj = Qj , where j = 1, 2, . . . , n
Kinetic energy:
Potential energy
T = 12 m1 (l1 ✓˙1 )2 + 12 m2 ((l1 ✓˙1 cos(✓1 )+l2 ✓˙2 cos(✓2 ))2 +(l1 ✓˙1 sin(✓1 )+l2 ✓˙2
V = m1 gl1 (1 cos(✓1 )) + m2 g(l1 (1 cos(✓1 )) + l2 (1 cos(✓2 )))
For ✓1 :
@L
= m l 2 ✓˙ + m l2 ✓˙ + m l l ✓˙ cos(✓ ✓2 )
@ ✓˙1 1 1 1 2 1 1 2 1 2 2 1
⇣ ⌘
d @L
= (m1 +m 2 )l 2✓¨1 +m2 l1 l2 ✓¨2 cos(✓1 ✓2 ) m2 l1 l2 ✓˙2 sin(✓1 ✓2 )(✓˙1 ✓˙2 )
dt @ ✓˙ 1
1
@L
@✓1 = l1 g(m1 + m2 ) sin(✓1 ) m2 l1 l2 ✓˙1 ✓˙2 sin(✓1 ✓2 )
Similarly, for ✓2 :
@L
= m l 2 ✓˙ + m l l ✓˙ cos(✓ ✓2 )
@ ✓˙ 2 2 2 2 1 2 1 1
Divide through by l1 and this simplifies to:
example: double pendulum
(m1 +m2 )l1 ✓¨1 +m2 l2 ✓¨2 cos(✓1 ✓2 )+m2 l2 ✓˙22 sin(✓1 ✓2 )+g(m1 +m2 ) sin(✓1 ) =
0
Similarly, for ✓2 :
@L
= m l 2 ✓˙ + m l l ✓˙ cos(✓ ✓2 )
@ ✓˙2 2 2 2 2 1 2 1 1
⇣ ⌘
d @L
= m 2 l 2
¨2 + m2 l1 l2 ✓¨1 cos(✓1 ✓2 )
✓ m2 l1 l2 ✓˙1 sin(✓1 ✓2 )(✓˙1 ✓˙2 )
dt @ ✓˙ 2
@L
@✓2 = m2 l1 l2 ✓˙1 ✓˙2 sin(✓1 ✓2 ) l2 m2 g sin ✓2
⇡
For the initial conditions ✓1 = 2 and ✓2 = ⇡, you get the response be-
but robots are not point masses...
links could be represented by solid cylinders
http://en.wikipedia.org/wiki/List_of_moments_of_inertia
what do you do if the rotation is not
about the center?
If the new axis of rotation is parallel to the original
axis of rotation, use the parallel axis theorem:
2
Inew = Icm + mR
Icm moment of inertia of the object about an
axis passing through its center of mass
m object’s mass
R perpendicular distance between the two axes
and what if the new axis of rotation is
not parallel to the original?
the moment of inertia of a continuous solid body
rotating about a known
Z axis is calculated by
I= ⇢(~r)d(~r)dV (~r)
V
~r radius vector (from origin to volume element of interest)
⇢(~r) object’s mass density at ~r
d(~r) shortest distance between a point at ~r and the axis
of rotation
integrated over the volume V of the body
http://hyperphysics.phy-astr.gsu.edu/hbase/rke.html
for robot dynamics review
http://see.stanford.edu/materials/aiircs223a/
handout7_Dynamics.pdf
http://cs.stanford.edu/groups/manips/teaching/cs223a/
assets/slides/dynamics.pdf
endpoint
force/torque
in Assignment 3,
you will simulate the this force and externally applied
effects of system loads result in robot motion
dynamics e.g., solve for x in f = mẍ + bẋ
simulating equations of motion
goal: given an equation of motion and applied forces,
what will the resulting robot motion be?
There are a series of native Matlab functions that solve ODEs given initial conditions. Di↵erent
functions are appropriate for di↵erent problem types (“sti↵ness”, corresponding to large di↵erences
in scales) and and order of accuracy (low to high).
ode45 is based on an explicit Runge-Kutta (4,5) formula, the Dormand-Prince pair. It is a one-step
solver - in computing y(tn ), it needs only the solution at the immediately preceding time point,
y(tn-1). In general, ode45 is the best function to apply as a “first try” for most problems.
[t,y] = ode45(’my_func’,tspan,y0);
And the code to apply initial condition and solve the system is:
% plot the response
tspan = [0,5]; % figure
time duration for calculation
plot(t,y)
y0 = 10; % initial condition title(’First Order Response’)
xlabel(’Time (s)’)
ylabel(’Position (m)’)
% Note that the equation of motion is in a
The resulting plot is shown below:
% subprogram named my_func First Order Response
10
9
[t,y] = ode45(’my_func’,tspan,y0); 8
Position (m)
figure 5
plot(t,y) 4
2
xlabel(’Time (s)’)
1
ylabel(’Position (m)’) 0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s)
2 3
x(t)
p(0) p(tf )
p(t) = 4 y(t) 5
z(t)
2 3
ẋ(t)
derivatives: ṗ(t) = 4 ẏ(t) 5 = a1 + 2a2 t + 3a3 t2
ż(t)
2 3
ẍ(t)
p̈(t) = 4 ÿ(t) 5 = 2a2 + 6a3 t
z̈(t)
constraints
position and velocity at initial and final times:
p(0) = p0
p(tf ) = pf
ṗ(0) = 0
ṗ(tf ) = 0
velocity
quadratic
Velocitypolynomial
C0 continuous
.
θ (t ) = 40.00t + 13.33t 2
Acceleration
acceleration
..
linear θpolynomial
( t ) = 40 . 00 − 26 . 66 t