Dynamics of rigid bodies and of articulated robots

advertisement
Dynamics of
Articulated Robots
Kris Hauser
CS B659: Principles of Intelligent Robot Motion
Spring 2013
Agenda
• Basic elements of simulation
• Derive the standard form of the dynamics of an articulated
robot in joint space
• Also works for humans, biological systems, non-actuated
mechanical systems …
• Featherstone algorithm: fast method for computing forward
dynamics (torques to accelerations) and inverse dynamics
(accelerations to torques)
• Constrained dynamics
Rigid Body Dynamics
• The following can be derived from first principles
using Newton’s laws + rigidity assumption
• Parameters
•
•
•
•
•
CM translation c(t)
CM velocity v(t)
Rotation R(t)
Angular velocity w(t)
Mass m, local inertia tensor HL
Rigid body ordinary
differential equations
• We will express forces and torques in terms of terms of H (a
function of R), πœ”, 𝑣 and πœ”
• 𝑓 = π‘šπ‘£
• 𝜏 = [πœ”] 𝐻 πœ” + 𝐻 πœ”
• Rearrange…
• 𝑣 = 𝑓/π‘š
• πœ” = 𝐻 −1 (𝜏 − πœ” 𝐻 πœ” )
• So knowing f(t) and τ(t), we can derive c(t), v(t), R(t), and w(t)
by solving an ordinary differential equation (ODE)
• dx/dt = f(x)
• x(0) = x0
• With x=(c,v,R,w) the state of the system
• Numerical integration, also known as simulation
Articulated body ODEs
• We will express joint torques 𝜏 in terms of terms of π‘ž, π‘ž, and π‘ž
and external forces f
• 𝐡 π‘ž π‘ž + 𝐢 π‘ž, π‘ž + 𝐺 π‘ž = 𝜏 + 𝐽𝑇 π‘ž 𝑓
• Rearrange…
• π‘ž=𝐡 π‘ž
−1
𝜏 + 𝐽𝑇 π‘ž 𝑓 − 𝐢 π‘ž, π‘ž − 𝐺 π‘ž
• An ODE in the state space x=(π‘ž, π‘ž)
•
𝑑π‘₯
𝑑𝑑
=
π‘‘π‘ž
𝑑𝑑
π‘‘π‘ž
𝑑𝑑
= 𝑓 π‘ž, π‘ž =
𝐡 π‘ž
−1
π‘ž
𝜏 + 𝐽𝑇 π‘ž 𝑓 − 𝐢 π‘ž, π‘ž − 𝐺 π‘ž
• Solve using numerical integration
Numerical integration of ODEs
• If dx/dt = f(x) and x(0) are known, then given a step size h,
• x(kh) ο‚» xk = xk-1 + h f’(xk-1)
• gives an approximate trajectory for k ο‚³1
• Provided f is smooth
• Accuracy depends on h
• Known as Euler’s method
• Better integration schemes are available
• (e.g., Runge-Kutta methods, implicit integration, adaptive step
sizes, etc)
• Beyond the scope of this course
DYNAMICS OF RIGID BODIES
Kinetic energy for rigid body
• Rigid body with velocity v, angular velocity w
• KE = ½ (m vTv + wT H w)
• World-space inertia tensor H = R HL RT
1/2
w
v
T
H 0
0 mI
w
v
Kinetic energy derivatives
•
πœ•πΎπΈ
πœ•π‘£
= π‘šπ‘£
• Force (@CM) 𝑓 =
•
•
πœ•πΎπΈ
πœ•πœ”
𝑑
H
𝑑𝑑
𝑑 πœ•πΎπΈ
( )
𝑑𝑑 πœ•π‘£
= π‘šπ‘£
= π»πœ”
= [w]H – H[w]
• Torque t =
𝑑 πœ•πΎπΈ
𝑑𝑑 πœ•πœ”
= [w] H w + H πœ”
Summary
•π‘“ = π‘šπ‘£
• 𝜏 = [πœ”] 𝐻 πœ” + 𝐻 πœ”
Gyroscopic “force”
Force off of COM
F
x
Force off of COM
F
𝛿π‘₯
x
Consider infinitesimal virtual displacement 𝛿π‘₯ generated
by F.
(we don’t know what this is, exactly)
The virtual work performed by this displacement is FT𝛿π‘₯
Generalized torque
f
Now consider the equivalent force f, torque τ at COM
Generalized torque
f
𝛿π‘₯
π›Ώπ‘ž
Now consider the equivalent force f, torque τ at COM
And an infinitesimal virtual displacement of R.B.
coordinates π›Ώπ‘ž
Generalized torque
f
𝛿π‘₯
π›Ώπ‘ž
Now consider the equivalent force f, torque τ at COM
And an infinitesimal virtual displacement of R.B.
coordinates π›Ώπ‘ž
Virtual work in configuration space is [fT,τT] π›Ώπ‘ž
Principle of virtual work
f
F
𝛿π‘₯
π›Ώπ‘ž
[fT,τT] π›Ώπ‘ž= FT 𝛿π‘₯
Since 𝛿π‘₯ = 𝐽 π‘ž π›Ώπ‘ž we have [fT,τT] π›Ώπ‘ž= FT𝐽 π‘ž π›Ώπ‘ž
Principle of virtual work
f
F
𝛿π‘₯
π›Ώπ‘ž
[fT,τT] π›Ώπ‘ž= FT 𝛿π‘₯
Since 𝛿π‘₯ = 𝐽 π‘ž π›Ώπ‘ž we have [fT,τT] π›Ώπ‘ž= FT𝐽 π‘ž π›Ώπ‘ž
Since this holds no matter what π›Ώπ‘ž is, we have [fT,τT] =
FTJ(q),
f
Or JT(q) F = τ
ARTICULATED ROBOT DYNAMICS
Robot Dynamics
• Configuration π‘ž, velocity π‘ž οƒŽ Rn
• Generalized forces u οƒŽ Rm
• 𝑒 = 𝜏 + π‘˜ π½π‘˜ π‘ž π‘‡π‘“π‘˜
• Joint torques 𝜏 and external forces π‘“π‘˜
• How does u relate to 𝒒 and 𝒒?
• Use Langrangian mechanics to find a link between
u and π‘ž
Lagrangian Mechanics
• 𝐿 π‘ž, π‘ž = 𝐾 π‘ž, π‘ž − 𝑃 π‘ž
Kinetic energy
Potential energy
• The trajectory between two states (π‘ž0 , π‘ž0 ),
π‘žπ‘‡ , π‘žπ‘‡ is the one that minimizes the “action”
𝑇
𝑆 = 0 𝐿 π‘ž, π‘ž 𝑑𝑑
• 𝐿 π‘ž, π‘ž is defined such that the path minimizing S is
equivalent to the one produced by Newton’s laws,
subject to the constraints that the system only moves
along coordinates q
Lagrangian Mechanics
• 𝐿 π‘ž, π‘ž = 𝐾 π‘ž, π‘ž − 𝑃 π‘ž
• Minimum action condition => Euler-Lagrange
equations of motion:
•
𝑑 πœ•πΏ
𝑑𝑑 πœ•π‘ž
−
πœ•πΏ
πœ•π‘ž
=𝑒
A system of n partial differential
equations
• Note that P is independent of π‘ž, so
•
𝑑 πœ•πΎ
𝑑𝑑 πœ•π‘ž
−
πœ•πΎ
πœ•π‘ž
+
πœ•π‘ƒ
πœ•π‘ž
=𝑒
Example: Point Mass
• Coordinates q = (x,y)
• Potential field P(x,y)
1
2
• Lagrangian: 𝐿 π‘ž, π‘ž = π‘š π‘₯ 2 + 𝑦 2 − 𝑃 π‘₯, 𝑦
• Equations of motion
•
•
𝑑
𝑑𝑑
𝑑
𝑑𝑑
πœ•π‘ƒ
πœ•π‘₯
πœ•π‘ƒ
+
πœ•π‘¦
πœ•π‘ƒ
πœ•π‘₯
πœ•π‘ƒ
+
πœ•π‘¦
π‘šπ‘₯ +
= π‘šπ‘₯ +
= 𝑒π‘₯
π‘šπ‘¦
= π‘šπ‘¦
= 𝑒𝑦
Sanity check: Newton’s laws
Kinetic energy for articulated robot
• 𝐾(π‘ž, π‘ž) = 𝑖 𝐾𝑖 (π‘ž, π‘ž)
• Velocity of i’th rigid body
𝑝
• 𝑣𝑖 = 𝐽𝑖 π‘ž π‘ž
• Angular velocity of i’th rigid body
• πœ”π‘– = π½π‘–π‘Ÿ(π‘ž)π‘ž
• 𝐾𝑖 =
1 𝑇
π‘ž (π‘šπ‘–π½π‘–π‘π‘‡π½π‘–π‘
2
+ π½π‘–π‘Ÿπ‘‡π»π‘–π½π‘–π‘Ÿ)π‘ž
• 𝐾(π‘ž, π‘ž) = ½π‘ž 𝑇 𝐡(π‘ž)π‘ž
Mass matrix:
symmetric positive definite
Derivative of K.E. w.r.t π‘ž
πœ•πΎ
•
πœ•π‘ž
π‘ž, π‘ž = 𝐡 π‘ž π‘ž
𝑑 πœ•πΎ
•
𝑑𝑑 πœ•π‘ž
=𝐡 π‘ž π‘ž+
• = 𝐡(π‘ž) π‘ž +
𝑖 π‘žπ‘–
𝑑
𝐡
𝑑𝑑
πœ•
𝐡
πœ•π‘žπ‘–
π‘ž
π‘ž
π‘ž
π‘ž
Derivative of K.E. w.r.t q
πœ•
𝐾 π‘ž, π‘ž = ½
πœ•π‘ž
πœ•
𝐡(π‘ž)π‘ž
πœ•π‘ž1
…
πœ•
𝑇
π‘ž
𝐡(π‘ž)π‘ž
πœ•π‘žπ‘›
π‘žπ‘‡
Potential energy for articulated
robot in gravity field
πœ•π‘ƒ
•
πœ•π‘ž
πœ•π‘ƒπ‘–
•
πœ•π‘ž
=
πœ•π‘ƒπ‘–
𝑖 πœ•π‘ž
= π‘šπ‘–
0
0
0 𝑣𝑖 = π‘šπ‘– 0 𝐽𝑖𝑝(π‘ž)
𝑔
𝑔
• G(q)
Generalized gravity
Putting it all together
𝑑 πœ•πΎ
•
𝑑𝑑 πœ•π‘ž
πœ•πΎ
−
πœ•π‘ž
• 𝐡 π‘ž π‘ž+
+
πœ•π‘ƒ
πœ•π‘ž
𝑑
𝐡(π‘ž)π‘ž
𝑑𝑑
=𝑒
–½
πœ•
𝑇
π‘ž
𝐡(π‘ž)π‘ž
πœ•π‘ž1
π‘žπ‘‡
…
+ 𝐺(π‘ž) = 𝑒
πœ•
𝐡(π‘ž)π‘ž
πœ•π‘žπ‘›
Group these terms together
Final canonical form
• 𝐡 π‘ž π‘ž + 𝐢 π‘ž, π‘ž + 𝐺(π‘ž) = 𝑒
Generalized
inertia
Centrifugal/
coriolis forces
Generalized
gravity
Generalized forces
(joint torques +
external forces)
Forward/Inverse Dynamics
• Given 𝑒, π‘ž, and π‘ž, find π‘ž
• From torques to accelerations
• π‘ž = 𝐡 π‘ž −1 (𝑒 − 𝐢(π‘ž, π‘ž) − 𝐺(π‘ž) )
• Given π‘ž, π‘ž, and π‘ž, find 𝑒
• From desired accelerations to necessary torques
• 𝑒 = 𝐡 π‘ž π‘ž + 𝐢(π‘ž, π‘ž) + 𝐺(π‘ž)
Example: RP manipulator
Application: Effective Inertia
• If a force 𝑓 is applied to a point 𝑝 on a robot, how much will 𝑝
accelerate?
Application: Effective Inertia
• If a force 𝑓 is applied to a point 𝑝 on a robot, how much will 𝑝
accelerate?
• Assume a stationary system, no acceleration when no force is
applied
• π‘ž0 = 𝐡 π‘ž
−1
𝜏 − 𝐢 π‘ž, π‘ž − 𝐺 π‘ž =0
• With the force:
•π‘ž= 𝐡 π‘ž
−1 𝐽(π‘ž)𝑇 𝑓
Application: Effective Inertia
• If a force 𝑓 is applied to a point 𝑝 on a robot, how much will 𝑝
accelerate?
• Assume a stationary system, no acceleration when no force is
applied
• π‘ž0 = 𝐡 π‘ž
−1
𝜏 − 𝐢 π‘ž, π‘ž − 𝐺 π‘ž =0
• With the force:
• π‘ž = 𝐡 π‘ž −1 𝐽(π‘ž)𝑇 𝑓
• 𝑝 = 𝐽 π‘ž π‘ž = 𝐽(π‘ž)𝐡 π‘ž
• The matrix 𝐽 π‘ž 𝐡 π‘ž
inertia matrix
• 𝑓= 𝐽 π‘ž 𝐡 π‘ž
−1 𝐽
−1 𝐽
π‘ž
π‘ž
−1 𝐽(π‘ž)𝑇 𝑓
𝑇 −1
is called the effective
𝑇 −1 𝑝
Can be infinite at singular configurations!
Application: Feedforward control
• Feedback control: let torques be a
function of the current error between
actual and desired configuration
• Problem: heavy arms require strong
torques, requiring a stiff system
• Stiff systems become unstable relatively
quickly
Application: Feedforward control
• Solution: include feedforward torques
to reduce reliance on feedback
• Estimate the torques that would
compensate for gravity and coriolis
forces, send those torques to the
motors
Feedforward Torques
• Given current π‘ž, π‘ž, desired π‘ž
• 1. Estimate B, C, G
• 2. Compute u
• 𝑒 = 𝐡 π‘ž π‘ž + 𝐢(π‘ž, π‘ž) + 𝐺(π‘ž)
• 3. Apply torques u
• How to compensate for errors in B,C,G? Combine
feedforward with feedback. More in later classes…
Newton-Euler Method
(Featherstone 1984)
• Explicitly solves a linear system for joint constraint forces and
accelerations, related via Newton’s equations
• No matrix larger than 6x6
• Faster forward/inverse dynamics for large chains (O(n) vs O(n3)
for direct matrix computations)
Forward Dynamics: Basic
Intuition
• Downward recursion: Starting from root, compute
“articulated body inertia matrix” for each link
• 6x6 matrix 𝐼𝑖𝐴 relating (𝑓, 𝜏) vectors to translational/angular
accelerations (a, 𝛼) respectively
• Also need a “bias force” 𝑃𝑖
• 𝑓, 𝜏 = 𝐼𝑖𝐴 𝛼, π‘Ž + 𝑃𝑖
• Upward recursion: Starting from leaves, compute
accelerations on links
• Given (𝑓, 𝜏) acting on i’th link, compute acceleration of joint i and
the joint constraint forces on the i-1’th link
• (𝑓, 𝜏) includes external forces + joint constraint forces from
downward links
Software
• Both Lagrangian dynamics and Newton-Euler methods are
implemented in KrisLibrary
• Lagrangian form is usually most mathematically convenient
representation
CONSTRAINED DYNAMICS
Constrained Systems
• Suppose the system is constrained by 𝐴 π‘ž π‘ž = 0
• E.g., closed-chains, contact constraints, rolling
constraints
• A is a k x n matrix (k constraints)
• How does π‘ž evolve over time?
The Wrong Way
• Suppose the system is constrained by 𝐴 π‘ž π‘ž = 0
• E.g., closed-chains, contact constraints, rolling
constraints
• A is a k x n matrix (k constraints)
• How does π‘ž evolve over time?
• Wrong way:
•
𝑑
𝑑𝑑
𝐴 π‘ž π‘ž =𝐴 π‘ž π‘ž+𝐴 π‘ž π‘ž =0
• Solve for π‘ž as usual, then project it onto the subspace that
satisfies this equation, obtaining π‘žπ‘π‘œπ‘›π‘ π‘‘
• The correct answer will be a projection, but a very specific one!
The Right Way…
• Constrained system of equations:
• 𝐡 π‘ž π‘ž + 𝐢 π‘ž, π‘ž + 𝐺 π‘ž = 𝑒 + 𝐴 π‘ž 𝑇 πœ†
•
𝑑
𝑑𝑑
𝐴 π‘ž π‘ž =𝐴 π‘ž π‘ž+𝐴 π‘ž π‘ž =0
• Lagrange multipliers have been introduced
• πœ† = πœ†1 , … , πœ†π‘˜ 𝑇
• πœ† can be thought of as constraint forces
• Solve for n+k variables π‘ž, πœ†
(1)
(2)
Solving…
• Constrained system of equations:
• 𝐡 π‘ž π‘ž + 𝐢 π‘ž, π‘ž + 𝐺 π‘ž = 𝑒 + 𝐴 π‘ž 𝑇 πœ†
•
𝑑
𝑑𝑑
𝐴 π‘ž π‘ž =𝐴 π‘ž π‘ž+𝐴 π‘ž π‘ž =0
(1)
(2)
• Solve for n+k variables π‘ž, πœ†
• A solution must satisfy
• π‘ž = 𝐡−1 𝑒 + 𝐴𝑇 πœ† − 𝐢 − 𝐺
• π΄π‘ž + 𝐴𝐡−1 𝑒 + 𝐴𝑇 πœ† − 𝐢 − 𝐺 = 0
• πœ† = 𝐴𝐡−1 𝐴𝑇
−1
(3) solve 1 for π‘ž
(4) subst (3) in (2)
π΄π‘ž + 𝐴𝐡−1 𝐢 + 𝐺 − 𝑒
(5) solve for πœ† in (4), use −π΄π‘ž = π΄π‘ž from (2)
• π‘ƒπ‘ž = 𝑃𝐡−1 (𝑒 − 𝐢 − 𝐺)
• With 𝑃 = 𝐼 − 𝐡−1 𝐴𝑇 𝐴𝐡−1 𝐴𝑇
(6) more manipulations..
−1 𝐴
Back to Pseudoinverses
• A pseudoinverse A# of the matrix A is a matrix such that
• A = AA#A
• A# = A#AA#
• Generalizes the concept of inverse to non-square, noninvertible
matrices
• Such a matrix exists (in fact, there are infinitely many)
• The Moore-Penrose pseudoinverse, denoted A+, can be
derived as
• A+ = (ATA)-1AT when ATA is invertible
• A+ = AT(AAT)-1 when AAT is invertible
(overconstrained)
(underconstrained)
Properties
• Note connection to least-squares formula
• Ax=b => x = A+b
• If system is overconstrained, this solution minimizes ||b-Ax||2
• If system is underconstrained, this solution minimizes ||x||2
• Note that (I-AA+)Ay = 0 is always satisfied
• (I-AA+) is a projection matrix
Weighted Pseudoinverse
• If (AAT)-1 exists, given any positive definite weighting matrix W,
we can derive a new pseudoinverse
• A# = W-1AT(AW-1AT)-1
• This is a weighted pseudoinverse
• Has the property that x=A#b is a solution to Ax = b such that
• x minimizes xTWx – a weighted norm
Weighted Pseudoinverse
• If (AAT)-1 exists, given any positive definite weighting matrix W,
we can derive a new pseudoinverse
• A# = W-1AT(AW-1AT)-1
• This is a weighted pseudoinverse
• Has the property that x=A#b is a solution to Ax = b such that
• x minimizes xTWx – a weighted norm
• Revisiting constrained dynamics…
• The P projection matrix solves for 𝒒 such that 𝒒𝑻 𝑩𝒒 is
minimized
• Constraint forces dissipate kinetic energy in a minimal fashion!
Rigid Body Simulators
• Articulated robots are often simulated as a set of connected
rigid bodies (Open Dynamics Engine, Bullet, etc)
• Connections give rise to constraints in the dynamics
• 𝐡 π‘ž π‘ž + 𝐢 π‘ž, π‘ž + 𝐺 π‘ž = 𝑒 + 𝐴 π‘ž 𝑇 πœ†
•
𝑑
𝑑𝑑
𝐴 π‘ž π‘ž =𝐴 π‘ž π‘ž+𝐴 π‘ž π‘ž =0
(1)
(2)
• Solve for n+k variables π‘ž, πœ†
• (1), (2) are sparse systems and are solved using specialized
solvers
• More on frictional contact later…
Next class
• Feedback control
• Principles App J
Download