Documentation

Import Visual Representations of Robot Models

You can import into a virtual world in金宝app®3D Animation™robot and robot environment 3-D models that are defined using unified robot description format (.urdf) or simulation description format (.sdf). The URDF file format is an XML file format that defines various model (typically robot) properties. When you import from a URDF file, only the visual representation of the model is imported. This representation typically refers to model component shape files, defined as STL or DAE files. You can import visual properties of the objects present in the URDF or SDF files into corresponding hierarchical structure ofTransformnodes containingIndexedFaceSetobjects with textures.

URDF and SDF files use Collada DAE and STL formats to define visual properties of scene objects.

To import visual representation of robots, in the 3D World Editor, selectNodes>Import From. Then selectSTL File,Physical Modeling XML File,URDF File,SDF File, orCOLLADA File. From the MATLAB®command line, you can use thevrimportfunction to import.urdf,.dae,.stl, and.sdffiles into a virtual world.

Import a DAE File

的黑绿豆F and SDF import supports a subset of the Collada DAE 3D file format (objects that are typically present in URDF and SDF files: geometric shape objects with textures).

This example imports a Collada DAE file,fox.dae, into a scene with predefined grid, gray background, and viewpoint. The fox head is a sphere with 1-m radius, placed at the origin and looking in the direction of VRML +z-axis.

Thefox.daeis shipped with theSimulink 3D Animationsoftware. The path ismatlabroot/toolbox/sl3d/sl3ddemos/fox.dae.

  1. From the MATLAB Toolstrip, in theAppstab, in theSimulation Graphics and Reportingsection, click3D World Editor.

  2. In the 3D World Editor, selectFile>New from Template.

  3. In the file dialog box, select theGridsfolder and then select theXZGrid.wrlvirtual world file.

  4. Save the virtual world in the current folder. SelectFile>Save asand name the virtual world filefox_dae.wrl.

  5. Import the DAE model. SelectNodes>Import From>COLLADA File. Select thefox.dae文件。

  6. Open theCOLLADA_fox_Transformnode and set thescalefield to 3 for each dimension.

Import a URDF File

In this example, thefox.urdffile refers tofox.dae文件。的黑绿豆F file transforms the original DAE model so that the fox is translated to the position [4 1 0] and rotated so that it points to the VRML +x-axis direction.

Thefox.urdfis shipped with theSimulink 3D Animationsoftware. The path ismatlabroot/toolbox/sl3d/sl3ddemos/fox.urdf.

  1. From the MATLAB Toolstrip, in theAppstab, in theSimulation Graphics and Reportingsection, click3D World Editor.

  2. In the 3D World Editor, selectFile>New from Template.

  3. In the file dialog box, select theGridsfolder and then select theXZGrid.wrlvirtual world file.

  4. Save the virtual world in the current folder. SelectFile>Save asand name the virtual world filefox_urdf.wrl.

  5. Import the URDF model. SelectNodes>Import From>URDF File. Select thefox.urdf文件。

  6. Open theURDF_visual_Transformnode and set thescalefield to 3 for each dimension.

导入一个自卫队文件

SDF is an XML format that describes objects and environments for robot simulators, visualization, and control, originally developed as part of the Gazebo robot simulator. The folder in which themodel.sdffile is located defines the SDF model name. This example shows how to import a simple arm link mechanism.

The example assumes that you have

  1. Download thesimple_armmodel folder (including all its contents) from this Gazebo model site:http://models.gazebosim.org/simple_arm/. To download all the folder contents, download and unpack themodel.tar.gz文件。

  2. From the MATLAB Toolstrip, in theAppstab, in theSimulation Graphics and Reportingsection, click3D World Editor.

  3. In the 3D World Editor, selectFile>New from Template.

  4. In the file dialog box, select theGridsfolder and then select theXZGrid.wrlvirtual world file.

  5. Save the virtual world in the current folder. SelectFile>Save asand name the virtual world filesimple_arm.wrl.

  6. Import the SDF model. SelectNodes>Import From>SDF File. In thesimple_armfolder, select themodel.sdf文件。

  7. Open theSDF_simple_arm_Transformnode and set thescalefield to 3 for each dimension.

  8. The import process creates in the model hierarchy some specialTransformnodes that make it easier to manipulate models. Each rotational joint in the SDF model is represented with aTransformnode with the name starting withaxis_. These nodes have rotation axes defined so that the model elements move consistently if you set the rotation angle to a different value.

    Change the rotation angle of a rotational joint node. For example, expand thechildrennode, then thejoint_arm_shoulder_pan_jointnode, then thechildren, and finally, theaxis_arm_shoulder_pan_joint. For therotationfield, set the fourth element to 1.

    Tip

    If you associate this virtual world with aVR Sinkblock in a Simulink model, you can use theVR Signal Expanderblock to set only the rotation angle (the fourth element of the rotation vector) of theaxis_xxxTransformnode rotation. Leave the first three elements of the vector unchanged. This approach preserves robot consistency with the way model authors defined movement of robot parts.

Define Viewpoint to Make Imported Model Visible

When you import a model, often it does not appear in the initial view of the virtual world. If necessary, create a viewpoint to make the imported model visible when the virtual world opens. If the imported model is not visible:

  1. In the 3D World Editor, select theROOTnode.

  2. SelectNodes>Add>Bindable>Viewpoint.

  3. To observe the imported model, navigate to a suitable location in the scene.

  4. Populate viewpoint properties with current camera settings. In the tree hierarchy pane, right-click the viewpoint and selectCopy values from current camera.

  5. Save the virtual world.

Limitations

URDF import transforms robot hierarchy of links and joints into a VRML or X3D hierarchy of transforms. It imports only visualization properties from each link. Joints are represented by transforms that preserve rotation axes of the original revolute joints and axis alignment of prismatic joints.

SDF import transforms the hierarchy of SDF model objects into VRML or X3D hierarchy of transforms the same way as URDF import. It supports a subset of SDF format objects and is limited to visual objects under theModelelement hierarchy. SupportedGeometryelements are geometric primitives and meshes.

See Also

Functions

Related Topics