Import a Robot Arm Model


This content is specific to Simscape™ Multibody™ First Generation software. First-generation features are slated to be deprecated and should be avoided.

This example shows you how to import the model of a robot arm CAD assembly. The import procedure makes use of the mech_import command. You use the command to specify the Physical Modeling XML file that Simscape Multibody Link generated during CAD Export.

Generate a Simscape Multibody model for the robot arm based on the file robot.xml. You can use this preconfigured example file or export your own version of the XML file from the robot arm CAD assembly. In either case, copy or move the XML file to your MATLAB® working folder.

Import Simscape Multibody XML File

The preconfigured robot.xml file is in the Simscape Multibody demos folder.

  1. Generate the model by entering mech_import('robot') at the command line.

    The status bar opens and indicates the progress of model generation. A model window, named robot, opens and is populated with blocks.

  2. Save this initial body-joint model as robot, and note these properties:

    • The top level of the model has 13 blocks and the grip-1 subsystem.

    • The grip-1 subsystem has 18 blocks.

      The original robot arm assembly has eight DoFs, with two in the grip subassembly and six at the top level. These translate into eight DoFs in the Simscape Multibody model, where:

      • Six DoFs occur at the top level. These include the upper arm relative to the base, the forearm relative to the upper arm, the wrist relative to the forearm, and the grip relative to the wrist.

      • Two DoFs occur in the grip-1 subsystem. These are the rotational DoFs of the two grip fingers.

        There are eight revolute primitives in the subsystem. They occur in two closed loops as two independent four-bar mechanisms. Each four-bar mechanism actually has only one independent DoF because each four-bar loop closes on itself.

Modify Imported Model

To modify and extend the robot arm model, you need blocks from the Simscape Multibody and Simulink® block libraries. Open these libraries by entering mechlib and simulink, respectively, at the command line.

Remove Redundant Rigid Bodies

Some of the bodies in the generated robot arm model are redundant. You can remove them without affecting the model's dynamics, as long as you properly reconnect the remaining blocks.

  • At the top level, the RootPart block is a zero-mass, zero-inertia Root Body. You can delete it, along with the connected Weld1 block, then reconnect the Root Ground to the base-1 block through the Weld block.

  • In the grip-1 subsystem, you can delete the grip-1 (Root Body) block and the connected Weld block because they are unnecessary. You can also delete the associated Body coordinate system on the metacarpal-1 Body block.

See the reference page for more details about the Body block.

Add Actuator and Sensor Blocks

You can motion-actuate the wrist relative to the forearm.

  1. Double-click the Revolute that connects the forearm-1 and wrist-1 Body blocks. Change the Number of sensor/actuator ports to 2.

  2. Click OK. Two new ports appear on the Joint.

  3. Add the following blocks to the model and connect them to the two new ports.

    Joint ActuatorSensors and Actuators1
    Joint SensorSensors and Actuators1

  4. Configure the Joint Actuator to accept motion signals. Be sure the angular units are deg (degrees).

  5. From the Simulink library, insert a Sine Wave, a Mux, two Integrator blocks, and one Scope block. Connect them to the previous blocks as shown in the following figure. Rename the Scope block to Pitch Angle.

  6. In the Sine Wave block, set the Amplitude to 60*pi*pi and the Frequency to 60. Leave all other defaults.

  7. In the lower Integrator block, set Initial condition to -60*pi. Leave all other defaults.

Configure Tolerances

The original robot arm CAD assembly requires looser tolerances than the Simscape Multibody defaults, and its motion can lead to singularities. To avoid simulation errors or slowdown, you need to reconfigure the assembly tolerances and constraint solver:

  1. Open the Machine Environment block.

  2. On the Parameters tab, reset the Linear assembly tolerance to 1e-2 m (meters) and the Angular assembly tolerance to 1e-1 rad (radians).

  3. On the Constraints tab, select the Use robust singularity handling check box. Leave all other defaults. Click OK.

  4. Resave your finished model as robot3.

Simulate and Visualize Robot Arm Motion

Run robot3 and examine its motion.

To use the motion sensor:

  1. Double-click the Pitch Angle block to open a scope.

  2. Click the Start simulation button. The scope plot displays a trace of the pitch angle motion.

To visualize the body motions:

  1. In the Simulink Editor window that contains your model, select Simulation > Model Configuration Parameters.

  2. In the Simscape Multibody 1G node, select Display machines after updating diagram and Show animation during simulation.

  3. Click OK.

  4. In the Simulink Editor window that contains your model, select Simulation > Update Diagram. The Simscape Multibody visualization window opens.

  5. In the Simscape Multibody menu of the visualization window, select Machine Display, then Ellipsoids. The display now shows the robot arm's component bodies as ellipsoids.

  6. Click the Start button. The simulation begins. Observe the robot arm motion in the Simscape Multibody window.

Was this topic helpful?