Documentation Center

  • Trial Software
  • Product Updates

Represent Box Frame Tree

Model Overview

In SimMechanics™, you can rigidly connect multiple Solid blocks to represent a complex rigid body. To position and orient different solids with respect to each other, you create a frame network that you can connect the solids to. The frame network contains Rigid Transform blocks that specify the spatial relationships between the different frames. In this example, you represent the frame tree for a box shape.

The example highlights the Rigid Transform block as the basic tool that you use to specify spatial relationships between frames and the solids that connect to them. The complete frame network is complex. It highlights nearly every type of rigid transformation that you can apply between two frames.

The modeling process in this example contains four stages:

  1. Add World Frame (W).

    This is the ultimate reference frame against which you define all other frames.

  2. Add the frames of the box bottom plane (frames A-D in the figure).

    You define these frames directly with respect to the World frame.

  3. Add the frames of the box top plane (frames E-I in the figure).

    You define these frames directly with respect to the box bottom plane frames.

  4. Add the frames of the box arch (frames K and J in the figure).

    You define these frames directly with respect to the center frame of the box top plane.

This example is based on model sm_frame_tree, which accompanies your SimMechanics installation. To open this model, at the MATLAB® command line, enter sm_frame_tree.

Start Model

Start a new model. Then, add a global reference frame that you can use to define other frames.

Use the World Frame block to represent the World frame:

  1. Start a new model.

  2. Drag the following blocks into the model.

    LibraryBlockQuantity
    Frames and TransformsWorld Frame1
    Simscape™ UtilitiesSolver Configuration1

  3. Connect the blocks as they appear in the figure.

Initialize Model Workspace Parameters

To specify the distance offsets between frames, you use Rigid Transform blocks. In this example, you specify the distance offsets in terms of MATLAB variables that you initialize in the model workspace. The table lists these variables.

DimensionVariable
LengthL
WidthW
HeightH

To initialize the MATLAB variables:

  1. On the Simulink® menu bar, click Tools > Model Explorer.

  2. On the Model Hierarchy pane, double-click the name of your model (e.g. frame_tree).

  3. Click Model Workspace.

  4. On the Model Workspace pane, in the Data Source drop-down list, select MATLAB Code.

  5. In the MATLAB Code section that appears, enter the following code:

    % Size of Cube
    L = 12;
    W = 10;
    H = 8;
  6. Click Reinitialize from Source.

Add Bottom Plane Frames

The World frame is the ultimate reference frame in a model. Now that you added the World frame to your model, you can define other frames with respect to it. You do this using the Rigid Transform block.

To define the four corner frames of the bottom box plane:

  1. From the Frames and Transforms library, drag four Rigid Transform blocks to the model.

  2. Connect and name the blocks as they appear in the figure.

  3. Double-click the Vertex W-A Transform block and, in the dialog box, specify the parameters that the table provides.

    Parameter SectionParameterValue
    RotationMethodSelect Standard Axis
    AxisSelect +Z
    AngleEnter 90 (deg)
    TranslationMethodSelect Cartesian
    OffsetEnter [L/2 W/2 0] (cm)

  4. Double-click the Vertex W-B Transform block and, in the dialog box, specify the parameters that the table provides.

    Parameter SectionParameterValue
    RotationMethodSelect Aligned Axis
    Pair 1 > Follower/BaseSelect +X/-X
    Pair 2 > Follower/BaseSelect +Y/-Y
    TranslationMethodSelect Cartesian
    OffsetEnter [-L/2 W/2 0] (cm)

  5. Double-click the Vertex W-C Transform block and, in the dialog box, specify the parameters that the table provides.

    Parameter SectionParameterValue
    RotationMethodSelect Standard Axis
    AxisSelect +Z
    AngleEnter 270 (deg)
    TranslationMethodSelect Cartesian
    OffsetEnter [-L/2 -W/2 0] (cm)

  6. Double-click the Vertex W-D Transform block and, in the dialog box, specify the parameters that the table provides.

    Parameter SectionParameterValue
    RotationMethodSelect None
    TranslationMethodSelect Cartesian
    OffsetEnter [L/2 -W/2 0] (cm)

To visualize the frames that you just added, on the Simulink menu bar, select Simulation > Update Diagram. Mechanics Explorer opens with a static 3-D display of your model. To view the position and orientation of each frame, in the Mechanics Explorer menu bar, select View > Show Frames.

Add Top Plane Frames

You can now define the top plane frames with respect to the bottom plane frames.

To add the top plane frames:

  1. From the Frames and Transforms library, drag five Rigid Transform blocks.

  2. Connect and name the blocks as they appear in the figure.

  3. Double-click the following blocks:

    • Vertex A-E Transform

    • Vertex B-F Transform

    • Vertex C-G Transform

    • Vertex D-H Transform

  4. In each block dialog box, specify the following parameters.

    Parameter SectionParameterValue
    RotationMethodSelect None
    TranslationMethodSelect Standard Axis
    Axis+Z
    OffsetEnter H (cm)

  5. Double-click the Vertex W-I Transform block and, in the dialog box, specify the following parameters.

    Parameter SectionParameterValue
    RotationMethodSelect Aligned Axes
    Pair 1 > Follower/BaseSelect +Y/-Z
    Pair 2 > Follower/BaseSelect +Z/+Y
    TranslationMethodSelect Standard Axis
    Axis+Z
    OffsetEnter H (cm)

To visualize the frames that you just added, on the Simulink menu bar, select Simulation > Update Diagram. Mechanics Explorer updates the 3-D view of the box frame tree.

Add Arch Frames

Finally, add the two arch frames. As before, use the Rigid Transform block to define these frames. Define them with respect to the center frame of the top plane (frame I).

To define the arch frames:

  1. From the Frames and Transforms library, drag two Rigid Transform blocks.

  2. Connect and name the blocks as they appear in the figure.

  3. Double-click the Vertex I-J Transform block and, in the dialog box, specify the parameters that the table provides.

    Parameter SectionParameterValue
    RotationMethodSelect Standard Axis
    AxisSelect +Z
    AngleEnter -90 (deg)
    TranslationMethodSelect Cylindrical
    RadiusEnter L/2 (cm)
    ThetaEnter -90 (deg)
    Z OffsetEnter W/2 (cm)

  4. Double-click the Vertex I-K Transform block and, in the dialog box, specify the parameters that the table provides.

    Parameter SectionParameterValue
    RotationMethodSelect Standard Axis
    AxisSelect +Z
    AngleEnter -90 (deg)
    TranslationMethodSelect Cylindrical
    RadiusEnter L/2 (cm)
    ThetaEnter -90 (deg)
    Z OffsetEnter -W/2 (cm)

To visualize the frames that you just added, on the Simulink menu bar, select Simulation > Update Diagram. Mechanics Explorer opens with a static 3-D display of your model. To view the position and orientation of each frame, on the Mechanics Explorer tool bar, check that the frame visibility icon is toggled on.

Save Model

Save the model as frame_tree in a convenient folder. In a subsequent example, you use Graphic blocks to represent each frame with a graphic icon. See Visualize Box Frame Tree

Related Examples

More About

Was this topic helpful?