Working with LinkageData
LinkageData can be considered as a small relational database that stores all relevant information of linkages. LinkageData consist of a list of
records that are identified with
record identifiers. Every records have to conform to a simple
{_String, _List} pattern. The first part of the record is the
record identifier, while the second part is the data.
Load LinkageDesigner package
Create and view LinkageData.
Create a simple LinkageData object from a serialized LinkageData
Out[2]= |  |
The format of the
LinkageData object is
-LinkageData, n-, where
n is the number of records in the database. The test
LinkageData contains currently three records.
Out[3]= |  |
LinkageData object can be queried and modified with standard list manipulation functions such as
Part or
Delete.
linkage[["id"]] | Overloaded Part function for LinkageData permits indexing with "id" record identifier string |
linkage[["id"]]={data} | Overloaded Set function for LinkageData permits to set part of LinkageData, which is indexed with record identifier |
PrependTo[linkage[["id"]],elem] | Overloaded PrependTo function for LinkageData permits to prepend the data list with elem for "id" record. |
AppendTo[linkage[["id"]],elem] | Overloaded AppendTo function for LinkageData permits to append the data list with elem for "id"record. |
DeleteTo[linkage,"id"] | Delete "id"record from linkage |
LinkageData manipulation functions.
Retrive the "
ID2" record using Part function
Out[4]= |  |
Get the second element of "
ID2" record
Out[5]= |  |
It is possible to retrieve sub records, which is identified by strings
Out[6]= |  |
Out[7]= |  |
Append one element to "myRecord"
Out[8]= |  |
Retrive the content of "myRecord"
Out[9]= |  |
Out[10]= |  |
Delete "myRecord" from the LinkageData
Out[11]= |  |
LinkageData is defined a database, which is flexible enough to easily extend with new chunk of data. In order to find the information required by the functions of
LinkageDesigner, certain number of pre-defined records are introduced. The record identifier and the record data of these pre-defined records are specified rigorously. Hovewer users can extend the
LinkageData object by using his/her own record identifier and data.
The string identifiers of the pre-defined records are also defined with constants, which permits to look up using the standard command completion mechanism of
Mathematica notebooks.
Record Identifier | Description |
$LDMechanismID | Defines the name of the linkage and other linkage instance specific informations (units, WorkBench name, etc.) |
$LDDrivingVariables | List of rules representing the driving variables of the linkage together with their substitutional values. |
$LDSimpleParameters | List of rules representing the simple parameters of the linkage together with their substitutional values. |
$LDStructure | List of records defininig the kinematic pairs of the linkage. |
$LDLowOrderJoint | List of records about the low order kinematic pairs ( type, joint marker, etc..) |
$LDLinkGeometry | Stores the geometric representation of the links. |
$LDDerivedParametersA | List of explicitly derived parameters. ( p is explicitly derived if it can be expressed as p = f[q1, q2, ...] |
$LDDerivedParametersB | List of implicitly derived parameters. ( p is implicitly derived if it can be expressed as the solution of f[p, q1, q2, ...]== 0) |
$LDLinkGroundTransformation | List of transformation of the Local Link Reference Frames to the Global Reference Frame |
$LDTimeDependentVariables | List of rules of time dependent variables together with the first derivative. |
$LDDrivingVelocities | List of rules representing the first derivative of the driving variables together with their substitutional values.. |
$LDInteractiveDef | Stores linkage definition of a previous LinkageCAD session. |
$LDMassProperties | Stores the mass properties of the links. Mass properties data consist of a list of {inertiaFrame,mass,momentOfInertia} sublist. |
$LDForces | Stores a list of forces that acting on the mechanism. Forces are stored as {{str1,vec},{str2,pointofAttack}} sublist |
$LDTorques | Stores a list of torques vectors acting on the linkage. Torques are stored as {{str1,vec},{str2,pointofAttack}} |
Predefined record identifiers of LinkageData.
Structural records of the linkage
New
LinkageData can be created with two function
CreateLinkage and
DefineLinkage. The resulted
LinkageData object is not completely empty, because the minimal set of records are already inserted. Since
DefineLinkage internally calls
CreateLinkage function, therefore only the latter one will be discussed here.
CreateLinkage[str] | creates an empty LinkageData object with str as the name of the linkage. |
DefineLinkage[str, ls] | creates a new linkage with str name and adds a list of kinematic pair definitions (ls). |
Create new LinkageData.
| | |
GroundName | Ground | GroundName defines the name of the ground link. |
WorkbenchName | Workbench | WorkbenchName specifies the name of the workbench link. |
SimpleParameters | {} | SimpleParameters specifies the intial set of simple parameters that can be used in the linkage defintion. |
WorkbenchPlacement | Automatic | Homogenous transformation matrix specifying the placement of the Workbench link w.r.t. the reference coordinate system. |
PlacementName | "Base-0" | Name of the kinematic pair defining the Workbench placement. |
LinkageUnits | Automatic | LinkageUnit specifies the default units used in the linkage. E.g. {Meter,Kilogramm,Second,Newton} |
Options of CreateLinkage
Create a linkage with the name "test" and assign the resulted linkage to test symbol
Out[12]= |  |
CreateLinkage returns a LinkageData object containing 5 records. To investigate the contents of the records brows the LinkageData with
ViewLDTree function
Display the records of the LinkageData object in ColumnForm
Out[13]= |  |
The first element of
$LDMechanismID record is the name of the linkage (referred as
LinkageName) . LinkageDesigner use a composite naming strategy to identify the entities such as links, geometries, forces,kinematic pairs etc. The name of the linkage is used to create the full name of entities. Every entities have a tring identifier that is called
EntityName . The full name of identifiers are composed by concatenating the
LinkageName and the
EntityName.
FullName = LinkageName@EntityName
There are two help function implemented in LinkageDesigner to manipulate composite names, the
GetFullName and
GetStrippedName functions.
GetFullName[linkage,"id"] | returns the full name of the "id" using the linkage name of linkage LinkageData |
GetStrippedName[fullName] | returns the entity name of fullName, by dropping the substrings up to the first @ character |
Functions for composite name manipulation. .
Define the full name of the "myLink" entity name
Out[14]= |  |
Get the entity name back form the full name
Out[15]= |  |
Beside the name of the linkage,
$LDMechanismID contains the full name of the
Ground (test@Ground) and the
Workbench (test@Workbench) links. These two links were created by CreateLinkage function, together with the first kinematic pair of the
$LDStructure record. The Ground link is the reference rigid body of the entire linkage. The LLRF of
Ground is the global reference frame for the linkage. The Workbench link is by default connected with a fixed joint to the ground link, and represents the local reference body of the linkage. The LLRF of the
Workbench link is the working reference frame of the linkage. This duplication of the reference links has two advantages:
i.) the reference link can be described with a kinematic pair
ii.) the linkage can be placed anywhere by changing only the
Ground-
Workbench transformation .
By parameterizing the
Ground-
Workbench transformation the movement of the mechanism -relative to the global reference frame- can be easily modeled. This movement could be used to model mobil or walking mechanism.
Out[16]= |  |
The
$LDStructure record stores the list of kinematic pairs of the mechanism. The kinematic pairs are the backbone structure of the mechanism, which detemines the movements of the links. Every kinematic pair is described with a subrecord in
$LDStructure record. These sub-records stores three information of the kinematic pair:
- String identifier of the kinematic pair ( test@Base-0 )
- String identifier of the lower and upper links ( {test@Ground,test@Workbench} )
- Homogeneous transformations of the LLRF of the upper link to the lower one and vice versa. ( {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}} )
Create a linkage with the name "test1" by overriding the default settings
Out[17]= |  |
Get the
$MechanismID and the
$Structure records of test1 LinkageData
Out[18]= |  |
Out[19]= |  |
The
$LDStructure record is populated mainly when the kinematic pairs of the linkages are defined.
Independent variables of linkages
Independent variables are such placeholders that can substituted with any numerical values. Typical independent variables are the joint variables and dimensional parameters. There are two records dedicated to store the independent variables of the linkages:
$LDDrivingVariables | List of rules representing the driving variables of the linkage together with their substitutional values. |
$LDSimpleParameters | List of rules representing the simple parameters of the linkage together with their substitutional values. |
Records of the independent variables.
Define a simple pendulum mechanism
Out[20]= |  |
Browse the database of the linkage
Out[21]= |  |
The
$LDStructure record of the returned LinkageData object contains three kinematic pairs ( {
pendulum@RotationalJoint-1,
pendulum@FixedJoint-2} ). The generated homogeneous transformation matrices contain the independent variables
q1 and
l1. The first symbol is a driving variable, while the second is a simple parameter. Both the driving variables and the simple parameters are independent variables of the linkage. This implies that their values can be changed independently (Note that linkages with connected kinematic graph, the values of the independent variables might constrained by the loop closure equations. Certain combinations of independent variable values result non-real value solution of the loop closure equations. However even in this case there exist a feasibility interval of the variables, where the values can be arbitrarily changed.)
The most important difference of
driving variables and
simple parameters is their influence on the mobility of the linkage. The
driving variables determines the mobility of the linkage, while the
simple parameters does not influences it. In case of open kinematic pair definition the mobility of the linkage is increased with the number of joint variables. In this case the joint variables represent the remaining Degree of Freedom (
DoF) of the upper link relative to the lower link after the kinematic pair definition is applied. In case of rotational joint- out of the possible 6 DoF of the upper link- removes 5 DoF from the upper link. This DoF is the rotation around the z-axis of the joint marker. The value of joint variable "
drives" this remaining
DoF.
The simple parameters, on the other hand, are basically placeholders of dimensional values. If they are used instead of numbers, all kinematic equations or transformation are generated using the parameter symbols. This way the dimensional values can be easily changed without redefine the whole linkage.
SetDrivingVariables[linkage,{vari→xi..}] | sets vari driving variable of linkage to xi and return the resulted LinkageData |
SetDrivingVariablesTo[linkage,{vari→xi..}] | Set the vari driving variable to xi value and resets the resulted LinkageData to linkage. |
SetSimpleParameters[linkage,{vari→xi..}] | sets vari simple parameter to xi and returns the resulted LinkageData object. |
SetSimpleParametersTo[linkage,{vari→xi..}] | sets vari simple parameter to xi and resets the resulted LinkageData object to linkage. |
Functions for setting the independent variables of LinkageData.
The numerical substitution value of the independent variables ( driving variable, simple parameter ) are stored together with the placeholder symbols, since they are wrapped with a
Rule function. Their values can be changed with the
SetDrivingVariables and
SetSimpleParameters functions.
Set the q1 driving variable to -45
Out[22]= |  |
Set the l1 simple parameters to

