Outdoor Environment
Description
The Environment Outdoors library is used to modify settings of the QLabs actor environment. Not all Open World environments support all environmental features.
Outdoor Environment Library
Constants
- QLabsEnvironmentOutdoors.ID_ENVIRONMENT_OUTDOORS = 1100
Class ID
- QLabsEnvironmentOutdoors.CLEAR_SKIES = 0
- QLabsEnvironmentOutdoors.PARTLY_CLOUDY = 1
- QLabsEnvironmentOutdoors.CLOUDY = 2
- QLabsEnvironmentOutdoors.OVERCAST = 3
- QLabsEnvironmentOutdoors.FOGGY = 4
- QLabsEnvironmentOutdoors.LIGHT_RAIN = 5
- QLabsEnvironmentOutdoors.RAIN = 6
- QLabsEnvironmentOutdoors.THUNDERSTORM = 7
- QLabsEnvironmentOutdoors.LIGHT_SNOW = 8
- QLabsEnvironmentOutdoors.SNOW = 9
- QLabsEnvironmentOutdoors.BLIZZARD = 10
Methods
- QLabsEnvironmentOutdoors.set_time_of_day(time)[source]
Set the time of day for an outdoor environment.
- Parameters
time (float) – A value from 0 to 24. Midnight is a value 0 or 24. Noon is a value of 12.
- Returns
True if setting the time was successful, False otherwise
- Return type
boolean
- QLabsEnvironmentOutdoors.set_outdoor_lighting(state)[source]
Overrides the outdoor lighting set by other environment functions
- Parameters
state – 0 force lights off, 1 force lights on
- Returns
True if setting the time was successful, False otherwise
- Return type
boolean
- QLabsEnvironmentOutdoors.set_weather_preset(weather_preset)[source]
Set the weather conditions for an outdoor environment with a preset value
- Parameters
weather_preset – A preset index (see defined constants for weather types)
- Returns
True if setting the time was successful, False otherwise
- Return type
boolean
Methods Tutorial
Example
1"""
2Weather Example
3---------------
4
5.. note::
6
7 Make sure you have Quanser Interactive Labs open before running this
8 example. This example is designed to run in the QCar Cityscape.
9
10"""
11
12from qvl.qlabs import QuanserInteractiveLabs
13from qvl.free_camera import QLabsFreeCamera
14from qvl.environment_outdoors import QLabsEnvironmentOutdoors
15from qvl.system import QLabsSystem
16
17import time
18import os
19
20def main():
21
22 # Clears the screen in Windows
23 os.system('cls')
24
25 print("\n\n------------------------------ Communications --------------------------------\n")
26
27 # Creates a server connection with Quanser Interactive Labs and manages
28 # the communications
29 qlabs = QuanserInteractiveLabs()
30
31 # Ensure that QLabs is running on your local machine
32 print("Connecting to QLabs...")
33 try:
34 qlabs.open("localhost")
35 except:
36 print("Unable to connect to QLabs")
37 return
38
39 print("Connected")
40
41 hSystem = QLabsSystem(qlabs)
42
43
44 ### Outdoor Environment
45 print("\n\n---Outdoor Environment---")
46
47 hEnvironmentOutdoors2 = QLabsEnvironmentOutdoors(qlabs)
48 hEnvironmentOutdoors2.set_outdoor_lighting(0)
49
50 # Create a camera at spawn location to allow us to see the weather changes
51 hCameraWeather = QLabsFreeCamera(qlabs)
52 x = hCameraWeather.spawn(location=[0.075, -8.696, 1.576], rotation=[0, -0.141, 1.908])
53 hCameraWeather.possess()
54
55 time.sleep(2.5)
56
57 # Run through different weather possibilities in QLabs
58 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.CLEAR_SKIES)
59 hSystem.set_title_string('Clear skies')
60 time.sleep(2.5)
61
62 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.PARTLY_CLOUDY)
63 hSystem.set_title_string('Partly cloudy')
64 time.sleep(2.5)
65
66 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.CLOUDY)
67 hSystem.set_title_string('Cloudy')
68 time.sleep(2.5)
69
70 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.OVERCAST)
71 hEnvironmentOutdoors2.set_outdoor_lighting(1)
72 hSystem.set_title_string('Overcast')
73 time.sleep(2.5)
74
75 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.FOGGY)
76 hSystem.set_title_string('Foggy')
77 time.sleep(2.5)
78
79 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.LIGHT_RAIN)
80 hEnvironmentOutdoors2.set_outdoor_lighting(0)
81 hSystem.set_title_string('Light rain')
82 time.sleep(2.5)
83
84 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.RAIN)
85 hEnvironmentOutdoors2.set_outdoor_lighting(1)
86 hSystem.set_title_string('Rain')
87 time.sleep(2.5)
88
89 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.THUNDERSTORM)
90 hSystem.set_title_string('Thunderstorm')
91 time.sleep(2.5)
92
93 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.LIGHT_SNOW)
94 hEnvironmentOutdoors2.set_outdoor_lighting(0)
95 hSystem.set_title_string('Light snow')
96 time.sleep(2.5)
97
98 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.SNOW)
99 hEnvironmentOutdoors2.set_outdoor_lighting(1)
100 hSystem.set_title_string('Snow')
101 time.sleep(2.5)
102
103 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.BLIZZARD)
104 hSystem.set_title_string('Blizzard')
105 time.sleep(2.5)
106
107 hEnvironmentOutdoors2.set_weather_preset(hEnvironmentOutdoors2.PARTLY_CLOUDY)
108 hEnvironmentOutdoors2.set_outdoor_lighting(0)
109 hSystem.set_title_string('QLABS WEATHER')
110
111
112 print("\n\n------------------------------ Communications --------------------------------\n")
113
114 qlabs.close()
115 print("Done!")
116
117main()
118