Symbolic Computation of Dynamics On Smooth Manifolds
Symbolic Computation of Dynamics On Smooth Manifolds
Smooth Manifolds
1 Introduction
Fig. 1: The spherical pendulum, quadrotor with suspended load, and three-link
walker systems that evolve on complex nonlinear manifolds. The dynamics for
each are symbolically computed using the presented framework, see codebase
at https://gitlab.com/HybridRobotics/dynamics_on_manifolds.
The paper can be summarized by the following: For systems that evolve
on manifolds (see Figure 1), traditional ways to obtain dynamical models in-
volve taking a local parametrization of the configuration space, such as Euler
angles, and then solving for the dynamics. However, obtaining the dynamics
on manifolds, without local parametrization, results in a dynamical model that
is condensed to a compact expression, is globally valid, and is in a singularity
free form. But, there exist no tools that can automate solving for the symbolic
dynamics on manifolds. We provide a symbolic algebraic framework to capture
geometric axioms and identities that govern the scalar, vector, and matrix
elements of dynamical systems. An algorithm is shown to automate computation
of the dynamics of simple mechanical systems on cartesian products of Cn , Rn ,
S 2 , and SO(3), as well as including computation of dynamics of a set of complex
robotic systems.
The rest of the introduction places our proposed algorithm amongst prior
work involving dynamics solvers and computer algebra systems, followed by an
outline of the paper. With respect to dynamics solvers, Euler-Angle parametriza-
tion has long been the standard for system development. Introducing these lo-
cal parametrizations of manifolds enables the use of well-established analytical
methods and corresponding software algorithms for deriving the equations of
motion. For instance, the Newton-Euler method is implemented in Neweul [16]
and SD/FAST [14]. The Recursive Newton-Euler Algorithm has been used to
efficiently compute dynamics of serial chain manipulators, [7,9]. The Lagrangian
method has been implemented on various multibody systems [22]. Additionally,
the Piogram Method [5], the Composite Rigid Body Algorithm [11], and the
Articulated Body Algorithm [11], all provide efficient algorithmic approaches for
solving the dynamical equations of long kinematic chains. Commercial systems
such as ADAMS [24], SimMechanics, MapleSim, LMS Dads [27], etc., not only
solve the equations of motion, but also offer efficient simulations. Symoro [15]
allows for symbolic modeling and simulation for high dimensional kinematic
tree-structures and closed kinematic chains. Although there are several efficient
methods and corresponding software tools that automate the computation of
3
2 Mathematical Background
Step 4: Group equations with respect to and and apply simplifications (e.g.:
q q = 0):
Z t
(ml2 q q) + (ml2 q q mglq e3 + q ) dt = 0.
0
5
Our mathematical expressions are stored as abstract syntax trees (ASTs). Math-
ematical operations, such as addition and multiplication, are represented as par-
ent nodes which contain a specified number of leaves appropriate for their respec-
tive functionality. Leaves on the other hand represent symbolic scalars, vectors,
and matrices. Mathematical algorithms are then written as functional programs
with the ASTs serving as the input and output data structures. Figure 3 provides
an AST of the Lagrangian for the spherical pendulum. As detailed next, ASTs
are coupled with pattern matching functions to encode mathematical rules.
of each step of the algorithm (steps enumerated 1-7). We will talk about trees of
n nodes containing p parents (operands) and e literals (mathematical elements).
Tree Conditioning: For the steps below, the tree conditioning is defined as
a full expansion of the expression, (i.e. a (b + c) is converted to a b + a c).
Isolating the dynamical terms enable succinct, procedural code to be written for
tree operations. Expanding the tree requires traversing the tree (covered next)
and invokes 3 parent operations per expansion (a b + a c). A maximum of
e 1 expansions can take place during traversal. Table 1 provides a condensed
layout of the computational cost for the algorithm.
Tree Traversal: Each algorithm requires traversal of the tree, from the top
down. The general run time for this case is O(n). If we balance the tree and
parallelize the operations (allowed by the structured commutativity above), we
could theoretically assert an O(log(n)) traversal time. The algorithm enables fast
computation of the dynamics (see Results Tables 2 and 3), with most systems
requiring computation time on the order of milliseconds.
Parent Literal
Process Traversal
Operations Operations
Step 1: - e1 e
Expand: n 3(e 1) -
Step 2: n 3(e 1) e
Step 3: n - e
Expand: n 3(e 1) -
Step 4: n 2(e 1) -
Step 5: n 2(e 1) 3(e 1)
Expand: n 3(e 1) -
Step 6: n 2(e 1) -
Step 7: n e -
Run Time: O(n) O(e) O(e)
Table 1: This table presents the run time of critical steps in the computation.
Linear run time convergence enables broad inspection of high degree of free-
dom dynamics, the laborious computational nature of which made model ex-
traction previously intractable. The coupled simplicity and effectiveness of the
algorithm is enabled by computing on coordinate free configuration spaces. There
is no trigonometric book-keeping, which grows rapidly for systems described on
S 1 and SO(2).
9
Listing 1 illustrates the user code for deriving the dynamics of a spherical pen-
dulum. The user provides the Lagrangian and specifies the actuated variables
of the system. These are input to the computeDynamics function (which im-
plements the algorithm detailed in Section 3.4 to derive the dynamics for the
system. Specification of configuration variables and manifold based constraints
is not required, since the constraint information is encapsulated within mathe-
matical type declaration of each variable. This simple example code will enable
users to effortlessly set up problems for solving the dynamics of new robotic
systems. Constraint manifolds are duduced from configuration variable types,
i.e. q S 2 has kinematic constraint q = q. The codebase is available at
https://gitlab.com/HybridRobotics/dynamics_on_manifolds.
o b j e c t SphericalPendulum {
d e f main ( ) {
// d e f i n e c o n s t a n t scalars
v a l g = Cons ( g ) // g r a v i t a t i o n a l c o n s t a n t
v a l m = Cons ( m ) // p o i n t mass
v a l l = Cons ( l ) // l e n g t h a t which p o i n t mass hangs
// d e f i n e v e c t o r s
v a l e3 = CVec ( e3 ) // o r i e n t a t i o n o f g r a v i t y
v a l q = UVec ( q ) // p o i n t mass a c t s on S2
v a l u = Vec ( u ) // v i r t u a l work done on system
// s e t c o n f i g u r a t i o n v a r i a b l e s
// ( s c a l a r s , v e c t o r s , m a t r i c e s )
v a l c o n f i g V a r s = Tuple3 ( L i s t ( ) , L i s t ( q ) , L i s t ( ) )
// define lagrangian
val KE = Num( 0 . 5 ) m l l ( d i f f V ( q ) dot d i f f V ( q ) )
val PE = m g l ( q dot e3 )
val L = KE PE
// s p e c i f y i n f i n i t e s i m a l v i r t u a l work o f system
v a l infWork = Dot ( del taV ( q ) , u )
hand, introduces real robotic systems evolving on highly complex manifolds. The
user supplies the Lagrangian, Virtual Work, and configuration variables. The ta-
ble lists the runtime and equations produced for each mechanical system. Next,
we briefly describe the systems tabulated in Table 1, for which our proposed
symbolic algorithm computes the dynamics on manifolds.
4.1 Simple Mechanical Systems
A Spherical Pendulum [6] is the first system considered, its parametrization
is described in section 2.2.
Configuration Manifold: S 2
Kinematic Constraints: q q = 0
Variations: q = q, q = q + q, R3
Energy Terms:
1
T = ml2 (q q), U = mgl(q e3 ).
2
The 3D Pendulum [28] provides a system which acts on the SO(3) manifold.
The pendulum is represented as a rigid body of mass m and symmetric inertia
matrix J R33 . It is pivoted at the point from which vector R3 extends
toward the center of mass. The orientation of the 3D pendulum is specified by
rotation matrix R SO(3) with , M R3 being the angular velocity and
moment input of the 3D pendulum respectively. The generalized vector R3
is utilized to describe the variation of R on SO(3).
Configuration Manifold: SO(3)
Kinematic Constraints: R = R
Variations: R = R, = + , R3
Energy Terms:
1
T = J, U = mgR e3 .
2
A Double Spherical Pendulum [20] is an extension of the singular Spher-
ical Pendulum. A second pendulum with point mass m2 is pivoted from the end
of the first pendulum containing point mass m1 . Each pendulum has a respec-
tive length li from its pivot to point mass. The unit vector qi S 2 points along
each li with its origin at the respective pivots. The torque at the base of each
pendulum is given by i R3 .
Configuration Manifold: S 2 S 2
Kinematic Constraints: qi qi = 0
Variations: qi = i qi , q i = i qi + i qi , i R3
Energy Terms:
1 1
T = (m1 + m2 )l12 q1 q1 + m1 l1 l2 q1 q2 + m2 l22 q2 q2
2 2
U = (m1 + m2 )gl1 q1 e3 + m2 gl2 q2 e3
q = q
S2 2 0.019 sec.
q (ml2 q + mgle3 ) = q
Spherical
Pendulum [6]
R = R
SO(3) 3 0.015 sec.
J + J = mg RT e3 + M
3D Pendulum [28]
q1 = 1 q1
q1 ((m1 + m2 )l12 q1 + m2 l1 l2 q2 +
(m1 + m2 )gl1 e3 ) = q1 1
S2 S2 4 0.032 sec.
q2 = 2 q2
q2 (m2 l1 l2 q1 + m2 l22 q2 + m2 gl2 e3 ) =
q2 2
Double Spherical
Pendulum [19]
(J1 m1 2 m2 22 )1 +
m2 1 R1T R2 2 2 + 1 (J1 m1 2
m2 21 )1 + m1 g R1T e3 +
SO(3)
6 0.033 sec. m2 g l1 R1T e3 + m2 1 R1T R2 22 = M1
SO(3)
(J2 m2 22 )2 m2 2 R2T R1 1 1 +
2 (J2 m2 22 )2 + m2 g 2 R2T e3 +
m2 2 R2T R1 12 1 = M2
Double 3D
Pendulum [17]
Table 2: The equations of motion were computed on these simple systems using
the proposed symbolic computation tool with the kinematic constraints,
variations, and Lagrangian (T-U) provided for each system.
13
by rotation matrices Ri .
Configuration Manifold: SO(3) SO(3)
Kinematic Constraints: R = R
Variations: Ri = Ri i , i = i i + i , i R3
Energy Terms:
1 1 1
T = 1 J1 1 + 2 J2 2 + m2 x2 x2
2 2 2
U = m1 gR1 1 e3 + m2 gR2 2 e3
Having seen the algorithm work for simple mechanical systems, we next consider
robotic systems with more complex configuration spaces, shown in Table 3.
The Three Link Walker [23] represents an idealized mechanical configu-
ration for bipedal walkers. Masses m, mH , and mT , are dynamically actuated
by torques 2 and 3 . Unit vectors q1 , q2 , and q3 specify the motion of the three
links. The Stance Dynamics are as shown below. The Flight Dynamics exist
on S 2 S 2 S 2 R3 , and account for the walkers evolution in Euclidean Space.
Configuration Manifold: S 2 S 2 S 2
Kinematic Constraints: qi qi = 0
Variations: qi = i qi , q i = i qi + i qi
Energy Terms:
5m mH mT 2 m m mT
T =( + + )l q1 q1 + l2 ( q1 + q2 ) q2 + (lLq1 + L2 q2 ) q3
8 2 2 2 8 2
3m m
U =( gl + mH l + mT gl)q1 e3 glq2 e3 + mT gLq3 e3
2 2
The Quadrotor with Tethered Load [29] and Reaction Mass Pendu-
lum [26] can be referred to at the respective sources for information on config-
uration variables and composition of the Lagrangian.
Manifolds Cn and Rn are directly computed by the same steps shown in Sec-
tion III, with the exception of Step 3, which introduces constraint manifolds for
S 2 and SO(3). This step is not required for variables that act on Cn and Rn .
The computational results for each system were validated by a published deriva-
tion and hand calculation. These results establish the validity and efficiency of
computing dynamics on complex manifolds using the symbolic evaluator.
5 Discussion
It should be noted that manually computing and validating the dynamics for
several of the systems in Table 3 would have taken a novice one to several days.
Our proposed method of automating the computation reduces this to fractions
of seconds. This will enable a broader study of novel robotic systems whose
dynamics evolve on complex manifolds, systems that were previously not broadly
14
q1 = 1 q1
q1 (( 54 m+mH +mT )l2 q1 + 21 ml2 q2 +
mT lLq3 + ( 32 m + mH + mT )gle3 ) = 0
q2 = 2 q2
S2 S2
6 0.032 sec. q2 ( 21 ml2 q1 + 14 ml2 q2 + 12 mgle3 =
S2
q2 2
q3 = 3 q3
3-Link Walker q3 (mT lLq1 + mT L2 q3 + mT gLe3 =
Stance q3 3
Dynamics [23]
xL = vL
(mQ + mL )VL + mQ l(q q)q + (mQ +
mL )ge3 = f Re3 + p (p f Re3 )
SO(3)
8 0.024 sec. q = q
S 2 R3
q (ml2 q + mgle3 ) = q T
R = R
Quadrotor with J + J = M
Suspended
Load [29]
q1 = 1 q1
q1 (( 54 m + mh + mt )l2 q1 +
1
2
ml2 q2 + mt lLq3 + ( 74 m + mh +
2mt )lx + ( 32 m + mh + mt )lge3 ) = 0
q2 = 2 q2
q2 ( 21 ml2 q1 + 14 ml2 q2 + 34 mlx +
S2 S2 1
10 0.064 sec. mlge3 ) = q2 2
S 2 R3 2
q3 = 3 q3
q3 (mt lLq1 + mt L2 q3 + 2mt Lx +
3 Link Walker mt Lge3 ) = q3 3
Flight ( 47 lm + lmh + 2lmt)q1 + ( 34 ml +
1
Dynamics [23] 2
mt L)q2 + 32 mt Lq3 + ( 25 m + mh +
4mt )x + (2m + 1mh + 2mt)ge3 = 0
T
m = mL e3 2 L + mgeT3 RL
T
e3
RL = RL L
JL L =
C L JL L + 2me3 2 L +
T T
SO(3) 11 0.073 sec. mge3 RL e3 + L RL RP D
SO(3) S RP = RP P
JP PP = P JP P +
4 mp si si ei 2 P + D
2mP si = 2mP si PT ei 2 P + Ui
Reaction Mass
Pendulum [26]
Table 3: The equations of motion were computed on these robotic systems
using the proposed symbolic computation tool with the kinematic constraints,
variations, and Lagrangian (T-U) provided for each system.
15
approachable by the robotics community. The compact models will also bring
new insight into the dynamics of existing robotic systems, enabling novel control
designs for achieving highly dynamical maneuvers. A limitation of this method
is that it cannot evaluate systems with nonholonomic constraints. Dynamics can
only be computed on Cartesian products of Cn , Rn , S 2 , and SO(3).
6 Conclusion
We have presented an algorithm which automates the computation of dynami-
cal equations for systems evolving on manifolds. By utilizing pattern matching
within the Scala framework, we are able to capture the geometric axioms and
identities of scalar, vector, and matrix elements of a dynamical system. Using
the framework we implement a generalized algorithm that works across a wide
variety of manifolds. The time efficient computation allows for the software to
provide near-instantaneous output of dynamical equations. The dynamics gener-
ated are compact, globally-valid, and free of singularities, as they are described
directly on the configuration manifold. This tool is released publicly and will
enable broader inspection of systems that act on complex, nonlinear manifolds.
7 Acknowledgements
B. Bittner would like to thank Carnegie Mellons URO, who supported him with
a Summer Undergraduate Research Fellowship. K. Sreenath would like to thank
R. Ravindran for discussions that led to the use of Scala. This work is supported
by NSF grants IIS-1464337 and CMMI-1538869.
References
1. List of computer algebra systems. http://en.wikipedia.org/wiki/List of computer
algebra systems.
2. Symbolic Math Toolbox. Mathworks Inc, 1993.
3. Mathematica Version 10.0. Wolfram Research Inc., 2014.
4. S. P. Bhat and D. S. Bernstein, A topological obstruction to continuous global
stabilization of rotational motion and the unwinding phenomenon, Systems &
Control Letters, vol. 39, no. 1, pp. 6370, 2000.
5. P.-y. Cheng, C.-i. Weng, and C.-k. Chen, Symbolic derivation of dynamic equa-
tions of motion for robot manipulators using piogram symbolic method, IEEE
Journal of Robotics and Automation, vol. 4, no. 6, pp. 599609, 1988.
6. L. Consolini and M. Tosques, On the exact tracking of the spherical inverted
pendulum via an homotopy method, Systems & Control Letters, vol. 58, no. 1,
pp. 16, 2009.
7. P. I. Corke, An automated symbolic and numeric procedure for manipulator rigid-
body dynamic significance analysis and simplification, in IEEE Conf. on Robotics
and Automation, 1996, pp. 10181023.
8. T. Daly, D. V. Chudnovsky, and G. V. Chudnovsky, Axiom The 30 Year Horizon.
The Axiom Foundation, 2007.
16