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 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 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.
The preconfigured robot.xml file is in the SimMechanics demos folder.
The status bar opens and indicates the progress of model generation. A model window, named robot, opens and is populated with blocks.
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 mechlibmechlib and simulinksimulink, 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.
|Joint Actuator||Sensors and Actuators||1|
|Joint Sensor||Sensors and Actuators||1|
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.
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:
Run robot3 and examine its motion.
To use the motion sensor:
To visualize the body motions: