# Motion: Marker Based

Model ElementMotion_Marker defines a motion input between two Reference_Markers.

## Description

The motion input may be translational or rotational. You define an expression for the motion characteristics. The expression may be used to define a displacement, velocity, or acceleration input. The expression is usually a function of time. Refer to Comment 8 if you want to make the motion expression dependent on system states.

Translational motions may be defined in one of the ways listed below.
1. The functions DX(), DY(), and DZ() represent the x-, y- and z-components, respectively, of the translational displacement vector of the I Reference_Marker, relative to the J Reference_Marker, as measured in the coordinate system of the J Reference_Marker.
• DX(I,J,J) - expression = 0
• DY(I,J,J) - expression = 0 >> Translational Displacement Motion
• DZ(I,J,J) - expression = 0
2. The functions VX(), VY(), and VZ() represent the x-, y- and z-components, respectively, of the translational velocity vector of the I Reference_Marker relative to the J Reference_Marker, as measured in the coordinate system of the J Reference_Marker. The time derivative is taken in the reference frame of the J Reference_Marker.
• VX(I,J,J,J) - expression = 0
• VY(I,J,J,J) - expression = 0 >> Translational Velocity Motion
• VZ(I,J,J,J) - expression = 0
3. The functions ACCX(), ACCY(), and ACCZ() represent the x-, y- and z-components, respectively, of the translational acceleration vector of the I Reference_Marker relative to the J Reference_Marker, as measured in the coordinate system of the J Reference_Marker. All time derivatives are taken in the reference frame of the J Reference_Marker.
• ACCX(I,J,J,J) - expression = 0
• ACCY(I,J,J,J) - expression = 0 >> Translational Acceleration Motion
• ACCZ(I,J,J,J) - expression = 0
Rotational motions may be defined in one of the ways listed below.
1. B1(I,J), B2(I,J), and B3(I,J) represent the first, second, and third angles of the Body 1-2-3 Euler angle sequence that orients the I Reference_Marker with respect to the J Reference_Marker. See the Comments section for a more detailed description of the B123 Euler rotation sequence.
• B1(I,J) - expression = 0
• B2(I,J) - expression = 0 >> Rotational Displacement Motion
• B3(I,J) - expression = 0
• d [B1(I,J)] / dt - expression = 0
• d [B2(I,J)] / dt - expression = 0 >> Rotational Velocity Motion
• d [B3(I,J)] / dt - expression = 0
• d2 [B1(I,J)] / dt2 - expression = 0
• d2 [B2(I,J)] / dt2 - expression = 0 >> Rotational Acceleration Motion
• d2 [B3(I,J)] / dt2 - expression = 0

## Format

Expression-based Motion
<Motion_Marker
id           = "integer"
[ label        = "string" ]
i_marker_id  = "integer"
j_marker_id  = "integer"
direction    = { "X" | "Y" | "Z" | "B1" | "B2" | "B3" }

{   val_type     = "D"
|
val_type     = "V"
ic_disp      = "real"
|
val_type     = "A"
ic_disp      = "real"
ic_vel       = "real"
}
{
type                = "expression"
expr                = "motionsolve_expression"
|
type                = "USERSUB"
usrsub_dll_name     = "valid_path_name"
usrsub_param_string = "USER( [[par_1[,...][,par_n]] )"
usrsub_fnc_name     = "custom_fnc_name" >
|
type                = "USERSUB"
script_name         =  valid_path_name
interpreter         = {"PYTHON" | "MATLAB"}
usrsub_param_string = "USER([[par_1[,...][,par_n]])"
usrsub_fnc_name     = "custom_fnc_name"
}
/>
Plant Input-based Motion
<Motion_Marker
id            = "integer"
[label         = "string"]
i_marker_id   = "integer"
j_marker_id   = "integer"
direction     = { "X" | "Y" | "Z" | "B1" | "B2" | "B3" }
type          = "PLANT_INPUT"
pinput_id     = "integer"
val_index     = "integer"
/>

## Attributes

