Visualize a Simple Machine

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 Simscape™ Multibody™ visualization window. Use your saved spen.mdl model, or use the mech_spen example model.

Simscape Multibody 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.

Start 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 Simscape Multibody 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.

Select a Body Geometry

The information that you use to specify body properties in a Simscape Multibody model is enough to display each body in a standard abstract shape. Without an external body geometry definition, Simscape Multibody 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 = 5/3(L/2) = 0.646 m and ay = az = 5(r/2) = 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.

Display the Pendulum

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

Display 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 Simscape Multibody 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.

Display 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

Model and Visualize 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.

Was this topic helpful?