Documentation

Working with Frames

What Are Frames?

Frames are axis triads that encode position and orientation data in a 3-D multibody model. Each triad consists of three perpendicular axes that intersect at an origin. The origin determines the frame position and the axes determine the frame orientation. The axes are color-coded, with the x-axis in red, the y-axis in green, and the z-axis in blue.

Role of Frames

Every solid component has one or more local frames to which it is rigidly attached. By positioning and orienting the component frames, you position and orient the components themselves. This is the role of frames in a model—to enable you to specify the spatial relationships between components.

Working with Frames

A frame port identifies a local frame on a component. For example, the R frame port of a Solid block identifies the local reference frame of a solid. Every block has one or more frame ports that you connect in order to locate the associated components in space. The figure shows the reference frame ports on the Body Elements blocks.

The connections between frame ports determine the spatial relationships between their frames. A direct frame connection line makes the connected frames coincident in space. A Rigid Transform block sets the rotational and translational offsets between the frames. The figure shows examples of coincident and offset frame connections.

A coincident relationship between solid frames does not, by itself, constitute a coincident relationship between solid geometries. The spatial arrangement of two solid geometries depends not only on the spatial arrangement of the respective reference frames, but also on how the geometries are defined relative to those frames.

If two geometries differ from each other, or if their positions and orientations relative to their reference frames differ from each other, then making the reference frames coincident will cause the solid geometries to be offset. In the figure, connecting the frame of Solid A to the left frame of Solid B joins the solids such that their geometries are offset from each other.

Custom Solid Frames

The Solid block provides a frame creation interface that you can use to create new, custom, frames. You can position and orient a custom frame using geometry features such as vertices, edges, and faces. More conveniently from an inertia standpoint, you can do the same using the center of mass and three principal axes of the solid.

Try It: Create a Custom Solid Frame

Create a custom frame using the frame creation interface of the Solid block. Then, place the frame origin at the center of mass and align the frame axes with the principal axes of inertia. The result is a frame that coincides with the principal reference frame—one in which the inertia matrix is diagonal and the products of inertia are zero.

  1. At the MATLAB command prompt, enter smdoc_lbeam_inertia. A model opens with a solid possessing the shape of an L-beam.

  2. In the Solid block dialog box, click the Create Frame button. The Solid block dialog box switches to a frame creation view.

  3. Change the Frame Name parameter to P (for “Principal Frame”). The visualization pane and the frame port use this label to identify your new frame.

  4. Under Frame Origin, select the radio button labeled At Center of Mass.

  5. Under Frame Axes > Primary Axis and Frame Axes > Secondary Axis, select the radio button labeled Along Principal Inertia Axis. Accept the default axis options (+Z and +X, respectively) and click Save. The block dialog box switches back to the main (parameters) view.

  6. In the visualization toolstrip, click the Toggle visibility of frames button. The visualization pane shows the frames of the solid, including your new custom frame, P.

What Are Frame Transforms?

The rotational and translational offsets between frames are called transforms. If the transforms are constant through time, they are called rigid. Rigid transforms enable you to fix the relative positions and orientations of components in space, e.g., to assemble solids into rigid bodies.

Working with Frame Transforms

You use the Rigid Transform block to specify a rotational, translational, or mixed rigid transform between frames. The transforms are directional. They set the rotation and translation of a frame known as follower relative to a frame known as base.

The frame port labels on the Rigid Transform block identify the base and follower frames. The frame connected to port B serves as base. The frame connected to port F serves as follower. Reversing the port connections reverses the direction in which the frame transform is applied.

You can specify a transform using different methods. For rotational transforms, these include axis-angle pairs, rotation matrices, and rotation sequences. For translational transforms, they include translational offset vectors defined in Cartesian or cylindrical coordinate systems.

If the rotational and translational transforms are both zero, the connected frames are coincident in space. This relationship is known as identity and it is equivalent to a direct frame connection line between frame ports—i.e., one without a Rigid Transform block.

Visualizing Frame Transforms

You can visualize frames and examine the transforms between frames using the Solid block visualization pane or Mechanics Explorer. Use the Solid block visualization pane to examine the frames of a single solid element. Click the Toggle visibility of frames button in the visualization toolstrip to show all the solid frames.

A Frame on a Solid

Use Mechanics Explorer to visualize the frames of more than a single solid element—e.g., in compound bodies, multibody subsystems, or complete multibody models. Select View > Show Frames in the Mechanics Explorer menu to show all frames. Select a node from the tree view pane to show only those frames belonging to the selected component.

Frames on a Body

Try It: Specify a Frame Transform

This example shows how to offset two solids relative to each other by specifying a frame transform between the solid reference frames. The transform consists of a -45 deg rotation about the z axis followed by a 1 m translation along the x-axis and a 1 m translation along the y-axis.

Add the solids to the model

  1. Drag two Solid blocks from the Body Elements library and place them in a new model.

    Each Solid block specifies the default geometry of a cube 1 m in width.

  2. Connect the Solid block R frame ports.

    The frame connection line makes the reference frames—and cubes—coincident in space.

Visualize the solid frames

  1. Drag a Solver Configuration block from the Simscape™ Foundation Utilities library and connect it anywhere on the model.

    This block is required for model update and simulation.

  2. Update the diagram, e.g., by selecting Simulation > Update Diagram.

    Mechanics Explorer opens with a model visualization.

  3. In the tree view pane, alternately click the Solid and Solid1 nodes.

    The visualization pane shows the solid reference frames. The frames are coincident in space.

Apply the rotation transform

  1. Drag a Rigid Transform block from the Frames and Transforms library and connect it between the two Solid blocks.

  2. In the Rigid Transform block dialog box, set:

    • Rotation > Method to Standard Axis.

    • Rotation > Axis to -Z.

    • Rotation > Angle to 45.

  3. Click OK and update the block diagram.

    The model visualization updates to show the rotated—and still overlapping—solids.

  4. In the tree view pane, click the Rigid Transform node.

    The visualization pane shows the rotated frames.

Apply the translation transform

  1. In the Rigid Transform block dialog box, set:

    • Translation > Method to Cartesian.

    • Translation > Offset to [1 1 0].

      The array elements are the translation offsets along the base frame x, y, and z axes.

  2. Click OK and update the block diagram.

    The model visualization updates to show the translated solids.

  3. In the tree view pane, click the Rigid Transform node.

    The visualization pane shows the translated frames.

The Rigid Transform block always applies the rotation transform first. The translation transform is relative to the rotated frame resulting from the rotation transform. To apply the translation transform first, use separate Rigid Transform blocks for each transform and connect them in the desired order between the Solid blocks.

Related Topics

Was this topic helpful?