Driving Example
Overview
This guide explains how to use and customize the driving simulation example in SightLab. The example is located in the ExampleScripts-Driving folder.
Driving_GUI.py uses the GUI version. Pressing spacebar will start the experiment or proceed to the next trial. Trial 1 shows a daytime cycle, while Trial 2 shows a nighttime cycle with the car headlights toggled on. Trial 3 goes back to the Day Cycle. This can all be modified (see below).
Driving_example.py uses only code, but has similar functionality to Driving_GUI
Driving_GUI_Traffic.py shows adding some cross traffic flow. Can modify the code to adjust speed and number of additional cars. Uses collision detection to check whether your vehicle collides with any others. If so, this ends the trial.
Controls
Desktop
- Movement: WASD keys
- Steering: Mouse
- Acceleration: "=" key
- Deceleration: "-" key
- Reposition viewpoint: T, F, G, H keys
HMD (Head-Mounted Display)
- Forward: Right Hand (RH) Trigger
- Brake/Reverse: Left Hand (LH) Trigger
- Steering: Thumbstick (left/right)
- Acceleration: B key
- Deceleration: A key
- Reposition viewpoint: WASD, X, and Z keys
SteamVR/Vive Controllers
- Steering: RH trackpad (left/right)
- Acceleration: RH system button
- Deceleration: RH grip button
Customization
Changing the Environment
- Place a new environment file in the Resources/environments folder.
-
Select the new environment using the GUI:
- Click "Modify" on the GUI screen
- Choose the new environment ### Changing the Vehicle
Modify the DrivingConfig file to select a different vehicle. Place your new vehicle in the "Resources" or some other sub folder and reference the path to that model in the DrivingConfig file.
Alternatively, for the non-GUI version (Driving_example), modify the DrivingConfig file to select a different environment, vehicle or audio file
ENVIRONMENT_MODEL = "Resources/environments/street_scene.osgb"
CAR_MODEL = 'sightlab_resources/objects/car.osgb'
ENGINE_AUDIO = 'Resources/Engine.mp3'
Changing View Position in Car
- Run the script using the Vizard editor and use either the TFGH, ZX keys to position your viewpoint if Desktop or WASD, ZX for HMD
- Press the 'v' key when your position looks correct
- This will print out your current position in the Vizard interactive window
- Copy and paste this position into the code below after "tranportNode2.setPosition" depending on which hardware you are using
if sightlab.getConfig() in ['Driving Desktop']:
transportNode2.setPosition([0.25, 0.65, 0.35])
elif sightlab.getConfig() in ['Driving SteamVR']:
transportNode2.setPosition([0.188, 1.315, 0.8676])
elif sightlab.getConfig() in ['Driving Vive']:
transportNode2.setPosition([-0.0360, 0.7195, 0.5641])
elif sightlab.getConfig() in ['Driving Meta']:
transportNode2.setPosition([0.2337, 0.641, 0.3140])
Customizing Controls
- Navigate to the vizconnect file in util_files/sightlab_utils/vizconnect_configs.
- Go to Advanced > Transports > Driving > Mappings and Acceleration/Deceleration under "Events".
- Modify the mappings as needed.
Note: You may need to set permissions on the file to edit the vizconnect.
Using Alternative Input Devices
You can connect various joysticks, such as a driving wheel or game controller:
- In vizconnect, add a generic or direct input joystick as an input.
- For more information, refer to the joystick connection documentation.
##
Session Replay
After running a session, use SessionReplay to view a playback of your session, including the car's movement.
Advanced Versions
Contact sales@worldviz.com for information on advanced versions:
- Version that shows driving over elevations and ramps
- 360 video driving simulator (combining 3D models and 360 videos)
- Flying simulator
Adding Ramps/Elevation Detection (SightLab 1.9.8 or higher)
- Add this line at the top of your script:
from sightlab_utils import collision - After the "updateCarTransform" function, add:
c = collision.Collision()
360 Driving Simulator Instructions (Available Upon Request)
Controls
- Reset Position: R key
- Start/Stop Simulation: Spacebar
- Pause Video: V key
- Reset Video: B key
- Fast Forward: F key
- Get Current Position: T key
- Toggle Overlays: H key
- Toggle Gaze Point: P key
- Take Screenshot: / key
Notes
- May require K-Lite Codec Pack installation:https://codecguide.com/download_kl.htm
- For positioning, use transportNode2.setPosition after getting the current position.
Additional Information
- A shortcut to the sightlab_utils folder is available in Projects > Util_files.
- The tutorial video below is for SightLab 1.9 and may contain outdated instructions, but still has good information on getting car models from Sketchfab, setting them up, etc.