setActorInitialParent
R2026bDescription
setActorInitialParent(
specifies the parent actor scnro,childActor,parentActor)parentActor of the child actor
childActor in the RoadRunner scenario scnro. Use this function to attach an actor as a
child to another actor, or to detach a child actor from a parent actor.
Examples
Use the setActorInitialParent function to attach a child actor to
a parent actor, such as a trailer to a truck.
This example assumes that you have prior knowledge of working with RoadRunner in MATLAB®. Before proceeding, follow the steps outlined in Set Up MATLAB Environment for RoadRunner Authoring Functions to set up your scenario using MATLAB functions for scenario authoring.
Add Two Actors to Scenario
Add two actors to your scenario by specifying the assets to use for the actors and
the locations in the scenario in which to place them. Use the getAsset function
to extract VehicleAsset objects that represent the
SemiTruck.fbx_rrx and
SemiTruck_Trailer01.fbx_rrx assets from the project
prj. Then, use the addActor function
to add them to the scenario represented by the Scenario object
scnro at the scenario origin.
semitruckAsset = getAsset(prj,"Vehicles/SemiTruck.fbx_rrx","VehicleAsset"); trailerAsset = getAsset(prj,"Vehicles/SemiTruck_Trailer01.fbx_rrx","VehicleAsset"); semiTruck = addActor(scnro,semitruckAsset,[0 0 0]); trailer = addActor(scnro,trailerAsset,[0 0 0]);
Align the semiTruck actor to a road. Use the
findSceneAnchor function to reference an existing anchor in the
scene, and then use anchorToPoint to relocate the actor from the
current location to the location specified by the referenced anchor. For more
information, see findSceneAnchor and
anchorToPoint.
anchorPoint = findSceneAnchor(scnro,"ScenarioStart"); semiPoint = semiTruck.InitialPoint; anchorToPoint(semiPoint,anchorPoint,PosePreservation="reset-pose")
Use setActorInitialParent to Attach Two Actors
To attach the actor trailer as a child to the actor
semiTruck, use the setActorInitialParent
function. This creates an ActorAttachmentPoint object that
represents the connection attributes of the child actor
trailer.
setActorInitialParent(scnro,trailer,semiTruck)
Run the simulation.
simulateScenario(rrApp)
Input Arguments
Scenario that contains the actors, specified as a Scenario object.
Child actor, specified as a Vehicle, Character, or MovableObject object.
The function sets the InitialPoint property of this object based on
the value of parentActor.
Vehicle,Character, orMovableObjectobject — If you specifyparentActoras one of these objects, the function populates theInitialPointproperty ofchildActorwith anActorAttachmentPointobject. RoadRunner Scenario relocateschildActorto a position relative to the specified parent actorparentActorbased on the properties of thisActorAttachmentPointobject.[]— If you specifyparentActoras an empty array, the function populates theInitialPointproperty ofchildActorwith aPointobject, detaching it from any parent actor with which it had been associated.
Parent actor, specified as Vehicle, Character, or MovableObject object,
or as []. The function sets the InitialPoint
property of childActor based on the value of this argument.
Vehicle,Character, orMovableObjectobject — If you specifyparentActoras one of these objects, the function populates theInitialPointproperty ofchildActorwith anActorAttachmentPointobject. RoadRunner Scenario relocateschildActorto a position relative to the specified parent actorparentActorbased on the properties of thisActorAttachmentPointobject.[]— If you specifyparentActoras an empty array, the function populates theInitialPointproperty ofchildActorwith aPointobject, detaching it from any parent actor with which it had been associated.
Version History
Introduced in R2026b
See Also
ActorAttachmentPoint | Point | Route | addActor | anchorToPoint
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)