The LinkModel command returns a "connection module" that allows programmatic access to a MapleSim model.
Important: You must first link to a MapleSim model before you can access the MapleSim API commands for your model.
The LinkModel command is part of the MapleSim package. You can access this command using the long form of the command name, MapleSim:-LinkModel, or by first executing with(MapleSim) and then using the short form of the command name, LinkModel.
You can attach a worksheet to any model through Add Apps or Templates > Templates > Worksheet. These worksheets have the LinkModel command inserted and the default "connection module" is named A.
Kinematic Variables and Functions
Every system is modeled by a set of generalized coordinates, q, and generalized speeds, p. The time derivatives of q are related to p through a derived set of kinematic transformations. If the coordinates, q, are not independent, they are related to each other through a set of position constraints. Similarly, if the speeds, p, are dependent, their inter-relationships are defined by the velocity constraints, and their derivatives by the acceleration constraints. The table below summarizes these exported kinematic variables and functions.
Generalized coordinates selected by user (n x 1 column matrix)
Generalized speeds selected by user (n x 1 column matrix)
State variables, comprised of generalized speeds
and coordinates (2n x 1 column matrix)
Time derivative of generalized coordinates
Time derivative of generalized speeds
Time derivative of state variables
Transformation between vQdot and vP (n x 1 column matrix)
Right-hand side of GetKinTrans() function
Position-level kinematic constraint equations in terms of the n coordinates (m x 1 matrix)
Jacobian matrix of the position constraint equations with respect to the generalized coordinates (m x n matrix)
Velocity-level kinematic constraint equations, which are nonlinear in the coordinates q and linear in the speeds p (m x 1 column matrix)
Jacobian matrix of the velocity constraint equations with respect to the generalized speeds (m x n matrix)
Right-hand side of velocity-level kinematic constraint equations
Acceleration-level kinematic constraint equations, which are nonlinear in p and q, and linear in accelerations (m x 1 column matrix)
Jacobian matrix of the acceleration-level constraints is identical to that for velocity-level constraints, and equal to the product of Φq⁢and hp, where hp⁢is the partial derivative of h with respect to the speeds p
Right-hand side of acceleration-level kinematic constraint equations
The GetMultibody command generates a module containing the multibody portion of the active MapleSim subsystem. The command produces a module whose exports are in the Model Exports column of the table above. The general form of this command is:
The kinematic export commands described in the table above and in the sections below all work on the multibody module that GetMultibody creates.
The GetFrameMotion command generates expressions for the translational or rotational motion of any moving frame in the system, in terms of the defined coordinates and speeds. The general form of this command is:
> MB := A:-GetMultibody():
where the vector describes the motion of the end_frame relative to the start_frame (the default is the inertial frame), resolved in components along the ref_frame (default is the inertial frame).
The vector_type string may take one of the following values:
• "r" - translational position vector
• "v" - translational velocity vector
• "vdot" - translational acceleration vector
• "R" - rotation transformation matrix (gives orientation of end_frame relative to start_frame; the ref_frame string must be omitted when this 3x3 matrix is requested)
• "w" - angular velocity vector
• "wdot" - angular acceleration vector
Finally, the ListNumSubs list is used to enter numeric values for parameters that appear in the motion expressions in symbolic form. To determine which system parameters have not been assigned numerical values, use the GetParams command. The ListNumSubs list takes the general form [pd_1=value_1, pd_2=value_2, ...], where pd_i is the i_th parameter or driver and value_i is the numeric parameter value or driving function of time.
A few examples will help to clarify these concepts.
gives the three global X, Y, Z components of the translational velocity of the CoM frame relative to the inertial frame.
gives the three global X, Y, Z components of the translational acceleration of the CoM frame relative to the Base frame.
> Params:= [L1=1, L2=0.5]:
gives the angular velocity of the CoM frame relative to the Base frame, resolved into x, y, and z components along the Ref frame. Numerical values for L1 and L2 are stored in the Params list, and substituted into the symbolic expressions.
gives the 3x3 rotation matrix transformation from the Base frame to the CoM frame. A complete description of rotation matrices is given in the section Building System Models / Bodies and Frames.
The GetNodeNames command collects the generated names for the system nodes. In multibody modeling when connecting two distinctly named nodes, MapleSim chooses one of the node names internally and uses that name for the connected node. However, when referencing node names in a command, you may explicitly define any applicable node name in the system. The general form of this command is:
> MB := A:-GetMultibody():
The GetParameters command collects all of the system parameters the have not been assigned numerical values (symbols) in the system. This command does not rely on the multibody module. The general form of this command is:
The example below shows an embedded MapleSim model of a planar slider-crank mechanism. The form of the commands below assume that you are using a Worksheet attached to the MapleSim model through Add Apps or Templates > Templates > Worksheet. In this example we are going to name our multibody exports module SliderCrank.
A ≔ MapleSim:-LinkModel⁡:
SliderCrank ≔ A:-GetMultibodysimplify:
Performing constraint analysis...
The system has 1 degree(s) of freedom. It is modeled using 3 generalized coordinate(s) coupled by 2 algebraic constraint(s).
Performing a dynamic analysis using an augmented reaction formulation - system variables shown below:
Dynamic analysis complete.
SliderCrank:-GetFrameMotionv, Main.R2.frame_b, GROUND, GROUND;
SliderCrank:-GetFrameMotionR, Main.R2.frame_b, GROUND, GROUND;
Dynamic Exports, MapleSim, MapleSim[LinkModel][GetMultibody]
Download Help Document