Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Working with Generated Models

About CAD-Based Models

This section explores the characteristics of a generated CAD-based model, imported with default or nondefault settings. It also explains when and how to edit your model and expand it with additional blocks, such as Constraints, Drivers, Actuators, and Sensors. The section concludes by pointing out major model-generation and simulation errors and problems that can arise from CAD-based models, and techniques for solving them.

Common Features of CAD-Based Models

    Note:   This section assumes a model generated with default import settings and not yet edited manually. To see the effects of using nondefault import settings in a newly generated model, see the following section, Nondefault Features in Generated Models.

Most of the properties of models that you generate from an XML file are the same as the default properties of all Simulink® models. For information on working with Simulink models, see the Simulink documentation.

SimMechanics™ models that are successfully generated from CAD-based Physical Modeling XML have certain common properties that reflect their origin in CAD assembles:

  • Machine Environment, Ground, Body, and Joint blocks only.

  • The minimum Body coordinate systems and grounded coordinate systems necessary to connect each Joint to exactly two coordinate systems, one on each side of the Joint.

  • Unattached coordinate systems corresponding to reference coordinate systems in the original assembly and, in general, not associated with constraints.

  • Fundamental root, represented by Ground – Root Weld – Root Body. The Root Body occurs at the top of the main hierarchy. The Root Body has no mass and no inertia, and does not move.

  • Subsystems below the top level encapsulating subassemblies from the original assembly.

  • Subassembly roots, represented by Root Body – Root Weld – Fixed Body. A Root Body occurs at the top of each subsystem hierarchy if you need such a body to correctly represent constraints in the original CAD assembly.

  • Joints with DoFs containing the correct joint primitives for the translational and rotational DoFs between any two bodies.

    If no appropriate specific Joint exists, the importer inserts a Custom Joint with the appropriate primitives.

  • Joints without DoFs, represented by Welds.

  • Apart from Root Body blocks, each Body block referencing its STL body geometry file.

  • Both machine- and model-wide visualization enabled.

This is an example of a model generated from a robot arm assembly.

World Coordinate System and the CAD Assembly Origin

A generated model has one Ground. The origin of this Ground is the origin of the World coordinate system and represents the original CAD assembly origin.

SimMechanics Visualization and STL Body Geometry Files

Each body in a generated SimMechanics model, apart from the ground and root bodies, is configured to reproduce the body geometry and color of its original CAD assembly body. If the needed STL files were created upon export and are referenced by the generated model, the custom body geometries are visualized. Each Body references its own STL file.

    Caution   In order for custom visualization to work, this STL file must be either:

    • On your MATLAB® path.

    • In your MATLAB present working folder.

    • Specified with complete path in the Body dialog.

    Otherwise, visualization reverts to the default body geometry.

For More About CAD Assemblies

Fully understanding the structure of a generated model requires understanding the original system in its CAD representation. Refer to your originating CAD assembly, CAD platform and associated documentation, and the SimMechanics Link documentation.

Nondefault Features in Generated Models

The importer controls allow generation of models with nondefault appearance and structure. Optional, nondefault coordinate systems can enhance the fidelity and usefulness of your models.

See the preceding section, Controlling New Model Import and the mech_import function reference page.

Nondefault Appearance and Layout of Generated Models

The following table summarizes the default and possible nondefault appearance options of a newly imported model.

Default Appearance and Layout OptionsNondefault Appearance and Layout Options
Short Joint block names based on joint typePotentially long Joint block names based on model hierarchy
Block names that are potentially overlappingBlock names that do not overlap
Block diagrams first oriented horizontally from left to right, then vertically from top to bottomBlock diagrams first oriented vertically from top to bottom, then horizontally from left to right

Nondefault Hierarchy and Organization of Generated Models

The following table summarizes the default and nondefault hierarchy and organization options of a newly imported model.

