-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathWeatherSelector.py
73 lines (65 loc) · 2.87 KB
/
WeatherSelector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
Defines a few custom weather presets. Up until version 0.9.6, carla has a few native ones; however, on my data capture
setup they don't seem to differ that much one from another
"""
import sys
import os
import settings
sys.path.append(settings.CARLA_EGG_PATH)
import carla
# https://carla.readthedocs.io/en/latest/python_api/#carlaweatherparameters-class
class WeatherSelector:
def __init__(self):
self.cloudiness = None # 0.0 to 100.0
self.precipitation = None # 0.0 to 100.0
self.precipitation_deposits = None # 0.0 to 100.0
self.wind_intensity = None # 0.0 to 100.0
self.sun_azimuth_angle = None # 0.0 to 360.0
self.sun_altitude_angle = None # -90.0 to 90.0
def get_weather_options(self):
return [self.morning(), self.midday(), self.afternoon(), self.default(), self.almost_night()]
def morning(self):
self.cloudiness = 20.0
self.precipitation = 90.0
self.precipitation_deposits = 30.0
self.wind_intensity = 30.0
self.sun_azimuth_angle = 0.0
self.sun_altitude_angle = 30.0
return [self.cloudiness, self.precipitation, self.precipitation_deposits, self.wind_intensity,
self.sun_azimuth_angle, self.sun_altitude_angle]
def midday(self):
self.cloudiness = 30.0
self.precipitation = 0.0
self.precipitation_deposits = 60.0
self.wind_intensity = 30.0
self.sun_azimuth_angle = 00.0
self.sun_altitude_angle = 80#80.0 # 45
return [self.cloudiness, self.precipitation, self.precipitation_deposits, self.wind_intensity,
self.sun_azimuth_angle, self.sun_altitude_angle]
def afternoon(self):
self.cloudiness = 50.0
self.precipitation = 0.0
self.precipitation_deposits = 40.0
self.wind_intensity = 30.0
self.sun_azimuth_angle = 0.0
self.sun_altitude_angle = -40.0
return [self.cloudiness, self.precipitation, self.precipitation_deposits, self.wind_intensity,
self.sun_azimuth_angle, self.sun_altitude_angle]
def default(self):
self.cloudiness = -1.0
self.precipitation = -1.0
self.precipitation_deposits = -1.0
self.wind_intensity = -1.0
self.sun_azimuth_angle = -1.0
self.sun_altitude_angle = -1.0
return [self.cloudiness, self.precipitation, self.precipitation_deposits, self.wind_intensity,
self.sun_azimuth_angle, self.sun_altitude_angle]
def almost_night(self):
self.cloudiness = 30.0
self.precipitation = 30.0
self.precipitation_deposits = 0.0
self.wind_intensity = 30.0
self.sun_azimuth_angle = 0.0
self.sun_altitude_angle = -60.0
return [self.cloudiness, self.precipitation, self.precipitation_deposits, self.wind_intensity,
self.sun_azimuth_angle, self.sun_altitude_angle]