Tutorial 2: Using the Vehicle Wizard to Turn an Asset into a Simulation Vehicle
This tutorial will use the Vehicle Wizard to configure the prims of a graphical vehicle asset such that it can be simulated and driven around (seeing the wheels rotate and turn due to accelerate and steer commands etc.). For this to work, the Vehicle Wizard expects the asset to have a certain prim hierarchy. For this tutorial, the asset is assumed to be organized as follows:
Car
|
|-- ChassisMesh0
|-- ChassisMesh1
|-- ...
|
|-- FrontLeftWheel
| |
| |-- WheelMesh0
| |-- WheelMesh1
| |-- ...
|
|-- FrontRightWheel
| ...
|
|-- RearLeftWheel
| ...
|
|-- RearRightWheel
| ...
Car is the root prim of the asset and expected to be a UsdGeomXform (not a mesh or some other geometry). The Car prim has some child prims that represent the geometry of the chassis as well as some child prims that represent the wheels. Note that these prims do not have to be direct children for the following steps to work. Deeper hierarchies are fine too. For the root prims of the wheels (in this example: FrontLeftWheel etc.), it’s recommended to use UsdGeomXform prims too (not meshes or other geometry to avoid nested geometry prims which is generally advised against). The Authoring the Vehicle’s Rendered Mesh section has some more suggestions for vehicle prim hierarchies. Another important assumption is that FrontLeftWheel etc. is positioned in the center of the wheel (since that is the prim that will get rotated as the wheel spins and turns).
Open the asset file
Open the Vehicle Wizard: Create > Physics > Vehicle (menu)
Select the Car prim in the tree view and press Selected in the Vehicle Wizard window (in Vehicle Prim panel). The Path field should now show the path of the Car prim (also, see Basic Page for a reference on the first Vehicle Wizard page)
Choose the Longitudinal Axis (in Chassis Box panel) to reflect the axis that aligns with the front-to-back direction of the vehicle
Select the ChassisMesh0 prim in the tree view and press Scan in the Vehicle Wizard window (in Chassis Box panel). The assumption here is that ChassisMesh0 represents a good tight fit of the vehicle chassis. This step will estimate the vehicle dimensions, mass and inertia based on the bounding box around the selected prim. The estimated values can be adjusted if desired.
Set the Number of Axles field (in Misc panel) to match the number of axles of your vehicle (each axle assumes 2 wheels)
Press Next (the wizard will transition to the Axles Page)
Select the FrontLeftWheel prim in the tree view and click on button Left in the Vehicle Wizard window (in Axles panel). There are multiple buttons called Left in there. Choose the one under Select Wheel Attachment and at the row marked with “1” (FrontLeftWheel is assumed to be a front wheel and the axles are consecutively numbered from front to back). If everything worked as expected, a row entry for the wheel should appear in the Wheels panel.
Select the WheelMesh0 prim in the tree view and click on button Left in the Vehicle Wizard window (in Axles panel), this time under Scan Selected Prims though (but still on row “1”). The assumption here is that WheelMesh0 represents a good tight fit of the wheel volume. This step will estimate the wheel radius, width and mass based on the bounding box around the selected prim. The estimated values can be adjusted if desired (in Wheels panel).
Repeat the previous two steps for FrontRightWheel, RearLeftWheel, RearRightWheel and the corresponding mesh child prims. For wheels on the right side of the axle make sure to choose the button Right instead of Left, for rear wheels, choose row “2” instead of “1”.
Press Create
In comparison to the previous tutorial, the Vehicle Wizard will operate on the existing prims and configure them for simulation. It will be the user’s responsibility to add collision geometry etc. if desired. To add a simple surface to drive on, select Create > Physics > Ground Plane in the menu. Read the Vehicle Dynamics Introduction section to learn how to run the simulation and control the vehicle.