EGO Vehicle Dynamics#

SVL Simulator supports multiple dynamics models for EGO vehicles. The default dynamics model is a C# based model that uses Unity's PhysX physics engine and components. The model receives controller input and applies force to the Unity wheel colliders. For users who would like to change or replace vehicle dynamics with their own models, the simulator offers the following ways to do so.

  • Simple Model Interface - pure C# dynamics
  • Full Model Interface - FMI 2.0 supported dynamics
  • Robotics - unique class extending IVehicleDynamics.cs and a unique class extending AgentController.cs
  • Spectator - no dynamics class with a class extending AgentController.cs

Simple Model Interface top#

Simple Model Interface is our C# dynamic model. Most SVL Simulator vehicles that are provided, use the VehicleSMI class. It is located in Assets -> Scripts -> Dynamics -> Examples. This class inherits IVehicleDynamics and has required methods for simulation. Users can make any C# dynamic model class as long as it inherits IVehicleDynamics and Monobehavior. It can be compiled in SVL Simulator run-time executable or the vehicle bundle itself.

Simple Model Interface Setup top#

  1. Create or select an EGO vehicle prefab in the Project panel only, not in scene

  2. Double click this EGO vehicle prefab. This opens the prefab editor scene

  3. Remove VehicleSMI.cs from the vehicle component list in the Inspector panel. This is the component that you are replacing with your own

  4. Add your new c# dynamics class component that inherits IVehicleDynamics

  5. If you plan to use Unity's physics engine, be sure to look at how VehicleSMI caches references to the wheel colliders and wheel meshes. This AxleInfo, in the C# example, enables you to apply force to the wheels and match the movement to the wheel models.

  6. Set any public references needed for your new dynamics model and save the prefab, Ctrl-S

  7. Open Simulator -> Build... to open the SVL Simulator bundle creation window

  8. Select Ego vehicle

  9. Select Build and after it is completed, in the root of the SVL Simulator you will have a folder called AssetBundles where the new bundles will be created. The new vehicle will be in AssetBundles/Vehicles folder.

  10. Open Loader.scene, run in editor and open the WebUI by pressing the Open Browser button in the Game panel view

  11. Under Library -> Vehicles select Add New

  12. Drag the new bundle into the target area to upload the vehicle or select from file folders.

  13. Set the vehicle details. Be sure to rename the vehicle so it isn't confused with other dynamics.

  14. Create a new sensor configuration.

  15. Publish the new vehicle.

Full Model Interface top#

Full Model Interface supports FMI2.0 Functional Mock-up Interface. Since user FMU's can vary greatly, we have provided an exampleFMU.fmu for testing in Windows only. It can be found in the source code in Assets -> Resources. ExampleVehicleFMU.cs is provided to see how the Full Model Interface system works. It is located in Assets -> Scripts -> Dynamics -> Examples. Users can create their own FMU class that inherits from IVehicleDynamics.

  1. Create or select an EGO vehicle prefab in the Project panel only, not in scene
  2. Double click this EGO vehicle prefab. This opens the prefab editor scene
  3. Remove VehicleSMI.cs from the vehicle component list in the Inspector panel. This is the component that you are replacing
  4. Add Component ExampleVehicleFMU.cs

ExampleFMU.fmu requires Unity physics solver

  1. Toggle button Non Unity Physics to Unity Physics
  2. Set Axles size to 2
  3. Setup Axles data. You will be dragging gameobjects from the Hierarchy panel to the Inspector panel
  4. Drag the correct wheel colliders and wheel meshes to public references from the prefab, see SMI setup
  5. Enable Motor and Steering for the front axle
  6. Set Brake Bias to 0.5f for front and back axles

