Supported Solver Subroutines
To write a user subroutine, you first have to determine which user subroutine you need to use and select a programming language.
- Subroutine Name
- Corresponding MotionSolve XML Element
- ARYSUB
- <Reference_Array>
- CNFSUB
- <Force_Contact> - Normal force only
- CFFSUB
- <Force_Contact> - Friction force only
- CONSUB
- <UserProgramControl>
- CONTACTPOST
- <Force_Contact> - Custom processing of contact results
- COUSUB/COUXX/COUXX2
- <Constraint_Coupler>
- CURSUB
- <Reference_ParamCurve>
- DIFSUB
- <Control_Diff>
- DMPSUB
- <Body_Flexible>
- FIESUB
- <Force_Field>
- GCOSUB
- <Constraint_General>
- GFOSUB
- <Force_Vector_OneBody|TwoBody> - when type is ForceAndTorque
- GRASUB
- <Post_Graphic>
- GSESUB/GSEXX/GSEXU/GSEYU/GSEYX
- <Control_StateEqn>
- MARKER_READ
- <Reference_Marker>
- MATRIX_READ
- <Reference_Matrix>
- MESSAGE_SUB
- <Messaging>
- MFOSUB
- <Force_FlexModal>
- MOTSUB
- <Motion_Joint|Marker>
- NFOSUB
- <Force_MultiPoint>
- PFOSUB
- <Force_Penalty>
- PINSUB
- <Control_PlantOutput>
- POST_SUB
- <Post_UserAPI>
- POUTSUB
- <Control_PlantOutput>
- PTDSFSUB
- <Force_PTdSF>
- RELSUB
- <Load_Model>
- REQSUB
- <Post_Request>
- SAVSUB
- <Save>
- SENSUB
- <Sensor_Event>
- SEVSUB
- <Sensor_Evaluate>
- SFOSUB
- <Force_Scalar_TwoBody>
- SPLINE_READ
- <Reference_Spline>
- STRING_READ
- <Reference_String>
- SURSUB
- <Reference_ParamSurface>
- TUNSUB
- <Param_Simulation>
- UCOSUB
- <Constraint_UserConstr>
- VARSUB
- <Reference_Variable>
- VFOSUB
- <Force_Vector_OneBody|TwoBody> - when type is ForceOnly
- VTOSUB
- <Force_Vector_OneBody|TwoBody> - when type is TorqueOnly
- YFOSUB/YFOXU/YFOXX/YFOYU/YFOYX
- <Force_StateEqn>
To help you create a user subroutine, included in the installation is a series of simple routine templates (one for each supported routine) in Fortran, C/C++, Python and Compose/MATLAB programming/scripting languages. These templates are located in the following installation directories:
<install-path>\hwsolvers\motionsolve\usersub\f_src
<install-path>\hwsolvers\motionsolve\usersub\c_src
<install-path>\hwsolvers\motionsolve\usersub\mex
<install-path>\hwsolvers\motionsolve\usersub\py_src
Also included in the installation directory is a Microsoft Visual Studio Project file that can be optionally used to create your user library (DLL, Dynamic-Link Library).
- msolvsub_c_include.h for C/C++ code.
This external file is used to resolve the symbols of the various utility functions that can be invoked. They contain the function prototypes of utility functions like SYSFNC, AKISPL, and all other utility functions that can be used to access system states (displacement, velocity, acceleration, forces, and so on) and MotionSolve states (current simulation time, solver mode, and so on).
You can simplify the process of creating the DLL by using Microsoft Visual Studio with the supplied project file which contains all compiler and linker options, the name of the generated DLL, and the pointers to all source files used for generating the DLL.