Prescribe Joint Motion in Planar Manipulator Model

Model Overview

In this tutorial, you prescribe the time-varying trajectory coordinates of a planar manipulator end frame with respect to the world frame using a 6-DOF Joint block. This block provides the requisite degrees of freedom between the two frames, but it does not represent a real physical connection between them. The joint it represents is said to be virtual.

The time-varying coordinates trace a square pattern, achieved by automatically computing and applying actuation torques at the various manipulator joints. During simulation, you can output the automatically computed torques and plot them using Simulink® blocks or MATLAB® commands, e.g. for analysis purposes.

Add Virtual Joint

  1. At the MATLAB command prompt, enter smdoc_double_pendulum. A double pendulum model, which in this tutorial you adapt as a simple planar manipulator model, opens. For instructions on how to create this model, see Model an Open-Loop Kinematic Chain

  2. From the Simscape > Multibody > Joints library, drag a 6-DOF Joint block and connect it as shown in the figure. This block represents a virtual joint, which you use to specify the manipulator end frame with respect to the world frame.

    Note

    Check that the base port frame (B) connects to the world frame. The base port frame functions as the reference frame for any joint motion input that you provide. Switching the base and follower port frames causes the block to interpret any motion input with respect to a different frame, possibly altering the manipulator end frame trajectory.

Prescribe Motion Inputs

  1. In the 6-DOF Joint block dialog box, specify these parameters settings.

    ParameterSelect
    Y Prismatic Primitive (Py) > Actuation > MotionProvided by Input
    Z Prismatic Primitive (Pz) > Actuation > MotionProvided by Input

    The block exposes two physical signal ports through which you can provide the joint motion inputs.

  2. Drag these blocks into the model.

    LibraryBlockQuantity
    Simscape > UtilitiesSimulink-PS Converter2
    Simulink > SourcesSignal Builder2

    The Signal Builder blocks provide the motion inputs as Simulink signals. The Simulink-PS Converter blocks convert the Simulink signals into Simscape™ physical signals compatible with Simscape Multibody™ blocks.

  3. Connect the blocks as shown in the figure.

  4. Open the dialog box of the Signal Builder block connected to port py of the 6-DOF Joint block. Specify this signal, the time-varying Y coordinate of the square trajectory the manipulator end frame is to follow.

  5. Open the dialog box of the Signal Builder block connected to port pz of the 6–DOF Joint block. Specify this signal, the time-varying Z coordinate of the square trajectory the manipulator end frame is to follow.

  6. In the dialog boxes of the Simulink-PS Converter blocks, specify the input signal units and filtering settings. Simscape Multibody requires that you either specify second-order filtering or provide the first two time derivatives of the trajectory coordinates.

    ParameterValue
    Units > Input signal unitcm
    Input Handling > Filtering and derivativesFilter input
    Input Handling > Input filtering orderSecond-order filtering
    Input Handling > Input filtering time constant (in seconds)0.1

    Small filtering constants can slow simulation significantly. For most Simscape Multibody models, a value of 0.1 seconds is a good choice. In this tutorial, this value suffices.

Sense Joint Actuation Torques

  1. In the dialog boxes of the two Revolute Joint blocks, set the following actuation and sensing parameters.

    ParameterSetting
    Actuation > TorqueAutomatically Computed
    Sensing > Actuation TorqueSelected

    Simscape Multibody requires the number of joint primitive degrees of freedom with motion inputs to equal the number with automatically computed joint actuation forces and torques. If the model does not meet this condition, simulation fails with an error.

  2. Drag these blocks into the model.

    LibraryBlockQuantity
    Simscape > UtilitiesPS-Simulink Converter2
    Simulink > SinksTo Workspace2

    The PS-Simulink Converter blocks convert the physical signal outputs into Simulink signals compatible with other Simulink blocks.

  3. In the two To Workspace block dialog boxes, enter the variable names t1 and t2.

  4. Connect the blocks as shown in the figure.

Simulate Model

Attempt to run the simulation. Simulation fails with an error arising from the closed kinematic loop present in the model. Simscape Multibody requires this loop to contain at least one joint block without motion inputs or automatically computed actuation forces or torques.

  1. From the Simscape > Multibody > Joints library, drag a Weld Joint block and connect it inside one of the Binary Link A subsystems.

    Adding the Weld Joint block ensures that the now-closed-loop system contains at least one joint block without motion inputs or computed actuation torques.

Run the simulation once again. Mechanics Explorer opens with a dynamic 3-D display of the two-bar linkage.

Plot the computed actuation torques acting at the two revolute joints in the linkage. At the MATLAB command line, enter this code:

figure; 
hold on;
plot(t1.time, t1.data, 'color', [60 100 175]/255); 
plot(t2.time, t2.data, 'color', [210 120 0]/255); 
xlabel('Time'); 
ylabel('Torque (N*m)'); 
grid on;
The plot shows the time-varying actuation torques acting at the two revolute joints. These torques enable the manipulator end frame to trace the prescribed square trajectory.

Related Examples

More About