Returns a carla.WeatherParameters with the corresponding weather for that route. If the route has no weather attribute, the default one is triggered.
(route)
| 81 | |
| 82 | @staticmethod |
| 83 | def parse_weather(route): |
| 84 | """ |
| 85 | Returns a carla.WeatherParameters with the corresponding weather for that route. If the route |
| 86 | has no weather attribute, the default one is triggered. |
| 87 | """ |
| 88 | |
| 89 | route_weather = route.find("weather") |
| 90 | if route_weather is None: |
| 91 | |
| 92 | weather = carla.WeatherParameters(sun_altitude_angle=70) |
| 93 | |
| 94 | else: |
| 95 | weather = carla.WeatherParameters() |
| 96 | for weather_attrib in route.iter("weather"): |
| 97 | |
| 98 | if 'cloudiness' in weather_attrib.attrib: |
| 99 | weather.cloudiness = float(weather_attrib.attrib['cloudiness']) |
| 100 | if 'precipitation' in weather_attrib.attrib: |
| 101 | weather.precipitation = float(weather_attrib.attrib['precipitation']) |
| 102 | if 'precipitation_deposits' in weather_attrib.attrib: |
| 103 | weather.precipitation_deposits = float(weather_attrib.attrib['precipitation_deposits']) |
| 104 | if 'wind_intensity' in weather_attrib.attrib: |
| 105 | weather.wind_intensity = float(weather_attrib.attrib['wind_intensity']) |
| 106 | if 'sun_azimuth_angle' in weather_attrib.attrib: |
| 107 | weather.sun_azimuth_angle = float(weather_attrib.attrib['sun_azimuth_angle']) |
| 108 | if 'sun_altitude_angle' in weather_attrib.attrib: |
| 109 | weather.sun_altitude_angle = float(weather_attrib.attrib['sun_altitude_angle']) |
| 110 | if 'wetness' in weather_attrib.attrib: |
| 111 | weather.wetness = float(weather_attrib.attrib['wetness']) |
| 112 | if 'fog_distance' in weather_attrib.attrib: |
| 113 | weather.fog_distance = float(weather_attrib.attrib['fog_distance']) |
| 114 | if 'fog_density' in weather_attrib.attrib: |
| 115 | weather.fog_density = float(weather_attrib.attrib['fog_density']) |
| 116 | |
| 117 | return weather |
| 118 | |
| 119 | @staticmethod |
| 120 | def check_trigger_position(new_trigger, existing_triggers): |