From 139041fd7f2e2af02ac799c83f1d975b7b8750ad Mon Sep 17 00:00:00 2001 From: Marcel Pi Date: Wed, 27 Apr 2022 11:52:25 +0100 Subject: [PATCH] Improvements to the dust_storm weather parameter. (#5388) * Switched DustStorm parameter from bool to float. * Automatically detect clang version. * Revert "Automatically detect clang version." This reverts commit 4ac1c95c26d652bbc484b60c2266b0179cba1937. * Update environment.py weather presets. * Expose dust_storm console command in environment.py + documentation. * Fix minor DustStorm preset error. * Update CHANGELOG.md --- CHANGELOG.md | 1 + Docs/python_api.md | 7 ++- .../source/carla/rpc/WeatherParameters.cpp | 46 +++++++++---------- LibCarla/source/carla/rpc/WeatherParameters.h | 4 +- PythonAPI/carla/source/libcarla/Weather.cpp | 4 +- PythonAPI/docs/weather.yml | 5 ++ PythonAPI/util/environment.py | 15 ++++-- .../Source/Carla/Weather/WeatherParameters.h | 4 +- 8 files changed, 52 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4ca3b9d9..4de7271b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * Added new API function: `set_day_night_cycle` at the LightManager, to (de)activate the automatic switch of the lights when the simulation changes from day to night mode, and viceversa. * Switch to boost::variant2 for rpc::Command as that allows more than 20 RPC commands * Added post process effects for rainy and dusty weathers. + * Switched data type of the dust storm weather parameter from bool to float. * Check for the version of the installed Clang compiler during build. ## CARLA 0.9.13 diff --git a/Docs/python_api.md b/Docs/python_api.md index 2b866deb6..24f47d555 100644 --- a/Docs/python_api.md +++ b/Docs/python_api.md @@ -3138,7 +3138,7 @@ Rain intensity values range from 0 to 100, being 0 none at all and 100 a heavy r - **precipitation_deposits** (_float_) Determines the creation of puddles. Values range from 0 to 100, being 0 none at all and 100 a road completely capped with water. Puddles are created with static noise, meaning that they will always appear at the same locations. - **wind_intensity** (_float_) -Controls the strenght of the wind with values from 0, no wind at all, to 100, a strong wind. The wind does affect rain direction and leaves from trees, so this value is restricted to avoid animation issues. +Controls the strength of the wind with values from 0, no wind at all, to 100, a strong wind. The wind does affect rain direction and leaves from trees, so this value is restricted to avoid animation issues. - **sun_azimuth_angle** (_float - degrees_) The azimuth angle of the sun. Values range from 0 to 360. Zero is an origin point in a sphere determined by Unreal Engine. - **sun_altitude_angle** (_float - degrees_) @@ -3157,6 +3157,8 @@ Controls how much the light will contribute to volumetric fog. When set to 0, th Controls interaction of light with large particles like pollen or air pollution resulting in a hazy sky with halos around the light sources. When set to 0, there is no contribution. - **rayleigh_scattering_scale** (_float_) Controls interaction of light with small particles like air molecules. Dependent on light wavelength, resulting in a blue sky in the day or red sky in the evening. +- **dust_storm** (_float_) +Determines the strength of the dust storm weather. Values range from 0 to 100. ### Methods - **\__init__**(**self**, **cloudiness**=0.0, **precipitation**=0.0, **precipitation_deposits**=0.0, **wind_intensity**=0.0, **sun_azimuth_angle**=0.0, **sun_altitude_angle**=0.0, **fog_density**=0.0, **fog_distance**=0.0, **wetness**=0.0, **fog_falloff**=0.0, **scattering_intensity**=0.0, **mie_scattering_scale**=0.0, **rayleigh_scattering_scale**=0.0331) @@ -3175,7 +3177,8 @@ Method to initialize an object defining weather conditions. This class has some - `scattering_intensity` (_float_) - Controls how much the light will contribute to volumetric fog. When set to 0, there is no contribution. - `mie_scattering_scale` (_float_) - Controls interaction of light with large particles like pollen or air pollution resulting in a hazy sky with halos around the light sources. When set to 0, there is no contribution. - `rayleigh_scattering_scale` (_float_) - Controls interaction of light with small particles like air molecules. Dependent on light wavelength, resulting in a blue sky in the day or red sky in the evening. - - **Note:** _ClearNoon, CloudyNoon, WetNoon, WetCloudyNoon, SoftRainNoon, MidRainyNoon, HardRainNoon, ClearSunset, CloudySunset, WetSunset, WetCloudySunset, SoftRainSunset, MidRainSunset, HardRainSunset. + - `dust_storm` (_float_) - 0 is no dust at all, 100 a heavy dust/sand storm. + - **Note:** _ClearNoon, CloudyNoon, WetNoon, WetCloudyNoon, SoftRainNoon, MidRainyNoon, HardRainNoon, ClearSunset, CloudySunset, WetSunset, WetCloudySunset, SoftRainSunset, MidRainSunset, HardRainSunset, DustStorm. _ ##### Dunder methods diff --git a/LibCarla/source/carla/rpc/WeatherParameters.cpp b/LibCarla/source/carla/rpc/WeatherParameters.cpp index e190e6765..68ceff20a 100644 --- a/LibCarla/source/carla/rpc/WeatherParameters.cpp +++ b/LibCarla/source/carla/rpc/WeatherParameters.cpp @@ -12,29 +12,29 @@ namespace rpc { using WP = WeatherParameters; // cloudiness precip. prec.dep. wind azimuth altitude fog dens fog dist fog fall wetness scat.i mie.scat.s rayleigh.scat.scale dust storm - WP WP::Default = { -1.0f, -1.0f, -1.0f, -1.00f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::ClearNoon = { 5.0f, 0.0f, 0.0f, 10.0f, -1.0f, 45.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::CloudyNoon = { 60.0f, 0.0f, 0.0f, 10.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::WetNoon = { 5.0f, 0.0f, 50.0f, 10.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::WetCloudyNoon = { 60.0f, 0.0f, 50.0f, 10.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::MidRainyNoon = { 60.0f, 60.0f, 60.0f, 60.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::HardRainNoon = { 100.0f, 100.0f, 90.0f, 100.0f, -1.0f, 45.0f, 7.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::SoftRainNoon = { 20.0f, 30.0f, 50.0f, 30.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::ClearSunset = { 5.0f, 0.0f, 0.0f, 10.0f, -1.0f, 15.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::CloudySunset = { 60.0f, 0.0f, 0.0f, 10.0f, -1.0f, 15.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::WetSunset = { 5.0f, 0.0f, 50.0f, 10.0f, -1.0f, 15.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::WetCloudySunset = { 60.0f, 0.0f, 50.0f, 10.0f, -1.0f, 15.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::MidRainSunset = { 60.0f, 60.0f, 60.0f, 60.0f, -1.0f, 15.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::HardRainSunset = { 100.0f, 100.0f, 90.0f, 100.0f, -1.0f, 15.0f, 7.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::SoftRainSunset = { 20.0f, 30.0f, 50.0f, 30.0f, -1.0f, 15.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::ClearNight = { 5.0f, 0.0f, 0.0f, 10.0f, -1.0f, -90.0f, 60.0f, 75.0f, 1.0f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::CloudyNight = { 60.0f, 0.0f, 0.0f, 10.0f, -1.0f, -90.0f, 60.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::WetNight = { 5.0f, 0.0f, 50.0f, 10.0f, -1.0f, -90.0f, 60.0f, 75.0f, 1.0f, 60.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::WetCloudyNight = { 60.0f, 0.0f, 50.0f, 10.0f, -1.0f, -90.0f, 60.0f, 0.75f, 0.1f, 60.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::SoftRainNight = { 60.0f, 30.0f, 50.0f, 30.0f, -1.0f, -90.0f, 60.0f, 0.75f, 0.1f, 60.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::MidRainyNight = { 80.0f, 60.0f, 60.0f, 60.0f, -1.0f, -90.0f, 60.0f, 0.75f, 0.1f, 80.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::HardRainNight = { 100.0f, 100.0f, 90.0f, 100.0f, -1.0f, -90.0f, 100.0f, 0.75f, 0.1f, 100.0f, 1.0f, 0.03f, 0.0331f, false }; - WP WP::DustStorm = { 100.0f, 0.0f, 0.0f, 100.0f, -1.0f, 45.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, true }; + WP WP::Default = { -1.0f, -1.0f, -1.0f, -1.00f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::ClearNoon = { 5.0f, 0.0f, 0.0f, 10.0f, -1.0f, 45.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::CloudyNoon = { 60.0f, 0.0f, 0.0f, 10.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::WetNoon = { 5.0f, 0.0f, 50.0f, 10.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::WetCloudyNoon = { 60.0f, 0.0f, 50.0f, 10.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::MidRainyNoon = { 60.0f, 60.0f, 60.0f, 60.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::HardRainNoon = { 100.0f, 100.0f, 90.0f, 100.0f, -1.0f, 45.0f, 7.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::SoftRainNoon = { 20.0f, 30.0f, 50.0f, 30.0f, -1.0f, 45.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::ClearSunset = { 5.0f, 0.0f, 0.0f, 10.0f, -1.0f, 15.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::CloudySunset = { 60.0f, 0.0f, 0.0f, 10.0f, -1.0f, 15.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::WetSunset = { 5.0f, 0.0f, 50.0f, 10.0f, -1.0f, 15.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::WetCloudySunset = { 60.0f, 0.0f, 50.0f, 10.0f, -1.0f, 15.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::MidRainSunset = { 60.0f, 60.0f, 60.0f, 60.0f, -1.0f, 15.0f, 3.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::HardRainSunset = { 100.0f, 100.0f, 90.0f, 100.0f, -1.0f, 15.0f, 7.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::SoftRainSunset = { 20.0f, 30.0f, 50.0f, 30.0f, -1.0f, 15.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::ClearNight = { 5.0f, 0.0f, 0.0f, 10.0f, -1.0f, -90.0f, 60.0f, 75.0f, 1.0f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::CloudyNight = { 60.0f, 0.0f, 0.0f, 10.0f, -1.0f, -90.0f, 60.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::WetNight = { 5.0f, 0.0f, 50.0f, 10.0f, -1.0f, -90.0f, 60.0f, 75.0f, 1.0f, 60.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::WetCloudyNight = { 60.0f, 0.0f, 50.0f, 10.0f, -1.0f, -90.0f, 60.0f, 0.75f, 0.1f, 60.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::SoftRainNight = { 60.0f, 30.0f, 50.0f, 30.0f, -1.0f, -90.0f, 60.0f, 0.75f, 0.1f, 60.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::MidRainyNight = { 80.0f, 60.0f, 60.0f, 60.0f, -1.0f, -90.0f, 60.0f, 0.75f, 0.1f, 80.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::HardRainNight = { 100.0f, 100.0f, 90.0f, 100.0f, -1.0f, -90.0f, 100.0f, 0.75f, 0.1f, 100.0f, 1.0f, 0.03f, 0.0331f, 0.0f }; + WP WP::DustStorm = { 100.0f, 0.0f, 0.0f, 100.0f, -1.0f, 45.0f, 2.0f, 0.75f, 0.1f, 0.0f, 1.0f, 0.03f, 0.0331f, 100.0f }; } // namespace rpc } // namespace carla diff --git a/LibCarla/source/carla/rpc/WeatherParameters.h b/LibCarla/source/carla/rpc/WeatherParameters.h index 470678345..45a75bf1f 100644 --- a/LibCarla/source/carla/rpc/WeatherParameters.h +++ b/LibCarla/source/carla/rpc/WeatherParameters.h @@ -63,7 +63,7 @@ namespace rpc { float in_scattering_intensity, float in_mie_scattering_scale, float in_rayleigh_scattering_scale, - bool in_dust_storm) + float in_dust_storm) : cloudiness(in_cloudiness), precipitation(in_precipitation), precipitation_deposits(in_precipitation_deposits), @@ -92,7 +92,7 @@ namespace rpc { float scattering_intensity = 0.0f; float mie_scattering_scale = 0.0f; float rayleigh_scattering_scale = 0.0331f; - bool dust_storm = false; + float dust_storm = 0.0f; #ifdef LIBCARLA_INCLUDED_FROM_UE4 diff --git a/PythonAPI/carla/source/libcarla/Weather.cpp b/PythonAPI/carla/source/libcarla/Weather.cpp index 15ef00f88..8c86a95d2 100644 --- a/PythonAPI/carla/source/libcarla/Weather.cpp +++ b/PythonAPI/carla/source/libcarla/Weather.cpp @@ -38,7 +38,7 @@ void export_weather() { namespace cr = carla::rpc; auto cls = class_("WeatherParameters") - .def(init( + .def(init( (arg("cloudiness")=0.0f, arg("precipitation")=0.0f, arg("precipitation_deposits")=0.0f, @@ -52,7 +52,7 @@ void export_weather() { arg("scattering_intensity")=0.0f, arg("mie_scattering_scale")=0.0f, arg("rayleigh_scattering_scale")=0.0331f, - arg("dust_storm")=false))) + arg("dust_storm")=0.0f))) .def_readwrite("cloudiness", &cr::WeatherParameters::cloudiness) .def_readwrite("precipitation", &cr::WeatherParameters::precipitation) .def_readwrite("precipitation_deposits", &cr::WeatherParameters::precipitation_deposits) diff --git a/PythonAPI/docs/weather.yml b/PythonAPI/docs/weather.yml index 9326d2620..c5189c68e 100644 --- a/PythonAPI/docs/weather.yml +++ b/PythonAPI/docs/weather.yml @@ -77,6 +77,11 @@ type: float doc: > Controls interaction of light with small particles like air molecules. Dependent on light wavelength, resulting in a blue sky in the day or red sky in the evening. + # -------------------------------------- + - var_name: dust_storm + type: float + doc: > + Determines the strength of the dust storm weather. Values range from 0 to 100. # - METHODS ---------------------------- methods: - def_name: __init__ diff --git a/PythonAPI/util/environment.py b/PythonAPI/util/environment.py index c254f88ee..0090896b1 100644 --- a/PythonAPI/util/environment.py +++ b/PythonAPI/util/environment.py @@ -25,9 +25,9 @@ SUN_PRESETS = { 'sunset': (0.5, 0.0)} WEATHER_PRESETS = { - 'clear': [10.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0331], - 'overcast': [80.0, 0.0, 0.0, 50.0, 2.0, 0.75, 0.1, 10.0, 0.0, 0.03, 0.0331], - 'rain': [100.0, 80.0, 90.0, 100.0, 7.0, 0.75, 0.1, 100.0, 0.0, 0.03, 0.0331]} + 'clear': [10.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0331, 0.0], + 'overcast': [80.0, 0.0, 0.0, 50.0, 2.0, 0.75, 0.1, 10.0, 0.0, 0.03, 0.0331, 0.0], + 'rain': [100.0, 80.0, 90.0, 100.0, 7.0, 0.75, 0.1, 100.0, 0.0, 0.03, 0.0331, 0.0]} CAR_LIGHTS = { 'None' : [carla.VehicleLightState.NONE], @@ -77,6 +77,7 @@ def apply_weather_presets(args, weather): weather.scattering_intensity = WEATHER_PRESETS[args.weather][8] weather.mie_scattering_scale = WEATHER_PRESETS[args.weather][9] weather.rayleigh_scattering_scale = WEATHER_PRESETS[args.weather][10] + weather.dust_storm = WEATHER_PRESETS[args.weather][11] else: print("[ERROR]: Command [--weather | -w] '" + args.weather + "' not known") sys.exit(1) @@ -110,6 +111,8 @@ def apply_weather_values(args, weather): weather.mie_scattering_scale = args.miescatteringscale if args.rayleighscatteringscale is not None: weather.rayleigh_scattering_scale = args.rayleighscatteringscale + if args.dust_storm is not None: + weather.dust_storm = args.dust_storm def apply_lights_to_cars(args, world): @@ -261,6 +264,12 @@ def main(): default=None, type=float, help='Mie scattering scale [0.0, 5.0]') + argparser.add_argument( + '--dust_storm', '-ds', + metavar='ds', + default=None, + type=float, + help='Dust storm strength [0.0, 100.0]') argparser.add_argument( '--cars', metavar='Cars', diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/WeatherParameters.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/WeatherParameters.h index d2f6db053..8feb65644 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/WeatherParameters.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/WeatherParameters.h @@ -52,6 +52,6 @@ struct CARLA_API FWeatherParameters UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "2.0", UIMin = "0.0", UIMax = "2.0")) float RayleighScatteringScale = 0.0331f; - UPROPERTY(EditAnywhere, BlueprintReadWrite) - bool DustStorm = false; + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0")) + float DustStorm = 0.0f; };