This example shows you how to import the model of a robot arm
CAD assembly. The import procedure makes use of the
You use the command to specify the Physical Modeling XML file that
SimMechanics Link generated during CAD Export. For a step-by-step
description of the CAD Export procedure, see Export CAD Robot Arm.
Generate a SimMechanics™ model for the robot arm based on
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
robot.xml file is in the SimMechanics demos
The status bar opens and indicates the progress of model generation. A model window, named robot, opens and is populated with blocks.
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 SimMechanics 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.
To modify and extend the robot arm model, you need blocks from
the SimMechanics and Simulink® block libraries. Open these
libraries by entering
respectively, at the command line.
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 SimMechanics_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.
You can motion-actuate the wrist relative to the forearm.
Double-click the Revolute that connects
the forearm-1 and wrist-1 Body blocks. Change the Number
of sensor/actuator ports to
Click OK. Two new ports appear on the Joint.
Add the following blocks to the model and connect them to the two new ports.
Configure the Joint Actuator to accept
motion signals. Be sure the angular units are
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.
In the Sine Wave block, set the Amplitude to
the Frequency to
Leave all other defaults.
In the lower Integrator block, set Initial condition to
Leave all other defaults.
The original robot arm CAD assembly requires looser tolerances than the SimMechanics defaults, and its motion can lead to singularities. To avoid simulation errors or slowdown, you need to reconfigure the assembly tolerances and constraint solver:
Open the Machine Environment block.
On the Parameters tab,
reset the Linear assembly tolerance to
m (meters) and the Angular assembly
1e-1 rad (radians).
On the Constraints tab, select the Use robust singularity handling check box. Leave all other defaults. Click OK.
Resave your finished model as robot3.
robot3 and examine its motion.
To use the motion sensor:
Double-click the Pitch Angle block to open a scope.
Click the Start simulation button. The scope plot displays a trace of the pitch angle motion.
To visualize the body motions:
In the Simulink Editor window that contains your model, select Simulation > Model Configuration Parameters.
In the SimMechanics 1G node, select Display machines after updating diagram and Show animation during simulation.
In the Simulink Editor window that contains your model, select Simulation > Update Diagram. The SimMechanics visualization window opens.
In the SimMechanics menu of the visualization window, select Machine Display, then Ellipsoids. The display now shows the robot arm's component bodies as ellipsoids.
Click the Start button. The simulation begins. Observe the robot arm motion in the SimMechanics window.