id
Element identification number (integer>0). This number is unique among all Motion_Marker elements.
label
The name of the Motion_Marker element.
i_marker_id
Specifies the Reference_Marker ID at which the motion input is applied.
j_marker_id
Specifies the Reference_Marker ID from which the motion input is applied.
direction
Specifies the direction of the input. Select one from "X", "Y", "Z", "B1", "B2", and "B3".
"X", "Y", and "Z" specify the direction for the translational motion. This is measured in the coordinate system of the J marker.
"B1", "B2", "B3" are the Body 1-2-3 or Tait-Bryant angles that take you from the J marker orientation to the I marker orientation. Your selection specifies the angle that is being used in the motion.
val_type
Specifies whether the motion applies a displacement input (D), a velocity input (V), or an acceleration input (A). You must select one value from "D", "V" or "A".
ic_disp
Specifies the displacement initial condition that is required when val_type = "V" or val_type = "A".
ic_vel
Specifies the velocity initial condition that is required when val_type = "A".
type
Select from EXPRESSION, USERSUB, and PLANT_INPUT. Specifies how the motion expression is defined.
EXPRESSION
Specifies that the motion value is a MotionSolve expression that can be evaluated at run-time.
USERSUB
Indicates that the value of the motion is specified in a user-defined subroutine. The parameters "usrsub_param_string" and "usrsub_dll_name" are used to provide more information about the user-defined subroutine.
PLANT_INPUT
Indicates that the Motion is used as a plant input. “val_index” defines the enforcement level and “pinput_id" references the Control_PlantInput.
expr
Defines an expression that defines the motion value. Use this parameter only when type = EXPRESSION. Any valid run-time MotionSolve expression can be provided as input.
usrsub_param_string
The list of parameters that are passed from the data file to the user defined subroutine. Use this keyword only when type = USERSUB is selected.
usrsub_dll_name
Specifies the path and name of the DLL or shared library containing the user subroutine. MotionSolve uses this information to load the user subroutine in the DLL at run time.
usrsub_fnc_name
Specifies an alternative name for the user subroutine MOTSUB.
script_name
Specifies the path and name of the user written script that contains the routine specified by usrsub_fnc_name.
interpreter
Specifies the interpreted language that the user script is written in. Valid choices are MATLAB or PYTHON.
val_index
Defines the simultaneous enforcement of constraints at position, velocity, and acceleration levels.
"3"
The motion is enforced only at the position level.
"2"
The motion is enforced at the position and velocity level simultaneously.
"1"
The motion is enforced at the position, velocity, and acceleration level simultaneously.
See Comment 10.
pinput_id
Specifies the Control_PlantInput ID at which the motion input is applied.

## Examples

Assume that you have measured the displacement and velocity of the origin of a coordinate system Marker J in the coordinate system of a Marker I as a function of time. You can specify the three translational displacements of Marker I with respect to Marker J as:

<Motion_Marker
id             = "1"
i_marker_id    = "301"
j_marker_id    = "201"
direction      = "X"
val_type       = "D"
type           = "EXPRESSION"
expr           = "CUBSPL(1, Time, 0)"
/>

<Motion_Marker
id             = "2"
i_marker_id    = "301"
j_marker_id    = "201"
direction      = "Y"
val_type       = "D"
type           = "EXPRESSION"
expr           = "CUBSPL(2, Time, 0)"
/>

<Motion_Marker
id             = "3"
i_marker_id    = "301"
j_marker_id    = "201"
direction      = "Z"
val_type       = "D"
type           = "EXPRESSION"
expr           = "CUBSPL(3, Time, 0)"
/>

Alternatively, you could have specified the velocity of the J marker as seen by the I Marker as:

<Motion_Marker
id             = "11"
i_marker_id    = "301"
j_marker_id    = "201"
direction      = "X"
val_type       = "V"
icdisp         = "-4.56"
type           = "EXPRESSION"
expr           = "CUBSPL(11, Time, 0)"
/>

<Motion_Marker
id             = "12"
i_marker_id    = "301"
j_marker_id    = "201"
direction      = "Y"
val_type       = "V"
icdisp         = "11.13"
type           = "EXPRESSION"
expr           = "CUBSPL(12, Time, 0)"
/>

<Motion_Marker
id             = "13"
i_marker_id    = "301"
j_marker_id    = "201"
direction      = "Z"
val_type       = "V"
icdisp         = "0.0"
type           = "EXPRESSION"
expr           = "CUBSPL(13, Time, 0)"
/>

The second example demonstrates how you may specify the motion of the end-effector of a robotic manipulator while it is executing a 3-D path through global space.

Reference_marker 314159 defines a coordinate system at the tip of the end-effector. Reference_Curve 3 defines the 3-D curve in global space. The X-, Y- and Z-coordinates of the end-effector are to be specified as a function of time. Motions in the X- and Y-directions are shown below.
<Motion_Marker
id	      = "101"
i_marker_id    = "314159"
j_marker_id    = "0"
direction      = "X"
val_type       = "D"
type           = “EXPRESSIION”
expr           = "CURVE(Time, 0, 1, 1)"
/>

<Motion_Marker
id	      = "101"
i_marker_id    = "314159"
j_marker_id    = "0"
direction      = "Y"
val_type       = "D"
type           = “EXPRESSIION”
expr           = "CURVE(Time, 0, 1, 2)"
/>

<Motion_Marker
id	      = "101"
i_marker_id    = "314159"
j_marker_id    = "0"
type           = “EXPRESSIION”
direction      = "Z"
val_type       = "D"
type           = “EXPRESSIION”
expr           = "CURVE(Time, 0, 1, 3)"
/>

The third example demonstrates how you may specify the motion as a plant input to create a Descriptor (implicit) State Space representation of the mechanical system or plant.

Reference_Variable 1 defines the motion as an expression at the position level. The Control_PlantInput collects the inputs to the Motion_Marker
<Reference_Variable
id                  = "1"
type                = "EXPRESSION"
expr                = "DM(1,1)"
/>

<Control_PlantInput
id                  = "1"
hold_order          = "1"
sampling_period     = "0."
offset_time         = "0."
num_element         = "1"
variable_id_list    = "1"
/>