Import the ExampleFMU.fmu

  1. Toggle button Import FMU
  2. Choose ExampleFMU.fmu in Assets -> Resources -> ExampleFMU.fmu
  3. FMU will unpack in the repository vehicle folder in External -> Vehicles -> VehicleName -> FMUName folder
  4. FMUImporter.cs will parse the XML file into FMUData in the VehicleFMU class instance on prefab
  5. Model Variables will be listed so users can reference by index
  6. Each model variable has multiple values that are displayed in the scroll area
  7. Open Simulator -> Build... to open the SVL Simulator bundle creation window
  8. Select the new Ego vehicle to build
  9. Select Build and after it is completed, in the root of the SVL Simulator you will have a folder called AssetBundles/Vehicles where the new bundles will be created.
  10. Open Loader.scene, run in editor and open the WebUI by pressing the Open Browser... button in the Game panel view
  11. Under Library -> Vehicles select Add New
  12. Drag the new bundle into the target area to upload the vehicle or select from file folders.
  13. Set the vehicle details. Be sure to rename the vehicle so it isn't confused with other dynamics.
  14. Create a new sensor configuration.
  15. Publish the new vehicle.

Full Model Interface Run-time behavior top#

SVL Simulator only supports one FMU vehicle and for Windows only.

Robotics top#

Robotics is similar to SMI C# dynamic model. It requires a class that inherits IVehicleDynamics and implements the needed methods for simulation. Users can make any C# dynamic model class as long as it inherits IVehicleDynamics and Monobehavior. It can be compiled in SVL Simulator run-time executable or the vehicle bundle itself. Robotics also requires a Controller class that inherits AgentController and implements the needed methods for simulation.

Robotics Setup top#

  1. Create an EGO robot prefab in the Project panel only, not in scene
  2. Double click this EGO robot prefab. This opens the prefab editor scene
  3. Robotics requires ArticulationBody components, not Rigidbody components. Set all ArticulationBody components in the Hierarchy Panel.
  4. Add your new c# dynamics class component that inherits IVehicleDynamics. Be sure to reference the ArticulationBody, not a rigidbody.

  1. Be sure BaseLink Transform is a child of the root prefab and set manually in the class.
  2. Add your new controller class component that inherits AgentController.
  3. Be sure Driver View Transform is a child of the root prefab and set manually in the class.
  4. Save the prefab, Ctrl-S.
  5. Open Simulator -> Build... to open the SVL Simulator bundle creation window
  6. Select Ego vehicle
  7. Select Build and after it is completed, in the root of the SVL Simulator you will have a folder called AssetBundles where the new bundles will be created. The new vehicle will be in AssetBundles/Vehicles folder.
  8. Open Loader.scene, run in editor and open the WebUI by pressing the Open Browser button in the Game panel view
  9. Under Library -> Vehicles select Add New
  10. Drag the new bundle into the target area to upload the vehicle or select from file folders.
  11. Set the vehicle details.
  12. Create a new sensor configuration.
  13. Publish the new vehicle.

Spectator top#

Spectator is not a vehicle at all. No dynamics class is needed and only a rigidbody with a class extending AgentController.cs. It can be compiled in SVL Simulator run-time executable or the vehicle bundle itself. Spectator vehicles that have no physics interaction just requires a Controller class that inherits AgentController and implements the needed methods for simulation.

Spectator Setup top#

  1. Create an EGO robot prefab in the Project panel only, not in scene
  2. Double click this EGO robot prefab. This opens the prefab editor scene
  3. Add a RigidBody component and tick disable Use Gravity.
  4. Add your new controller class component that inherits AgentController. This can be mostly empty

  1. Be sure Driver View Transform is a child of the root prefab and set manually in the class.
  2. Save the prefab, Ctrl-S.
  3. Open Simulator -> Build... to open the SVL Simulator bundle creation window
  4. Select Ego vehicle
  5. Select Build and after it is completed, in the root of the SVL Simulator you will have a folder called AssetBundles where the new bundles will be created. The new vehicle will be in AssetBundles/Vehicles folder.
  6. Open Loader.scene, run in editor and open the WebUI by pressing the Open Browser button in the Game panel view
  7. Under Library -> Vehicles select Add New
  8. Drag the new bundle into the target area to upload the vehicle or select from file folders.
  9. Set the vehicle details.
  10. Create a new sensor configuration.
  11. Publish the new vehicle.
  12. Create a new simulation.