v13 Getting Started.html v13 Getting Started.mw

DynaFlexPro User's Manual 

VERSION 1.0 

Copyright 2005 by MotionPro Inc. 

Getting Started:  A Single Pendulum Model 

 

Let's begin by creating a model for a single pendulum, swinging about a 

revolute (pin) joint due to the action of gravity: 

 

 Image 

 

The pendulum has only 1 "degree of freedom" (DOF),  which means that only 1 

motor would be required to completely control its motion.  There is no motor in 

this example, but the 1-DOF characteristic reveals that only 1 coordinate (variable) 

is required to uniquely define the position and orientation of all bodies in the 

system.  For this example, the desired coordinate is θ, the "joint coordinate" 

associated with the revolute joint.  DynaFlexPro will be used to automatically 

generate the single dynamic equation in terms of this coordinate. 

 

DynaFlexPro reads in a description of the system from an input (.dfp) file.  This 

ASCII file can be created with any text editor, but one must first learn the input 

file syntax.  To eliminate this tedious requirement, a Java-based graphical user 

interface, ModelBuilder, has been created.  With ModelBuilder (MB), system 

models can be quickly built by assembling a block diagram representation. 

 

You can launch ModelBuilder from the Maplesoft web site by clicking here. 

 

Creating system model with ModelBuilder 

 

Shown below is the ModelBuilder model of the single pendulum.  Rigid bodies 

and flexible beams are represented by blocks, and inter-body connections 

(joints, springs, dampers, forces, moments) are represented by arrows.  The 

arrows connect reference frames that are fixed on each body; these frames are 

shown as circles on the body to which they are affixed.  The international symbol 

for the center of mass designates the primary reference frame on each rigid body. 

The position and orientation of any other frame on the body is defined relative 

to this primary reference frame. 

 

The directions of the arrows are significant; the motion associated with the arrow 

is the relative motion of the frame at the head (end) of the arrow with respect to 

the frame at the tail (start) of the arrow.  The arrow shown in the figure below is 

the revolute joint connecting the pendulating body to the ground; the coordinate 

corresponding to this element is θ, the rotation of the body with respect to ground. 

 

Image 

 

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/Pendulum.mb"):
 

 

Image 

 

The parameters associated with each component (mass, inertia, geometry, axis 

of rotation, etc.) or the system can be set in the corresponding Properties menu. 

As shown above, the model name is set to "Pendulum" and the acceleration due 

to gravity is set to "G", acting in the -Y direction.  One can save MB models in 

a .mb file, and load previous system or subsystem models. 

 

To have the system equations generated in terms of θ, one selects the revolute 

joint component into the system "tree".  This is accomplished by selecting "T-tree" 

(translation) and "R-tree" (rotation) in the joint Properties menu, as shown below. 

Since the joint only allows relative rotation, and no relative translation of the two frames 

that it connects, only the rotational coordinate θ appears in the system equations 

generated by DFP.  The selection of modeling coordinates is explained further in 

the section Building System Models, below. 

 

 

Image 

 

To generate the input file (Pendulum.dfp) in the format required by DynaFlexPro, 

one simply clicks the Export to DFP button, shown in the very first window above. 

 

Generating and examining system equations 

 

Once a DynaFlexPro input file has been created, one should open a Maple worksheet 

and load the DynaFlexPro package: 

 

> restart:
 

> with(DynaFlexPro);
 

 

 


 

 

After DynaFlexPro has been loaded, the BuildEQs command can be called to automatically 

generate the kinematic and dynamic equations of motion for the system described in the input 

file "Pendulum.dfp" in the Examples sub-directory.  The BuildEQs command has several 

optional parameters for controlling the form of the generated equations: 

 

> Model:= BuildEQs("Examples/Pendulum.dfp",["DynSimpType", "Simplify"]):
 

Analyzing system... 

Performing constraint analysis... 

The system has 1 degree(s) of freedom.  It is modeled using 1 generalized coordinate(s) coupled by 0 algebraic constraint(s).
The system has 1 degree(s) of freedom.  It is modeled using 1 generalized coordinate(s) coupled by 0 algebraic constraint(s).
 

Peforming a dynamic analysis on the constraint free system - system variables shown below:
Peforming a dynamic analysis on the constraint free system - system variables shown below:
 

vQ 

Dynamic analysis complete. 

 

The system model has been stored in the module "Model".  One can then access different 

portions of the Model, e.g. the generalized coordinates vQ and speeds vP in which the equations 

have been generated (which are also listed above), or the state variables vX: 

 

> Model:-vQ;
 

> Model:-vP;
 

 

 

> Model:-vX;
 

Vector[column](%id = 146349868) 

 

One can load the Model module, in order to see the data and functions that can be exported 

from it: 

 

> with(Model);
 