<Motion_Marker
id                  = "1"
i_marker_id         = "2"
j_marker_id         = "1002"
type                = "PLANT_INPUT"
direction           = "Z"
val_index           = "3"
pinput_id           = "1"
/>

1. One constraint is added for each Motion_Marker.
• When a displacement constraint is specified (val_type="D"), the expression defines the instantaneous displacement of the Motion.
• When a velocity constraint is specified (val_type="V"), the expression defines the instantaneous velocity of the Motion. The current displacement is obtained by integrating the instantaneous velocity over time.
• When an acceleration constraint is specified (val_type="A"), the expression defines the instantaneous acceleration of the Motion. The current velocity is obtained by integrating the instantaneous acceleration over time. The current displacement is obtained by integrating the instantaneous velocity over time.
2. Differentiation tends to amplify any noise in the input signal. It is therefore important to ensure that all expressions and experimental data provided as input be smooth. More precisely, they must have continuous first- and second-time derivatives. Avoid the AKIMA()interpolation method when interpolating through experimental data. AKIMA() does not calculate good first and second derivatives. Use CUBSPL()instead.
3. Integration tends to decrease the noise in an input signal. Therefore, it is a good idea to use velocity inputs when providing interpolated experimental or tabular data as motion input expressions.
4. Define your curve with as few points as possible. Excessively large number of interpolation points in a cubic curve makes its first derivative "jumpy", and its second derivative "extremely jumpy", even though the curve itself may look smooth.
5. Make sure that the initial velocity of the motion matches the initial velocities of the bodies that it affects. For example, if your mechanism simulation starts from an initial static state, then you should make sure that the input motion has zero initial velocity. The motion input overrides any conflicting body and joint initial velocities.
6. If you decide to use velocity inputs, be aware that the position is satisfied only to the integration error specified in the Param_Transient element. Likewise, for acceleration inputs, the velocity and position are only satisfied to the integration error specified. Therefore, you may see some drift from the analytical solution. This is a limitation of any scheme based on numerical integration.
7. It is useful to look at the reaction force/torque time histories due to the motion constraint. It tells you how much force/torque is needed to achieve the given motion. You should ascertain whether this is realistic. Furthermore, it sometimes makes better physical sense to replace the motion with applied forces coupled with control laws. Remember that motion in a dynamic analysis is treated as a "hard" constraint with no room for compliance.
8. Motions may only be functions of time (type=”EXPRESSION”) or a plant input (type = “PLANT_INPUT”). You should try to avoid using functions of other system displacements, velocities, accelerations, reaction forces, and applied forces. MotionSolve may or may not be able to find a solution in such cases. If you find such a need, for example to implement a control law, then write a user subroutine to do so. However, you must apply a time lag to the system data you are requesting and then smooth it as discussed below.
• Assume that a Motion_Joint is used to apply a displacement that is based on the sensed radial velocity between two Reference_Markers 100 and 200. Then, you must code the user subroutine to implement the following:
EXPR(Tk+1) = VR(100,200)|Tk

evaluated at Tk, where Tk+1- Tk is the sampling period for the system.

Note that EXPR(Tn+1) is constant. However, it changes whenever the velocity VR() is sampled. This implementation is not adequate because the sampled values are not continuous. Now, you must fit a curve through the previously sampled values and extrapolate the curve to provide a smooth value. This is shown symbolically below:
EXPR(Tk+1) = CUBIC(VR(100,200)|Tk, VR(100,200)|Tk-1, VR(100,200)|Tk-2)
9. Directions B1, B2, and B3 refer to first, second, and third angles of the 1, 2, and 3 Euler angles to orient the I marker relative to the J marker. The image below illustrates this sequence.
• Start with a coordinate system X-Y-Z. Rotate the system about the X axis. This is the B1 rotation. Due to this rotation, Y will move to Y' and Z to Z'. The coordinate system obtained due to the B1 rotation is X-Y'-Z'.
• Now rotate about the Y' axis by an angle B2. Due to this rotation, Z' will move to its final location, Z1 and X to X''. The coordinate system obtained due to the B2 rotation is X''-Y'-Z1.
• The final rotation occurs about the Z1 axis. Due to this rotation, B3, X'' moves to it final location, X1 and Y' to its final location, Y1. The original orientation is X-Y-Z, the final is X1-Y1-Z1.
10. If you choose to define motion via plant input, then the motion constraints can be exactly satisfied at the position level $\left(\Phi \left(q\right)=0\right)$ , or simultaneously at the position and velocity level $\left({\left[\begin{array}{cc}\Phi \left(q\right)=0& {\Phi }^{\prime }\left(q\right)=0\end{array}\right]}^{T}\right)$ , or simultaneously at the position, velocity, and acceleration level ${\left[\begin{array}{ccc}\Phi \left(q\right)=0& \Phi \prime \left(q\right)=0& {\Phi }^{″}\left(q\right)=0\end{array}\right]}^{T}$ . You must provide the motion at all necessary levels using Reference_Variable and gather them into a list using the Control_PlantInput. From a mathematical point of view, the index number references the index of the DAE induced by the Motion_Marker. Reducing the index number decreases the possibility of a constraint violation.