Main Content

Configure a Driving Simulator for Your Desktop with Virtual Vehicle Composer

You can configure a driving simulator for your desktop with the Virtual Vehicle Composer. This example shows how to run a driver-in-the-loop simulation using the Logitech® G29 steering wheel and pedals.

Connect Game Wheel Hardware

Connect the Logitech G29 steering wheel and pedals hardware to the USB port on the target computer.

Tip

You must have Logitech G Hub installed and running prior to executing this workflow. For more information, see Logitech G Hub.

Build Virtual Vehicle Model

Build a virtual vehicle model with combined longitudinal and lateral dynamics.

  1. Navigate to the MATLAB® toolstrip. On the Apps tab, click the down arrow on the far right of the toolstrip to expand the apps gallery, and then select Virtual Vehicle Composer.

  2. To create a new virtual vehicle model, on the Virtual Vehicle Composer toolstrip, on the Composer tab, click New.

    Virtual Vehicle Composer app toolstrip showing the Composer tab that contains the new button.

  3. On the Setup tab in the Virtual Vehicle Composer, configure these settings for a passenger vehicle:

    • Powertrain architectureConventional Vehicle

      You can also select an electric vehicle or hybrid vehicle. For more information, see Powertrain architecture (Powertrain Blockset).

    • Vehicle dynamicsCombined Longitudinal and Lateral Dynamics

    • Model templateSimulink

    Virtual vehicle composer setup page with the powertrain architecture set to conventional vehicle, vehicle dynamics set to combined longitudinal and lateral dynamics, and model template set to Simulink.

  4. Click Confirm Setup.

  5. Click Build Virtual Vehicle.

Configure Game Wheel Hardware

Configure the game wheel hardware using the Driver Commands block.

  1. In the Driver Commands block, from the Vehicle command mode list, select Game Wheel Hardware.

    Driver Commands block parameters dialog box.

  2. Right-click the Driver Commands block and select Mask > Look Under Mask.

  3. In the Driver Commands/Driver Commands/Game Wheel Hardware subsystem, right-click the Simulation 3D Joystick block and select Uncomment to enable the block.

    Game wheel hardware subsystem.

    Right-click menu for the Simulation 3D Joystick with the uncomment option highlighted.

3D Environment Setup

Configure the 3D environment to use the ZalaZONE Automotive Proving Ground High-Speed Handling Course scene with the recommended starting location and enable the 3D engine.

3D Scene Setup

  1. In the Environment subsystem, right-click the Ground Feedback subsystem and select Variant > Label Mode Active Choice > 1 (3D Engine).

  2. In the Visualization subsystem, right-click the 3D Engine subsystem and select Variant > Label Mode Active Choice > Engine3D (3D Engine).

  3. In the Visualization > 3D Engine subsystem, open the Simulation 3D Scene Configuration block.

    Simulation 3D Scene Configuration block on model canvas.

    For this example, for the Simulation 3D Scene Configuration block:

    • Set Scene name to ZalaZONE High-speed Handling Course.

    • Set Scene view to SimulinkVehicle1.

    Note

    If the scene is not available in the Scene name parameter drop-down list, you must install it. See Setup.

  4. Click OK and save the model.

Starting Location Setup

  1. Open the Model Explorer.

  2. In the Model Hierarchy pane, navigate to ConfiguredVirtualVehicleModel > External Data > VirtualVehicleTemplate.

  3. In the list of Referenced Dictionaries, select PassVeh. Click Open.

    Virtual vehicle template PassVeh data dictionary

  4. In the Model Hierarchy pane, select ConfiguredVirtualVehicleModel > PassVeh > Design Data.

  5. Set the data dictionary variable value to the initial vehicle position values recommended for the scene. For this example, use these recommended values for the ZalaZONE Automotive Proving Ground High-Speed Handling Course scene.

    Data Dictionary VariableDescriptionRecommended Value
    PlntVehInitLongPos

    Recommended starting location - X

    1182

    PlntVehInitLatPos

    Recommended starting location - Y

    -347

    PlntVehInitVertPos

    Recommended starting location - Z

    -230.5

    PlntVehInitRollAng

    Recommended starting location - Roll

    0

    PlntVehInitPitchAng

    Recommended starting location - Pitch

    0

    PlntVehInitYawAng

    Recommended starting location - Yaw

    28.6

  6. In the PassVeh data dictionary, confirm the variable values match the recommended starting values for the scene.

    Virtual vehicle template passveh data dictionary

  7. In the Model Explorer, save the PassVeh changes.

Run Simulation

  1. Optionally, to run the simulation in soft real-time, enable simulation pacing by clicking the down arrow on the Run button, and then select Simulation Pacing.

    Run options drop-down menu.

    From the Simulation Pacing Options: ConfiguredVirtualVehicleModel dialog box, select Enable pacing to slow down simulation.

    Simulation Pacing Options: ConfiguredVirtualVehicleModel dialog box with the Enable pacing to slow donw simulation option selected.

  2. On the ConfiguredVirtualVehicleModel model toolstrip, click Run.

  3. Drive the vehicle around the track using the steering wheel and pedals. As the simulation runs, view the results in the Simulation 3D Viewer.

    Simulation 3D Viewer displaying an animation of a vehicle driving around the ZalaZONE Automotive Proving Grounds High-speed Handling Course.

See Also

|

Topics