| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimMechanics Link |
| Contents | Index |
| Learn more about SimMechanics Link |
| On this page… |
|---|
Locating the Robot Arm Assembly Files Viewing the Robot Arm Assembly Exporting the Robot Arm Assembly |
The following example is based on a more complex CAD assembly, a robot arm. It includes multiple parts, two closed loops, multiple constraints, and a subassembly.
Locate the 11 CAD files for the robot arm in the SimMechanics Link demos folder. They are
| File Name | CAD File Type |
|---|---|
| robot.ASSEMBLYFILETYPE | Assembly |
| grip.ASSEMBLYFILETYPE | Subassembly (flexible) |
| base.PARTFILETYPE forearm.PARTFILETYPE upperarm.PARTFILETYPE wrist.PARTFILETYPE | Parts (main assembly) |
| fingertips.PARTFILETYPE (twice) firstfingerlink.PARTFILETYPE firstfingerlinkL.PARTFILETYPE metacarpal.PARTFILETYPE secondfingerlink.PARTFILETYPE (twice) | Parts (subassembly) |
Open the assembly file for the whole robot.
Robot Arm Assembly in a CAD Platform

In the assembly tree to the left of the window, examine the CAD hierarchy:
Five of the part files are grouped into the subassembly grip. The subassembly uses two instances each of fingertips and secondfingerlink.
The subassembly has its own group of 18 constraints, MateGroup1.
Two constraints, Angle1 and Angle2, are not active. If they were, they would lock the grip fingers into the open position. Here, each grip finger can move separately.
The other four part files are separate and grouped into the main assembly.
The main assembly has its own MateGroup1, consisting of seven constraints.
The whole assembly has eight DoFs. The grip subassembly alone contains two, allowing each finger to open and close separately. The main assembly has six DoFs:
The upper arm can move relative to the base by pitching, yawing, and rolling (three DoFs).
The forearm can yaw relative to the upper arm (one DoF).
The wrist can pitch relative to the forearm (one DoF).
The grip can rotate about its symmetry axis (one DoF).
Apply any changes you want to the assembly configuration or settings. If you change the assembly or any subassemblies, you need to rebuild the assembly before exporting it to XML.
Using the SimMechanics Link interface to your CAD platform, export the assembly into Physical Modeling XML. The XML file robot.xml appears in your working CAD folder.
Generate a SimMechanics model for the robot arm based on the file robot.xml. You can use this preconfigured demo 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.
The preconfigured robot.xml file is in the SimMechanics demos folder.
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.
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.
Note For more about counting mechanical degrees of freedom, see the SimMechanics User's Guide. |
To modify and extend the robot arm model, you need blocks from the SimMechanics and Simulink block libraries. Open these libraries by entering mechlib and simulink, respectively, at the command line.
You can also open the Simulink library from the MATLAB window menu or toolbar.
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.
The non-Weld Joint blocks, those that carry DoFs, are Revolute and SphericalSpherical Joints configured with the proper primitives to represent the original CAD assembly's DoFs.
The first non-Weld Joint you encounter as you move away from the Ground block is a Spherical, representing three DoFs.
Each Revolute block contains a single revolute primitive, representing one rotational DoF.
Save this intermediate model as robot2.
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 2.
From the SimMechanics Sensors & Actuators library, insert and attach a Joint Actuator and a Joint Sensor to these new ports.
Configure the Joint Actuator to accept motion signals. Be sure the angular units are deg (degrees).
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.
Consult the Simulink documentation for more about these Simulink blocks.

In the Sine Wave block, set the Amplitude to 60*pi*pi and the Frequency to 60. Leave all other defaults.
In the lower Integrator block, set Initial condition to -60*pi. 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:
On the Parameters tab, reset the Linear assembly tolerance to 1e-2 m (meters) and the Angular assembly tolerance to 1e-1 rad (radians).
On the Constraints tab, select the Use robust singularity handling check box. Leave all other defaults. Click OK.
Run robot3 and examine its motion.
To use the motion sensor:
To visualize the body motions:
From the Simulation menu, select Configuration Parameters, then the SimMechanics node.
Select Display machines after updating diagram and Show animation during simulation. Click OK.
Select Update Diagram from the Edit menu. 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.
![]() | Updating and Retranslating a CAD Pendulum | Translating a CAD Stewart Platform | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |