load
Description
Examples
This example shows how to build an actor from an imported 3D file using MATLAB®. If you have a custom actor defined in a supported 3D file, you can import the file. You can import 3D file formats including FBX, STL, and URDF.
To build an actor from an imported 3D file using Simulink®, see Build Actor from Imported 3D File Using Simulink.
You can use the sim3d.World
object and functions to create and view a 3D environment. You can use the sim3d.Actor
object and functions to create an actor in the 3D environment and build an appearance for the actor from an imported 3D file. Use the load
function of the sim3d.Actor
object to import the file.
Create 3D Environment
Create a world object.
world = sim3d.World();
Build Actor from File
Use the load
function to import a 3D file. This example uses an STL file.
rotor = sim3d.Actor(ActorName='Rotor'); load(rotor,'rotor.stl', 0.01*[1 1 1]); rotor.Rotation = [0 pi/2 0]; add(world,rotor);
Set Viewer Window Point of View
If you do not create a viewport, then the default view is set and you can use the keyboard shortcuts and mouse controls to navigate in the Simulation 3D Viewer window.
For this example, use the createViewport
function to create a viewport.
viewport = createViewport(world,Translation=[-0.5 0 0]);
Run Animation
Run the animation set for 5
seconds with a sample time of 0.01
seconds.
sampletime = 0.01; stoptime = 5; run(world,sampletime,stoptime)
Delete World
Delete the world object.
delete(world)
Import a scene built in RoadRunner into the Unreal Engine® simulation environment. To export a RoadRunner scene, use the option CARLA Filmbox. For more information, see Export Using CARLA Filmbox (RoadRunner). For more information on the exported RoadRunner scene files, see the Project parameter of the Simulation 3D Scene Configuration block.
Create a world object using sim3d.World
.
world = sim3d.World();
Create an empty actor using the sim3d.Actor
object. Load the Filmbox (.fbx
) file to import the RoadRunner scene. To add a vehicle and simulate in this scene, set the sim3d.Actor
object properties, Shadows
and PreciseContacts
to 1
.
scene = sim3d.Actor(ActorName='RoadRunnerScene'); add(world,scene); filepath = fullfile(pwd,'Data','sim3dRoad.fbx'); load(scene,filepath);
Set the Simulation 3D Viewer window point of view and run the simulation.
viewport = createViewport(world); viewport.Translation = [-2, 0, 1]; sampletime = 0.01; stoptime = 5; run(world,sampletime,stoptime);
Input Arguments
Actor object, specified as a sim3d.Actor
object.
Example: actor = sim3d.Actor()
Name of location from where actor is loaded, specified as a character array. The
source can be a file path or file name. load
supports these as sources.
File Formats
MAT (MAT file from MATLAB®)
STL (Stereolithography)
FBX (Autodesk® Filmbox format)
URDF (Unified Robot Description File)
X3D (Extensible 3D)
WRL (Virtual Reality Modeling Language)
DAE (Collada digital asset exchange)
USD, USDA, USDC (Universal Scene Description)
The actors imported from USD files are not compatible with collision detection. To export and simulate RoadRunner scene in USD format, see Simulate in RoadRunner Scene.
MATLAB Objects
RigidBodyTree
surf (only 3D shapes based on polygons)
patch (only 3D shapes based on polygons)
Note
USD file import is not supported on Linux®. USD files do not support collision detection.
Overall scale applied to the entire loaded model, specified as a real positive scalar. Scale parameters of individual objects are not affected by using this parameter.
More About
To export a RoadRunner scene in .fbx
format, use the option CARLA
Filmbox in Export Using CARLA Filmbox (RoadRunner). This option exports
these three files to a folder:
Filmbox (
.fbx
) fileASAM OpenDrive (
.xodr
) fileXML (
.rrdata.xml
) file
To export a RoadRunner scene in USD format, see Export to USD (RoadRunner). When you export the scene, select these options in the Export USD dialog box:
Split by Segmentation
Power Of Two Texture Dimensions
Export Only Highest LODs
Selecting these options enables compatibility with semantic segmentation, optimizes system performance, and provides high-quality rendering of objects in the 3D environment with mesh improvement and high level of details. The RoadRunner scene in the USD file also requires these metadata files:
XML (
.rrdata.xml
) file for semantic segmentation in Simulation 3D Camera and Simulation 3D Lidar blocksASAM OpenDRIVE® (
.xodr
) file for the Simulation 3D Vision Detection Generator block to generate detections using object data and lane ground truth data
To export the metadata files, use the option CARLA Filmbox in Export Using CARLA Filmbox (RoadRunner).
Tip
Semantic segmentation in Simulation 3D Camera and Simulation 3D Lidar uses the XML (.rrdata.xml
) file. The ASAM OpenDRIVE (.xodr
) file provides object data and lane ground truth data for the Simulation 3D Vision Detection Generator to generate detections. When you specify the Filmbox (.fbx
) or Universal Scene Description (USD) file as the Project parameter, check that the XML (.rrdata.xml
) and ASAM OpenDRIVE (.xodr
) files are in the same folder.
Tips
You can load STL files even with sim3d.Actor
objects
that are not currently added to the World.
Version History
Introduced in R2022bYou can import .usd
, .usdc
, or
.usda
file formats using the load
function.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)