Products & Services Solutions Academia Support User Community Company

Learn more about SimMechanics   

Visualizing a Simple Mechanical Model

Visualizing and Animating the Simple Pendulum

In this section, you learn how to view the swinging steel rod of the model introduced in the last section using the SimMechanics visualization window. Use your saved spen.mdl model, or use the mech_spen demo model. If you are using online Help, you can click here to open the model.

SimMechanics visualization displays a machine by displaying its bodies. You can display the bodies in two standard ways, by equivalent ellipsoids and by closed surfaces (convex hulls) enveloping the bodies' coordinate systems. This section explains how to visualize your pendulum using either standard body geometry.

You can view the pendulum before you start and, separately, choose to animate it during simulation as well.

Starting Visualization

The first step is to configure the Configuration Parameters dialog.

  1. On the Simulink menu bar, open the Simulation menu and select the Configuration Parameters entry. The Configuration Parameters dialog appears. Select the SimMechanics subnode, under the Simscape node, at the lower left.

  2. To view the pendulum in its static initial state, select the Display machines after updating diagram check box.

    To animate the pendulum visualization while the simulation is running, select the Show animation during simulation check box as well.

  3. Click OK. Select Update Diagram from the Edit menu to open the visualization window.

Selecting a Body Geometry

The information that you use to specify body properties in a SimMechanics model is enough to display each body in a standard abstract shape. Without an external body geometry definition, SimMechanics visualization does not have enough information to display its full shape.

Equivalent Ellipsoids

A rigid body has a unique equivalent ellipsoid, a homogeneous solid ellipsoid with the same inertia tensor.

Because the rod has an axis of symmetry, the x-axis in this case, two of its three generalized radii are equal: ay = az. The generalized radii of the equivalent ellipsoid are ax = = 0.646 m and ay = az = = 1.12 cm.

Convex Hulls

Each Body coordinate system (CS) has an origin point, and the collection of all these points, in general, defines a volume in space. The minimum outward-bending surface enclosing such a volume is the convex hull of the Body CSs.

You created the pendulum body with only two Body CSs, CG and CS1. The convex hull excludes the CG CS and thus, for the pendulum rod, is just the CS1 origin, a point.

Implementing Your Body Geometry Choice

In the Model menu of the visualization window, you can choose how the pendulum or any machine bodies are displayed. In the Body Geometries submenu, choose Convex Hulls or Ellipsoids.

Displaying the Pendulum

You can access the SimMechanics visualization window from any SimMechanics model. To open it or to synchronize it at any time with your model, select Update Diagram in your model window's Edit menu.

Displaying the Pendulum as a Convex Hull

The displayed figure depends on the body geometry you choose. If you chose Convex Hulls in the Model > Body Geometries menu, a convex hull appears.

Pendulum Rod Displayed as a Convex Hull

You can change the viewpoint and manipulate the image with the controls in the toolbar and menus. Experiment with the SimMechanics menu's settings to see various ways of displaying the pendulum.

When you start the model, the body in the graphics window moves in step with the simulation.

Displaying the Pendulum as an Equivalent Ellipsoid

To display the pendulum as an equivalent ellipsoid, follow the previous steps, but change the body geometry choice:

  1. Open the Model menu and select Body Geometries.

  2. In the submenu, select Ellipsoids.

    The display changes. The equivalent ellipsoid looks like this.

    Pendulum Rod Displayed as an Equivalent Ellipsoid

Viewing a Simple Pendulum Animation

If you are connected to the Internet, have an AVI-compatible media streaming application installed on your system, and want to play a recorded animation of this system:

  1. Click the following link. When the download dialog opens, choose Save to file and specify a file name and location on your system.

  2. Click OK to save the AVI file to your system.

  3. Once the downloading is complete, start the AVI animation on your system.

If you do not have an AVI-compatible application, consider using the MATLAB aviread and movie commands instead.

This is a compressed AVI recording, which requires that you have the Indeo 5 video codec installed to decompress and play.

Download animation

Modeling and Visualizing More Complex Machines

The next tutorial shows how to create, run, and visualize a model for a more complex machine, a four bar mechanism. To configure Ground, Body, and Joint blocks now means repeating and expanding upon the three blocks of the first two tutorials.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS