Main Content

Import an Onshape Humanoid Model

You can import a CAD assembly model from Onshape® software into the Simscape™ Multibody™ environment. The import process occurs in two steps based on the smexportonshape and smimport functions. The smexportonshape exports the assembly model in an intermediate XML conforming to the Simscape Multibody XML schema. The smimport function converts the intermediate XML file into a Simscape Multibody version of the original Onshape model.

Example Overview

This example shows how to import an Onshape model of a humanoid robot assembly. The model comprises various parts representing the torso, head, and limbs of the robot. The parts connect through Revolute mates that represent the various joints. The model is identical to that shown in Import a URDF Humanoid Model. Enter the following URL in your web browser to access the model (Onshape login required):

https://cad.onshape.com/documents/5817806f96eae5105bfa5085/w/15ab3bfb58cacbf427d77ff3/e/181493813f84966648a8db1b

Model Schematic

Export the Model

Use the smexportonshape function to export the model:

  1. At the MATLAB® command prompt, navigate to a folder for which you have write privileges—for example:

    cd C:\Users\JDoe\Documents\Models

  2. Store the model URL in a MATLAB variable named assemblyURL:

    assemblyURL = "https://cad.onshape.com/documents/5817806f96eae5105bfa5085/w/15ab3bfb58cacbf427d77ff3/e/181493813f84966648a8db1b";
    

  3. Export the model and save the XML file name in a variable named exportedModel:

    exportedModel = smexportonshape(assemblyURL);

    You may be prompted to log in to your Onshape account. The smexportonshape function generates the XML multibody description file for this model and a set of STEP files for the various part geometries.

Import the Model

Use the smimport function to import the XML multibody description file:

smimport(exportedModel);

The function generates a Simscape Multibody model of the humanoid robot.

Build on the model, for example, by adding control systems to actuate the various joints. For a controlled example, at the MATLAB command prompt enter OpenExample('sm/ImportedURDFExample'). Simulate the model to view a simple animation.

See Also

|

Related Topics