[GetAYBSysODEs, GetAccCons, GetDynEQs, GetFrameMotion, GetKinTrans, GetPosCons, GetSimCodeData, GetSysEQs, GetSysODEs, GetVelCons, SetBaumgarte, sDFPVersion, vAccRHS, vF, vKinTransRHS, vLambda, vP, vP...
[GetAYBSysODEs, GetAccCons, GetDynEQs, GetFrameMotion, GetKinTrans, GetPosCons, GetSimCodeData, GetSysEQs, GetSysODEs, GetVelCons, SetBaumgarte, sDFPVersion, vAccRHS, vF, vKinTransRHS, vLambda, vP, vP...
[GetAYBSysODEs, GetAccCons, GetDynEQs, GetFrameMotion, GetKinTrans, GetPosCons, GetSimCodeData, GetSysEQs, GetSysODEs, GetVelCons, SetBaumgarte, sDFPVersion, vAccRHS, vF, vKinTransRHS, vLambda, vP, vP...
[GetAYBSysODEs, GetAccCons, GetDynEQs, GetFrameMotion, GetKinTrans, GetPosCons, GetSimCodeData, GetSysEQs, GetSysODEs, GetVelCons, SetBaumgarte, sDFPVersion, vAccRHS, vF, vKinTransRHS, vLambda, vP, vP...
[GetAYBSysODEs, GetAccCons, GetDynEQs, GetFrameMotion, GetKinTrans, GetPosCons, GetSimCodeData, GetSysEQs, GetSysODEs, GetVelCons, SetBaumgarte, sDFPVersion, vAccRHS, vF, vKinTransRHS, vLambda, vP, vP...
 

 

As listed, there are many functions and data available for examining different features of the 

symbolic model.  The GetDynEQs function returns the dynamic equation, which is easily 

validated by a hand derivation using the Newton-Euler or Lagrange equations: 

 

> ODE:=GetDynEQs();
 

Vector[column](%id = 147293104) 

 

The equations for this system take the general form of  M*dp/dt = F,  where M is the mass matrix, 

p are the generalized speeds (vP), and F contains external loads and quadratic velocity terms. 

 

Matrix data in the Model module are prefaced by an "x", while vector data are prefaced by a "v". 

Thus,  the mass matrix Mis given by:  

 

> xM;
 

Matrix(%id = 151559536) 

 

As expected, the mass matrix is a single scalar; it represents the moment of inertia of the 

pendulum about the joint axis of rotation, which is quickly validated using the parallel axis 

theorem.  The column matrix F is the resultant moment about the joint axis, due to the weight: 

 

> vF;
 

Vector[column](%id = 146659468) 

 

The GetFrameMotion function provides kinematic information (position,  orientation, and their 

derivatives) about any frame in the system.  For example, the position vector from the ground 

frame to the center of mass frame, resolved in XYZ components along the ground frame, can 

be automatically expressed in terms of vQ: 

 

> GetFrameMotion("r","CoM","Ground","Ground");
 

Vector[column](%id = 146924072) 

 

Note that the frame names "Ground" and "CoM" were specified by the user in the ModelBuilder model. 

 

Simulating the dynamic response 

 

As for most dynamic systems, the governing differential equations of motion are nonlinear.  In 

this case, one can search for analytical solutions in the form of Bessel equations.  However, it 

is often more useful to proceed to a numerical solution of the differential equations, using Maple's 

built-in numerical integrators. 

 

Start by specifying numeric values for the symbolic parameters and defining the initial conditions. 

In this case, the pendulum is released from rest from a horizontal position. 

 

> L := 1: m:= 1: Izz:= 1: G:=9.8:
 

> SysEqns:= [ODE[1], D(theta)(0)=0,theta(0)=Pi/2];
 


 

 

One can now numerically integrate the differential equation of motion, subject to the given initial 

conditions, and plot the results for the pendulum angle versus time: 

 

> Soln := dsolve(SysEqns, numeric, range=0..4):
 

> plots[odeplot](Soln, [[t,theta(t)*180/Pi]],0..4,
 

>               title= "Angle (deg) versus Time",
 

>               labels = ["time (s)", "angle (deg)"]);
 

Plot 

 

Now that the generalized coordinates and speeds are known as functions of time, other 

motions can be computed.  For example, using GetFrameMotion to generate the motion of 

the center of mass frame relative to the ground, the circular trajectory of the mass center 

can be plotted: 

 

> plots[odeplot](Soln, [GetFrameMotion("r","CoM","Ground","Ground")[1],
 

>                      GetFrameMotion("r","CoM","Ground","Ground")[2]],
 

>                      t=0..4, labels=["x","y"], scaling=constrained,
 

>                      title="Trajectory of mass center");
 

>
 

Plot 

>
 

 

In the next sections, full details are given of how to build complex system models from the 

library of components, how to generate the system equations, and how to extract information 

from these equations.  The last section provides a number of solved examples to show some 

of the different systems that can be modeled with DynaFlexPro.