Aspect of Hierarchy & OrganizationDefault Hierarchy & OrganizationNondefault Option ANondefault Option B
Location of
non-Weld Joints
At the subsystem level corresponding to the subassembly level in the original CAD assemblyAt the highest level of the model or subsystem being importedSame as default
Grouping of Bodies
rigidly connected by Welds
Ungrouped and located individually at the subsystem level corresponding to the subassembly level in the original CAD assemblyGrouped into their own subsystem within the subsystem corresponding to the subassembly level in the original CAD assemblySame as nondefault hierarchy A

Model Hierarchy and Organization Changed During Import: Graphical Examples.  These examples use the Physical Modeling XML example files, SimplificationExample1.xml and SimplificationExample2.xml. Detailed graphics show the model hierarchies and organizations resulting from different model simplification options during import. Key block types are color coded to indicate their function in the model.

Block ColorBlock Type
GreenRigidly welded Bodies
BlueWelds
RedMoving Joints (DoFs)

First, import SimplificationExample1.xml in two ways to see the difference between no model simplification and the reorganization by grouping Bodies rigidly connected by Welds.

  1. Import the file with no model simplification.

    The figure shows a detailed graphic of the default model hierarchy. Except for the root body at the top level of model hierarchy, the rigidly welded Bodies are ungrouped, at the first level below the top level.

  2. Import the file with the option to group Bodies rigidly connected by Welds into their own subsystems. (With the mech_import function, this choice corresponds to a value of 2 for the ModelSimplificationOpt option).

    The figure shows a detailed graphic of the reorganized model hierarchy. The rigidly welded Bodies in the subsystem are grouped into their own subsystem, creating a second level of hierarchy but simplifying the model appearance.

Second, import SimplificationExample2.xml in two ways to see the difference between no model simplification and the double simplification of:

  • Promoting moving Joints to the top level of hierarchy

  • Grouping Bodies rigidly connected by Welds

  1. Import the file with no model simplification. The figure shows a detailed graphic of the default model hierarchy. The moving Joints, representing degrees of freedom (DoFs), are located two levels down in the model hierarchy. Rigidly welded Bodies are ungrouped.

  2. Import the file with the option to promote the moving Joints to the top level and to group the Bodies rigidly connected by Welds into their own subsystems. (With the mech_import function, this choice corresponds to a value of 1 for the ModelSimplificationOpt option).

    The figure shows a detailed graphic of the simplified and reorganized model hierarchy. The DoFs, represented by the moving Joints, are promoted to the top level. Rigidly welded Bodies are grouped into a single subsystem. The model hierarchy is simplified with a single level below the top level, instead of two levels.

Coordinate Systems in Generated Models

In addition to the paired coordinate systems automatically generated for Body–Joint connections, a generated model can contain other coordinate systems:

Coordinate Systems: Automatically Generated, Inserted Before Export, and Manually Added After Import

Manually Modifying and Extending Generated Models After Import

A SimMechanics model satisfying full modeling requirements typically contains other blocks beyond those generated by import. These blocks can include Constraints, Drivers, Sensors, and Actuators (from the SimMechanics block library), as well as blocks from Simulink, such as Scopes. You manually insert and connect these additional blocks in your generated model.

    Tip   When you first generate a model from Physical Modeling XML, you might want to save this original CAD-based model before you create later versions by eliminating unnecessary blocks and adding new ones.

Deleting Unnecessary Blocks

The constraint-to-joint mapping creates whatever blocks are needed to correctly isolate the degrees of freedom (DoFs). In some models, certain generated blocks are not needed for simulation. You can delete these unnecessary blocks to simplify your model without affecting its dynamics, as long as you reconnect the remaining blocks properly.

