getAsset
Description
extracts an object of the specified asset type for the asset at the specified path relative
to the asset
= getAsset(project
,assetPath
,assetType
)Asset
folder of the specified project. For example,
mySedan = getAsset(prj,"Vehicles/Sedan.fbx","VehicleAsset")
extracts
the VehicleAsset
(RoadRunner Scenario)
object mySedan
for the asset with the relative path
"Vehicles/Sedan.fbx"
from the project prj
. You can
use asset objects to add lane marking textures to roads, represent actors in the scenario,
and modify actor behavior during simulation.
Examples
Use the getAsset
function to extract a VehicleAsset
(RoadRunner Scenario) object that represents the Sedan.fbx
asset
in your RoadRunner project. Then, use the addActor
(RoadRunner Scenario)
function to add an actor to the scenario that uses the newly created asset
object.
Create a roadrunner
object, specifying the
path to an existing project. For example, this code shows the path to a project, on a
Windows® machine, located at "C:\RR\MyProject"
. This code assumes that
RoadRunner is installed in the default location, and returns an object,
rrApp
, that provides functions for performing basic tasks such as
opening, closing, and saving scenes and projects.
rrApp = roadrunner(ProjectFolder="C:\RR\MyProject");
Note
If you are opening RoadRunner from MATLAB® for the first time, or if you have changed the RoadRunner installation location since you last opened it from MATLAB, you can use the roadrunnerSetup
function to specify new default
project and installation folders to use when opening RoadRunner. You can save these folders between MATLAB sessions by selecting the Across MATLAB
sessions
option from the corresponding drop down.
Open an existing scene in RoadRunner by using the openScene
function, specifying the
roadrunner
object rrApp
and the filename of the
specific scene that you want to open. Then, use the newScenario
function to
create a new
scenario.
openScene(rrApp,"ScenarioBasic.rrscene")
newScenario(rrApp)
Create an object for the RoadRunner authoring API, rrApi
, that references the object for the
current RoadRunner instance rrApp
. The rrApi
object enables you
to programmatically author scenes and scenarios, such as by adding and modifying roads, actors,
and logic components, using MATLAB.
rrApi = roadrunnerAPI(rrApp);
Scene
and
Scenario
properties of the authoring API object rrApi
,
respectively. The extracted Scene
object enables you to specify the scene in
which to add scene components such as roads and lanes. The extracted Scenario
(RoadRunner Scenario) object
enables you to specify the scenario in which to add scenario components such as actors and
logic.scn = rrApi.Scene; scnro = rrApi.Scenario;
Project
property of the authoring API object
rrApi
. The extracted Project
object enables you to
specify the project folder for the current RoadRunner session from which to retrieve asset objects. You can use the asset objects to
assign assets to roads in your scene, or to actors in your
scenario.prj = rrApi.Project;
Use the getAsset
function to extract a
VehicleAsset
object, mySedan
, that represents
the Sedan.fbx
asset in the project prj
. Then,
use the addActor
(RoadRunner Scenario) function to add a Vehicle
(RoadRunner Scenario)
actor, car
, represented by the mySedan
asset, to
the scenario scnro
at the world
origin.
mySedan = getAsset(prj,"Vehicles/Sedan.fbx","VehicleAsset"); car = addActor(scnro,mySedan,[0 0 0]);
Input Arguments
Project folder for the current RoadRunner session, specified as a Project
object.
Example: prj = rrApi.Project
, where rrApi
is
the RoadRunner authoring API object, returns the Project
object
prj
for the current RoadRunner session.
Relative asset path, specified as a string scalar or character vector. The specified
path must be relative to the Assets
subfolder within
project
. The getAsset
function does not
support absolute paths.
Note
By default, RoadRunner searches the Assets
folder in your RoadRunner project when you specify a relative path to an asset. If you want to add
an asset that is located outside the Assets
folder in your
RoadRunner project, use the <PROJECT>
prefix to specify your
current project folder before specifying the new path. For example,
getAsset(prj,"<PROJECT>/CustomFiles/CustomVehicles/CustomSedan.fbx","VehicleAsset")
.
Type of the extracted asset, specified as one of these options:
"VehicleAsset"
— Specifies the asset type of the extracted asset as Vehicle."CharacterAsset"
— Specifies the asset type of the extracted asset as Character."MovableObjectAsset"
— Specifies the asset type of the extracted asset as Movable Object."BehaviorAsset"
— Specifies the asset type of the extracted asset as Behavior. RoadRunner stores behavior asset data in.rrbehavior
files."LaneMarkingStyle"
— Specifies the asset type of the extracted asset as Lane Marking.
Output Arguments
Asset object, returned as one of these objects:
VehicleAsset
(RoadRunner Scenario) — Represents an asset with the Vehicle asset type.CharacterAsset
(RoadRunner Scenario) — Represents an asset with the Character asset type.MovableObjectAsset
(RoadRunner Scenario) — Represents an asset with the Movable Object asset type.BehaviorAsset
(RoadRunner Scenario) — Represents an asset with the Behavior asset type. RoadRunner stores behavior asset data in.rrbehavior
files.LaneMarkingStyle
— Represents an asset with the Lane Marking asset type.
Version History
Introduced in R2025a
See Also
Scenario
(RoadRunner Scenario) | Project
| createAsset
| addActor
(RoadRunner Scenario) | Vehicle
(RoadRunner Scenario)
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)