DynaFlexPro User's Manual
VERSION 1.0
Copyright 2005 by MotionPro Inc.
Example Problems
Overview of common format for examples
Each of the following examples are presented using a standard format, so that
the user can easily navigate between the commands and concepts presented
in the different examples.
Description
A description of the physical system is given, along with the relevant system
variables and parameters.
Concepts
A short list of the concepts presented in the example.
Modeling
The system is modeled using ModelBuilder to create the components and
their interconnections, and BuildEQs to generate the governing equations.
Simulation
The kinematic and dynamic equations are solved, usually numerically, to
provide a computer simulation of the time response. Plots and animations
are used to demonstrate the system motion.
References
Papers, journals, and web links are provided for further information on the
given example.
Spring-mass-damper model
This is the classical model of a vibrating system, consisting of a translating mass connected
to ground by a linear spring and damper.
Description
A prismatic joint is used to constrain the mass to translational motion along the global
X axis. The displacement of the center of mass, x(t), is measured from the position where
the spring is undeformed. Acting on the mass is an external force F(t), as well as the
restoring forces from the spring and damper.
Concepts
Modeling
You can launch this ModelBuilder example from the Maplesoft web site by clicking here.
Alternatively, if you have installed DynaFlexPro and this User's Manual on your computer
(automatically put in Maple 10 toolbox directory), you can un-comment the next line to
launch this DynaFlexPro ModelBuilder example:
| > | #DynaFlexPro:-BuildModel("Examples/SprMassDamp.mb"): |
The block diagram model of the system is shown above. The connection between the
translating Mass and the Ground is a prismatic (slider) joint, as shown below. Note
that the joint is selected into the trees of the linear graph, so that the equations are
automatically generated in the joint coordinate, x(t).
The spring, damper, and external force could all be modeled by separate connections
between the ground and translating mass. However, it is simpler to include the stiffness,
damping, and external force as elements acting in parallel with the prismatic joint; as
shown below, this is easily entered through the "Force Driver" interface for the joint.
The model is then exported to the input file "SprMassDamp.dfp".
| > | restart; |
| > | with(DynaFlexPro); |
![]()
After loading the DynaFlexPro libraries into Maple, the system equations are automatically
generated by passing the input file name to the BuildEQs command. The resulting module
is stored in "Model", so that the kinematic and dynamic exports can be easily examined.
| > | Model:= BuildEQs("Examples/SprMassDamp.dfp",[]): |
![]()
![]()
| > | with(Model); |
![]()
![]()
![]()
![]()
| > | GetDynEQs(); |
As expected, the dynamic equations comprise a single, second-order, linear ordinary differential equation
that governs the response of this vibrating 1-DOF system.
Simulation
Since the governing ODE is linear, we can obtain analytical solutions using Maple's dsolve command.
Let's start by looking at the unforced response case, i.e. with F(t) = 0.
Numerical values are set for the system parameters, and the system is released from rest with x=1 at
time=0. With m=k=1, critical damping would occur for d=2 (see Thomson and Dahleh). With d=1/2, the
dynamic response is an underdamped vibration:
| > | ParaSubs:= [m= 1, d= 1/2, k= 1, F(t)= 0]: |
| > | SysODE:= eval(GetDynEQs()[1],ParaSubs): |
| > | UnforcedSoln:= dsolve({SysODE, x(0)=1, D(x)(0)=0}); |

The dynamic response can be plotted, in order to better visualize the response:
| > | assign(UnforcedSoln); |
| > | plot(x(t),t=0..10,title="Displacement versus time"); |
| > | plot(diff(x(t),t),t=0..10,title="Speed versus time"); |
Now look at the response of the mass to a sinusoidal forcing function. Start by unassigning
the previous solution for x(t), and and then find the new solution:
| > | unassign('x(t)'); |
| > | ParaSubs:= [m= 1, d= 1/2, k= 1, F(t)= sin(omega*t)]: |
| > | SysODE:= subs(op(ParaSubs),GetDynEQs()[1]); |
| > | ForcedSoln:= dsolve({SysODE, x(0)=1, D(x)(0)=0}, x(t)); |
| > | assign(ForcedSoln); |
![]()
![]()



