SimMechanics    

Modifying the Model

Here are two modifications of the demo you can try. One illustrates the simple user-driven controller you can adjust to change the motion of the pusher. The other illustrates a powerful feature of SimMechanics, visualization of a machine and animation of its simulated motion.

To make these modifications, it is best to close and restart the demo.

Changing the Pusher Reference Position

The Reference Position block is actually a Simulink Slider Gain block (from the Simulink Math Library) and controls where the pusher comes to rest.

You can adjust the Reference Position block to change where the pusher stops:

  1. Open the Reference Position block. You see an adjustable slider to set the position of the pusher's rest point.
  2. Enter values in the Low and High fields to set the lower and upper limits of the allowed slider range. The defaults in this demo are 0 and 0.2, with implied units of meters (m).
  3. Enter a value in the central field to set the pusher stopping point, which you can also adjust by clicking and dragging the slider between the lower and upper limits. The default is 0 (meters).

You can apply changes to the reference position to the simulation in two ways:

Visualizing and Animating the Conveyor

You can visualize the conveyor mechanism as a static machine and animate the simulation as well with the two visualization tools:

With either visualization tool, you can display the bodies of the machine in two possible abstract representations:

Handle Graphics Visualization.   First try visualizing the conveyor with Handle Graphics:

  1. From the Simulation menu, click Mechanical environment. The Mechanical Environment Settings dialog box appears.
  2. Click the Visualization tab. Select the Draw machine in initial state and Animate machine during simulation check boxes.
  3. Leave the other defaults as they are and close the dialog.

    Visualization Control
    Default Value
    Draw machine using
    MATLAB Graphics
    Represent bodies as
    Convex hulls
    Update machine
    When diagram changes
  1. A MATLAB Handle Graphics window appears, displaying the conveyor machine at rest in its initial state.

    The bodies are rendered in the default representation, as convex hulls. The bodies and Body coordinate system axis triads are also displayed as defaults.

  1. Change Reference Position to a nonzero value such as 0.1 or 0.2.
  2. Restart the simulation. The Handle Graphics window animates the machine in motion. You can compare this motion to the plots in the scope.

  3. Click a body in the Handle Graphics window. The model window comes back into focus with the corresponding Body block highlighted in color.
  4. Open the special SimMechanics menu in the upper right of the Handle Graphics window.
  1. Here, you can reconfigure the special display properties for machines: bodies, Body CS axis triads, colored fill-in patches connecting Body CSs on the same body, and user viewpoint orientation.

  1. Close the Handle Graphics window when you are finished.

Virtual Reality Visualization.   Now visualize the conveyor in virtual reality scene:

  1. From the Simulation menu, click Mechanical environment. The Mechanical Environment Settings dialog box appears.
  2. Click the Visualization tab. Select the Draw machine in initial state and Animate machine during simulation check boxes.
  3. Using the pull-down menus, change Draw machine using to Virtual Reality Toolbox and Represent bodies as to Equivalent ellipsoids.
  1. Leave Update machine as When diagram changes.

    A virtual reality viewer opens, displaying the conveyor machine at rest in its initial state.

    The bodies are rendered as equivalent ellipsoids.

  1. Restart the simulation. The viewer now animates the machine in motion.
  2. Use the virtual reality controls at the bottom of the virtual scene to change the user viewing position and orientation:
  1. See Viewing Machines in Virtual Reality in the Visualizing and Animating Machines chapter for how to control the virtual scene.

  1. While the animation is running, open the Reference Position block and move the slider up and down. In addition to what you can see in the Scope plots, the viewer directly animates the pusher trajectory in space as the mechanism responds to your adjustment.

  Starting the Demo What Can You Do with SimMechanics?