Out[23]= |  |
Out[24]= |  |
In case of linkages with simple kinematic graph (serial chain or tree) setting the independent variable is nothing else but replacing the second argument of the
Rule function. However for more complicated linkages, setting the independent variables includes the solution of the constraint equations for the new set of independent variables. This is the reason while it is advised to use the setter function instead of directly replace the values of the
LinkageData.
Dependent variables of the linkage
There are two kind of dependent variables defined in LinkageData. If the dependent variable (y) can be expressed as the explicit function of the independent variables
(x1, x2, ...), than it is stored in the
$LDDerivedParametersA record. However if the dependent variable
y is defined implicitly with an equation, it is stored in the
$LDDerivedParametersB record
y = f[x1,x2,...] | y is an explicitly defined variable |
g[y,x1,x2,...] = 0 | y is an implicitly defined variable |
Different type of dependent variables.
Implicitly defined dependent variables
Implicitly defined variables are generated automatically if a
loop closing kinematic pair is defined.
DefineKinematicPair function detects, whether the kinematic pair is a
loop closing or an
open one. In the first case it calculates the mobility of the
upper link of the kinematic pair relative to the
lower one. Based on the result it constructs the set of non-redundant constraint equations. Finally it removes as many driving variables from the
$LDDrivingVariables record as the number of constraint equations. The constraint equations are stored in the
$LDDerivedParametersB record.
Load the pre-defined crank-slider mechanism
Out[25]= |  |
Display the linkage and its kinematic graph
Out[26]= |  |
List the independent variables of the linkage
Out[27]= |  |
Out[28]= |  |
List the implicitly defined dependent variables of crank-slider mechanism
Out[29]= |  |
Implicitly defined variables are
{q2, q3}. Their value are calculated with
FindRoot function after the actual values of the independent variables are substitued. Implicitly defined variables can be converted into explicitly defined variables if the constraint equations are solved in a closed form.
Explicitly defined dependent variables
The loop closing constraint equations of the crank-slider mechanism can be easily solved in closed form. It is possible to use the standard
Solve function or utilize the
PatternSolve utility function of LinkageDesigner.
Simplify the loop closing constraint equations
Out[31]= |  |
One solution method is to eliminate the q3 variable from the two equations and solve the remaining equation for
q2.
Eliminate q3 from the equations
Out[32]= |  |
Solve the remaining equation for q2
Out[33]= |  |
Solve the eliminated equation for q3
Out[34]= |  |
Out[35]= |  |
In
crankSlider linkage the
{q2, q3} variables are stored as implicitly defined variables. Using the
ReplaceVariables function a new LinkageData can be defined, which defines explicitly these variables.
Replace the implicitly defined variables with explicit functions
Out[36]= |  |
Browse the original and new LinkageData
Out[37]= |  |
Out[38]= |  |
Utility records
The pre-defined LinkageData records contains some auxiliary utility records that are used in the visualization and simulation of the linkages.
Utility records.
In order to visualize a linkage, the geometric representation of the links should be stored. The
$LDLinkGeometry record stores the geometric representations of the link, which is a
Graphics3D object. Geometries can be defined to the links using different functions such as:
DefLinkGeometryTo[linkage,type] | assigns simplified geometries to every links of linkage. The geometries of the links are determined by the center points of the joint markers. |
linkage[[$LDLinkGeometry,link]]=Graphics3D[...] | Sets the geometry of the link in the $LDLinkGeometry record of LinkageData. |
Geometry input functions.
| | |
AppendLinkGeometry | Automatic | the geometric representation contains only a text primitive, withthe name of the link. |
AppendLinkGeometry | None | the geometric representation is an empty Graphics3D object |
AppendLinkGeometry | gr | Botth link will use the same Graphics3D object gr |
AppendLinkGeometry | {grLower,grUpper} | the geometric representation of the lower link is grLower while the upper link is grUpper |
AppendLinkGeometry options of DefineKinematicPair function
List the link' geometries of crank-slider mechanism
Out[39]= |  |
Set the geometry of
link0 to a cylinder
Out[40]= |  |
Replace the geometry of
link3 link with Cuboid
Out[41]= |  |
Out[42]= |  |
During the simulation of the linkage the position of every LLRF should be calculated relative to the global reference frame. These transformation matrices are calculated using the kinematic graph of the linkage. Sometimes it speeds up the animation if the link-ground transformations are calculated in advance to spare the time of calculations before each animation steps. The
$LDLinkGroundTransformation record is calculated and appended if the
PlaceLinkage function is called. All animation function recognize the presence of
$LDLinkGroundTransformation record and use it if it is defined.
Manipulate $LDLinkGroundTransformation record.
List the link-ground transformation of
link3
Out[43]//MatrixForm= |
|  |
The pre-defined crank slider mechanism has already a placement transformation which parameterize the orientation and position of the whole linkage. This placement transformation is stored in the Ground-Workbench kinematic pair.
Retrieve the Ground-Workbench transformation of crank slider mechanism (Note that the name of the Workbench is
link0)
Out[44]= |  |
Place linkage to the global reference frame and retrieve the link-ground transformation of
link3
Out[46]//MatrixForm= |
|  |
Kinematics and dynamics
LinkageData by default does not contains kinematic records, because the basic analysis does not requires it. In order to calculate the velocity or acceleration, the linkage should be converted into a time dependent linkage. As the linkage is converted into time dependent linkage
LinkageDesigner calculates and stores the required records in
$LDTimeDependentVariables and
$LDDrivingVelocities records.
Kinematics related records in LinkageData.
Two function is defined in LinkageDesigner to calculate kinematics record:
ToTimeDependentLinkage or
NToTimeDependentLinkage functions. The primary task of these functions is to calculate the first derivatives of all time dependent variables and store them in the
$LDTimeDependentVariables record.
Convert linkages into time dependent ones.
Load the pre-defined crankSlider mechanism
Out[47]= |  |
Convert crank-slider mechanism to time dependent linkage symbolically
Out[48]= |  |
List the first derivatives of the time dependent variables
Out[49]= |  |
Retrieve the $LDDrivingVelocities record
Out[50]= |  |
Get the velocity and angular velocity of the slider
Out[51]= |  |
Plot the
vx and
vy coordinate functions of the slider's velocity
Out[53]= |  |
Dynamical calculation requires also some pre-defined records where the mass properties of the links, the forces and torques acting on the linkage can be stored.
$LDMassProperties | Stores the mass properties of the links. Mass properties data consist of a list of {inertiaFrame,mass,momentOfInertia} sublist. |
$LDForces | Stores a list of forces that acting on the mechanism. Forces are stored as {{str1,vec},{str2,pointofAttack}} sublist |
$LDTorques | Stores a list of torques vectors acting on the linkage. Torques are stored as {{str1,vec},{str2,pointofAttack}} |
Records of the dynamical calculation.
Load the double pendulum linkage
Out[55]= |  |
Out[56]= |  |
The double pendulum linkage has already defined
$LDMassProperties record. LinkageDesigner provides a number of function that calculates the mass properties of links based on their geometries. If the mass properties are not known the
CalculateMassProperties function can determine the mass, center of gravity and moment of inertia of closed polyhedron geometrical models assuming uniform density.
CalculateMassProperties[linkage,dens] | calculates the mass properties of all links of linkage using dens density value and assigns the {frame,mass,moment of inertia } values to the $LDMassProperties record. The function returns the updated LinkageData record. |
CalculateMassProperties[linkage,{name1→dens1,name2→dens2,...}] | calculates the mass properties of the specifies links using the specified densities. |
CalculateMassProperties[linkage] | calculates the mass properties of all geometries using unit density. |
Calculate mass properties.
Calculate weight vectors of the pendulum
Out[57]= |  |
List the force vectors of the linkage
Out[58]= |  |
Display the linkage with the force vectors
Out[59]= |  |
CalculateWeight[linkage,gvec] | function calculates the the weight vector to links based on the mass property definition. The weight vector is inserted into the $LDForces record of linkage. Weight vector is calculated as m*gVec, where m is the mass of the link and gVec is the gravity vector. Weight vector is acting at the center of mass of the link. The function returns the resulted LinkageData record. |
CalculateWeight[linkage] | function calculates the the weight vector to all links assuming that the gravity vector is {0,-9.81,0} |
DefineForceVector[linkage,{lName1,pt},{lName2,f}] | function adds one force vector to the LinkageData of linkage. The force vector is defined with a point of attack (pt) which is defined w.r.t lNamei's LLRF and the force vector (f), which is defined w.r.t lName2's LLRF. lName1 and lName2 are link names of linkage. The function returns the resulted LinkageData. |
DefineForceVector[linkage,lName,f] | function adds a force definition to the LinkageData of linkage assuming that the point of attack is the origin of lName and the force (f) is defined with respect to the Ground of the linkage. |
Force definition functions.
Define a torque vector that is acting on link1
Out[60]= |  |
Define a torque vector that is acting on the link2
Out[61]= |  |
Out[62]= |  |
DefineTorqueVector[linkage,{lName1,pt},{lName2,t}] | function adds a torque vector to the LinkageData of linkage. The torque vector is defined with a point of attack (pt) which is defined w.r.t lName1's LLRF and the torque vector (t) which is defined w.r.t lName2's LLRF. lName1 and lName2 are link names defined in linkage. Torque definition is inserted to LinkageData of linkage. The function returns the resulted LinkageData. |
DefineTorqueVector[linkage,lName,t] | function adds a torque definition to the LinkageData of linkage assuming that the point of attack is the origin of lName and the force (t) is defined with respect to the Ground of the linkage. |
Define Torque vector.
As soon as the mass properties and forces/torques are defined on the linkage, the LinkageData contains all information that is required for static or dynamical analysis of the mechanism.
Set the driving velocities to 0. These values will be used as initial velocities at start time.
Out[63]= |  |
Set the driving variables to 15° and 45° respectively these value will be used as initial values at start time
Out[64]= |  |
SolveLagrangian[linkage,{t,start,end}] | function calculates the Lagrangian of the linkage, define the Lagrange's equations and numerically differentiateit. It returns the list of interpolation functions of the driving variables. |
Solve dynamical simulation.
Solve the Lagrangian's equation fro (0,10) interval
Out[65]= |  |
Plot the time function of the generalized coordinates
Out[66]= |  |
Animate the dynamical simulation
Out[67]= |  |