Notice how the forced response depends upon the frequency ω of the forcing excitation. One can
plot the displacement response for low and high frequency excitations:
| > | plot(subs(omega=1,x(t)),t=0..10,title="Displacement versus time (omega=1)"); |
| > | plot(subs(omega=10,x(t)),t=0..10,title="Displacement versus time (omega=10)"); |
When the forcing frequency is much higher than the natural frequency, one can see that the response
is essentially the unforced, underdamped response, with a superimposed high-frequency oscillation.
| > |
References
Two-dimensional particle motion
In this example, the two-dimensional motion of a simple particle mass projectile is modeled
and simulated.
Description
The particle mass is launched with some initial velocity in the XY plane of motion,
and gravity acts in the -Y direction.
Concepts
Modeling
You can launch this ModelBuilder example from the Maplesoft web site by clicking here.
Alternatively, if you have installed DynaFlexPro and this User's Manual on your computer
(automatically put in Maple 10 toolbox directory), you can un-comment the next line to
launch this DynaFlexPro ModelBuilder example:
| > | #DynaFlexPro:-BuildModel("Examples/Projectile.mb"): |
In this example, the rigid body representing the particle mass is connected to the Ground
by a Planar Joint. In that way, the mass can only translate in the XY plane, and rotate about
the Z axis out of the plane. Thus, the particle mass has 3 degrees of freedom (DOF).
The variables associated with the planar joint are denoted X, Y, and θ, and the planar joint
is selected into the tree so that the final equations are in terms of X, Y, and θ.
If one wanted to simulate the three-dimensional motion of a projectile, the planar joint
can be replaced by a Free Joint, or no joint at all.
The mass of the body is set to m, and the moment of inertia about Z is set to Inertia. Do
not use "I" as a symbol, since Maple will confuse this with the complex number I =
In the Model Properties window, the gravity is set to G in the -Y direction and the model file
name is set to "Projectile.dfp", to which the system model is exported.
After loading the DynaFlexPro package, the BuildEQs command will automatically generate
the governing equations of motion, given the name of the model file as input:
| > | restart; |
| > | with(DynaFlexPro); |
![]()
| > | Model:= BuildEQs("Examples/Projectile.dfp",[]): |
![]()
![]()
By saving the results in the module Model, the exported data and functions can easily be examined:
| > | with(Model); |
![]()
![]()
![]()
![]()
| > | GetDynEQs(); |
As expected, the dynamic equations comprise 3 second-order ODEs in terms of the
selected coordinates X, Y, and θ.
Simulation
As in the previous example, the governing ODEs are linear and can be solved analytically
using dsolve.
However, to demonstrate the features associated with BuildSimCode, optimized simulation
code will be generated for this example and numerically integrated within Maple.
Numerical values are set for the system parameters. Then, an optimized Maple procedure
(pXdot) is created, which contains a computational sequence for computing the derivatives
Xdot needed for subsequent numerical integration by Maple's dsolve/numeric.
| > | ParaSubs:= [m= 1, G=10, Inertia= 1]: |
| > | BuildSimCode(Model,{"Xdot"}, "MapleProc", "Optimize", ParaSubs); |
![]()
The projectile is launched with initial speed v0, at a 30 degree angle above the X axis. The motion
is simulated by numerically integrating the optimized procedure (pXdot):
| > | v0:= 10: |
| > | odeICs := array([v0*cos(Pi/6),v0*sin(Pi/6),10,0,0,0]); |
| > | odeVars := convert(convert([Model:-vX],Vector),list); |
| > | tr := time():
Soln := dsolve(numeric, implicit=false, procedure=pXdot, abserr = 1e-8, relerr=1e-7, start=0, initial=odeICs, output=listprocedure, procvars=odeVars, range=0..1): Time_to_integrate := time()-tr; |
Once the numerical results are obtained by dsolve/numeric, they can be plotted using plots[odeplot]:
| > | plots[odeplot](Soln, [[odeVars[4],odeVars[5]]],t=0..1, refine=1, title= "Trajectory of Projectile, Side View", labels = ["X", "Y"], scaling= constrained, view=[0..10,0..2]); |
| > | plots[odeplot](Soln, [GetFrameMotion("r", "CoM", "Ground", "Ground")[1],GetFrameMotion("r", "CoM", "Ground", "Ground")[2],GetFrameMotion("r", "CoM", "Ground", "Ground")[3]],t=0..1, refine=1, labels=["x","y","z"], refine=2, axes=framed, orientation=[-80,20],title= "Trajectory of Projectile, 3D View"); |
Note that the angular speed of the mass remains constant, since there are no torques
acting on the mass in this example:
| > | plots[odeplot](Soln, [t,odeVars[3]],0..1, refine=1, title= "Angular speed versus time", labels = ["Time", "theta_dot"], view=[0..1,0..20]); |
| > |
Two-DOF serial robot manipulator
In this example, the dynamic equations are obtained for a 2-link 2-DOF robot arm.
Description
The robot consists of two rigid bodies connected by revolute joints with parallel axes.
Thus, this "RR" robot is constrained to the XY plane, with gravity G acting in the -Y
direction. The robot is driven by two motor torques,T1 and T2, acting at the two joints.
Concepts
Modeling
You can launch this ModelBuilder example from the Maplesoft web site by clicking here.
Alternatively, if you have installed DynaFlexPro and this User's Manual on your computer
(automatically put in Maple 10 toolbox directory), you can un-comment the next line to
launch this DynaFlexPro ModelBuilder example:
| > | #DynaFlexPro:-BuildModel("Examples/RR_robot.mb"): |
Using the ModelBuilder, the links are connected to each other and Ground by revolute
joints with axes parallel to Z:
In addition to specifying the axis for each joint, the desired coordinate names
and
are entered in the joint properties menu. With the two joints selected into the trees for
rotation and translation, the final equations will be in terms of
and
.
The joint torques are easily entered through the Torque Driver menu for the joints:
Rigid body-fixed frames are created on each body where the joints are connected. In
addition, a body-fixed frame is attached to the tip P of the second link:
After defining the gravity vector, the model is exported to the file "RR_robot.dfp":
| > | restart; |
| > | with(DynaFlexPro); |
![]()
After loading the DynaFlexPro package, the system equations are generated by BuildEQs from the
given input model file and stored in the Model module. The optional argument instructs BuildEQs
to apply the Simplify command to the dynamic equations of motion:
| > | Model:= BuildEQs("Examples/RR_robot.dfp",["DynSimpType", "Simplify"]): |
![]()
![]()
| > | with(Model); |
![]()
![]()
![]()
![]()
Because the 2-DOF system is modeled by 2 independent coordinates, the governing dynamic equations
take the form of ordinary differential equations
, where
is the 2x2 mass matrix:
| > | xM; |