In particular, you can simplify the fundamental root, Ground – Root Weld – Root Body, in certain cases. (The same holds for subassembly roots. However, the corresponding subsystem's Root Body takes the place of Ground, and the subsystem's Fixed Body plays the role of Root Body.)

  • If the Root Body is connected to the rest of the block diagram by a single Joint, you can delete the Root Weld – Root Body blocks and reconnect the Joint directly to Ground.

  • If the Root Body is connected to the rest of the block diagram by multiple Joints, you cannot delete the Root Weld – Root Body sequence because a Ground can connect to only one Joint, and the generated model contains only one Ground. You have two alternatives in this case:

    • Determine where the Root Body coordinate systems (CSs) are. Delete the Root Weld – Root Body sequence. Then manually add more Grounds at the spatial points representing each of the deleted Root Body CS origins. Reconnect each Joint to its corresponding Ground at the correct spatial point.

    • Leave the Root Weld – Root Body sequence as it is.

Regrouping, Reducing, and Eliminating Welds.  Not all Welds are redundant. Some Welds are needed to connect a Body that otherwise would be isolated from the rest of the model. Such Welds represent rigid connections between distinct assembly parts.

  • If you want to group Bodies rigidly connected by Welds into their own subsystems, use the model hierarchy simplification controls in the Advanced Options tab of the Import Physical Modeling XML dialog box or mech_import function.

  • If you want to reduce or eliminate such Welds, return to your original assembly and reexport it with rigid subassemblies. See the SimMechanics Link documentation.

Adding More Coordinate Systems

In addition to the automatically generated pairs of coordinate systems that connect Joints representing CAD constraints, you can also add your own coordinate systems to Bodies, after import. If you want to add Constraint, Driver, Actuator, or Sensor blocks to a generated model, and connect these blocks to one or more of the Bodies, you need extra Body coordinate systems as connection points.

These sections describe how to add Body coordinate systems to a Body:

Reference Coordinate Systems in the Original Assembly.  You can also insert reference coordinate systems, in general not associated with constraints, in the original assembly before export. You might find positioning and orienting such coordinate systems easier in the CAD environment. Translation preserves these coordinate systems, which appear in the generated model in addition to the coordinate systems pairs connecting Joints and Bodies.

For more information, see Inserting Reference Coordinate Systems into Assemblies Before Export in the following section, Troubleshooting Imported and Updated Models.

Constraining and Driving Degrees of Freedom

Constraints reduce the number of independent degrees of freedom in a mechanical system by preventing certain movements. Drivers affect DoFs, not by eliminating them completely, but by forcing their motions to follow an external time-dependent signal. A constrained or driven DoF is not free to respond to forces and torques independently.

These sections discuss how to add constraints and drivers to your model:

    Note:   You insert these constraints into the SimMechanics model as blocks. They act in addition to the part constraints in the original CAD assembly.

Actuating Bodies and Joints with Motions and Forces

You can actuate bodies and joints in your SimMechanics models with external forces and motions and set up internal forces between bodies. You can also vary the mass or inertia (or both) of a body in time. Consult these sections for more details:

Setting the Model's Initial Conditions

When you import a CAD assembly into the SimMechanics environment, the XML file determines the initial geometric configuration of the model's bodies. By default, the initial velocities of the bodies are zero, and the model is in home configuration.

If you want to change the initial positions and/or velocities of the bodies in your model to be different from the CAD-determined configuration, you need to add initial condition actuators, as discussed in Specifying Initial Positions and Velocities.

Sensing Forces and Motions

To detect the motions of bodies and joints and measure the forces acting on or through them, you can add sensors to your model. See Sensing Motions and Forces.

Satisfying SimMechanics Model Validity Requirements

You can find the general instructions for building valid SimMechanics models in these sections:

Changing Custom Body Visualization Geometries and Colors

When it generates the Body blocks in a model (except for Root Bodies), the SimMechanics importer automatically customizes the body geometries for visualization by referencing the STL files associated with the CAD assembly export. It also automatically customizes the body colors to match the original CAD part colors, which are captured by the exported XML file.

You can manually reset the custom visualization on one or more of these Bodies, changing body shape, color, or both. See the Body block reference page and About Custom SimMechanics Visualization.

Was this topic helpful?