Import a CAD, URDF, or Robotics System Toolbox model
[
creates a Simscape Multibody model from a CAD, URDF, or Robotics System Toolbox
model.H
,dataFileName
]
= smimport(modelSource
)
modelSource
is the name of the file or object containing the
model or, for CAD import, an intermediate representation of it. CAD models must be
in XML files, URDF models in URDF files, and Robotics System Toolbox models in
RigidBodyTree
objects. XML files must conform to the Simscape Multibody XML schema and URDF files must conform to the URDF specification. A Robotics
System Toolbox license is required to create RigidBodyTree
objects.
H
is the model handle and dataFileName
is the name of the supporting file that, in imported CAD models, stores the numeric
values of block parameters—in a structure array populated with MATLAB variables
referenced in the blocks. The data file provides a mechanism to update the imported
model if the CAD model changes. Models imported from URDF files or
RigidBodyTree
objects do not rely on data files for block
parameters.
XML files can come from different sources. The smexportonshape
function converts Onshape CAD models into XML files
for import. The Simscape Multibody Link plug-in does the same for Autodesk Inventor®, PTC®, and SolidWorks® CAD models. The plug-in is free to download. For other CAD
applications, and for multibody modeling tools of other types, the Simscape
Multibody XML schema makes it possible to create a custom model export app.
CAD, URDF, and RigidBodyTree
models all share the same components.
These are (i) rigid bodies, also known as parts in CAD models and links in URDF
models, and (ii) kinematic constraints, packaged, in some cases, as joints. Rigid
bodies import as Simulink subsystems with solid and Rigid
Transform blocks—the elemental components from which the
attributes of shape, inertia, color, and placement derive. Constraints map into
joint, gear, and other constraint blocks.
URDF models contain <link>
elements which in turn contain
<joint>
elements. Likewise, RigidBodyTree
objects contain RigidBody
objects which in turn contain
Joint
objects. This hierarchy changes with import into Simscape
Multibody. Joints become siblings to rigid bodies and feature not inside rigid body
subsystems but alongside them. Joint limits and home positions persist, the later as
position state targets, in the appropriate joint blocks.
Note
Joint limits are imported from URDF and RigidBodyTree
models but not from CAD models. Reproduce the joint limits of CAD models
manually if you must—by enabling joint limits in the joint blocks and
setting the limit positions to appropriate values.
[
creates a Simscape Multibody model from a CAD, URDF, or Robotics System Toolbox
model with custom name or regenerates the data file of a previously imported CAD
model. Most name-value pair arguments apply only to CAD models. Use
H
,dataFileName
]
= smimport(modelSource
,Name,Value
)ImportMode
to regenerate parameter data files and
PriorDataFile
to catch inadvertent changes to the model,
such as the removal of a part or a change in its name.
smexportonshape
| importrobot
(Robotics System Toolbox)