![]()
![]()
![]()
![]()
![]()
![]()
As expected, the mass matrix is symmetric positive-definite. The entry corresponding to β2
is the moment of inertia of the second link about the second joint axis (easily verified using the
parallel axis theorem). The entry corresponding to β1 (see order of coordinates in vQ, above)
is the combined moment of inertia of both bodies about the first joint axis.
The right-hand side F of the ODEs includes weight and quadratic velocity terms. The β2 entry
corresponds to the net moment about the second joint axis of these contributing terms, and the
β1 entry is the net moment about the first joint axis:
| > | vF; |

![]()
![]()
![]()

![]()

![]()
![]()
![]()


The (X,Y) coordinates of the tip point P are easily found in terms of the 2 independent coordinates
using the GetFrameMotion command:
| > | xP(t):= GetFrameMotion("r","P","Ground","Ground")[1]; |
| > | yP(t):= GetFrameMotion("r","P","Ground","Ground")[2]; |
![]()
![]()
![]()
![]()
Maple's Combine command is often successful at simplifying complex trigonometric
expressions that typically appear in kinematic equations:
| > | xP(t):= map(combine,xP(t)); |
| > | yP(t):= map(combine,yP(t)); |
![]()
![]()
Simulation
In this example, we assume that the joint coordinates are known functions of time. From these functions,
the trajectory of point P can be calculated --- this is known as forward kinematics. Alternatively, in an inverse
kinematic analysis, the trajectory of P is given and the joint coordinates are found by solving the previous
expressions from GetFrameMotion.
Once the joint coordinates are known, the motor torques required to produce the motion can be found by
solving the dynamic equations. This is known as inverse dynamics. In a forward dynamics problem, the
torques are given and the dynamic equations are numerically integrated to get the dynamic response (see
forward dynamic simulations in the projectile and spinning top examples).
Start by prescribing the joint motions and numerical values for the system parameters:
| > | beta_1:= t->Pi*t^2; beta_2:= t->Pi*t^2; # both angles traverse 180 degrees in 1 second.
L3:= 1: L4:= 1: L5:= 1: L6:= 1: |
| > | plot([beta_1(t),diff(beta_1(t),t)],t=0..1,legend=["beta_1","beta_1_dot"]); |
We now have enough information to solve the forward kinematics problem for the trajectory of P,
which is seen to spiral in towards the first joint axis:
| > | plot([map(eval,xP(t)),map(eval,yP(t)),t=0..1],scaling=constrained); |
For dynamics problems, we also need values for masses, moments of inertia, and gravity. Once they
are known, the torques can be obtained from the dynamic equations. Since the torques appear linearly
in the dynamic equations (see vF, above), a linear solver (solve) is all that is needed.
| > | m1:= 1: m2:= 1: I1:= 1: I2:= 1: G:= 10: |
| > | Torque1:= solve(GetDynEQs()[1],T1); |
| > | Torque2:= solve(GetDynEQs()[2],T2); |
![]()
![]()
![]()
| > | plot([Torque1,Torque2],t=0..1,legend=["Torque 1","Torque 2"]); |
In the first part of the response, centripetal effects are small because of small angular speeds. Thus,
the static weight and constant angular acceleration terms dominate. In the latter part of the response,
the increasing angular speeds begin to affect the required driving torques through the centripetal
acceleration terms.
| > |
References
In this example, the dynamic equations are generated for the 3-dimensional motion of
a spinning top. The equations are numerically integrated to obtain a simulation of the
complex motions.
Description
The base of the top is assumed to remain stationary at the origin O; this assumption is
enforced by a spherical joint between the ground and the rigid spinning body. The 3-D
rotational motion of the top is represented using 3-1-3 Euler angles: ζ for precession
about Z, η for nutation about the rotated x frame, and ξ for spin about the body's axis of
symmetry. Gravity acts through the center of mass C, located a distance L from O.
Concepts
Modeling
You can launch this ModelBuilder example from the Maplesoft web site by clicking here.
Alternatively, if you have installed DynaFlexPro and this User's Manual on your computer
(automatically put in Maple 10 toolbox directory), you can un-comment the next line to
launch this DynaFlexPro ModelBuilder example:
| > | #DynaFlexPro:-BuildModel("Examples/SpinTop.mb"): |
In this example, the rigid body is connected to the ground by a spherical
(ball-and-socket) joint, so that the base of the top remains stationary.
As shown in the spherical joint properties below, 3-1-3 Euler angles are used to
represent the three rotations in the spherical joint. Since the joint is selected into
the tree, the final equations will be in terms of ζ, η, and ξ.
The spherical joint connects the Ground frame to the body-fixed Base frame on
the rigid body. From the system description, the Base frame is -L units along the
body-fixed z axis from the center of mass.
The top itself has a mass m, a moment of inertia C about the z spin axis, and
a moment of inertia A about the two transverse axes through the joint center.
Using the parallel-axis theorem, the moment of inertia about x and y through
the center of mass is A - m
After specifying the gravity vector, the model can be exported to the file "SpinTop.dfp".
| > | restart; |
| > | with(DynaFlexPro); |
![]()
After loading the DynaFlex package, BuildEQs generates the system equations from the given input
file, with Simplify applied to the resulting dynamic equations:
| > | Model:= BuildEQs("Examples/SpinTop.dfp",["DynSimpType", "Simplify"]): |
![]()
![]()