Added more weather attributes

This commit is contained in:
Marc Garcia Puig 2020-01-13 19:10:20 +01:00 committed by bernat
parent 73f91e0bfc
commit a41bf95afd
7 changed files with 76 additions and 37 deletions

View File

@ -349,7 +349,7 @@ object
```py
weather = carla.WeatherParameters(
cloudyness=80.0,
cloudiness=80.0,
precipitation=30.0,
sun_altitude_angle=70.0)

View File

@ -11,22 +11,22 @@ namespace rpc {
using WP = WeatherParameters;
// cloudyness precip. prec.dep. wind azimuth altitude
WP WP::Default = { -1.0f, -1.0f, -1.0f, -1.00f, -1.0f, -1.0f};
WP WP::ClearNoon = { 15.0f, 0.0f, 0.0f, 0.35f, 0.0f, 75.0f};
WP WP::CloudyNoon = { 80.0f, 0.0f, 0.0f, 0.35f, 0.0f, 75.0f};
WP WP::WetNoon = { 20.0f, 0.0f, 50.0f, 0.35f, 0.0f, 75.0f};
WP WP::WetCloudyNoon = { 80.0f, 0.0f, 50.0f, 0.35f, 0.0f, 75.0f};
WP WP::MidRainyNoon = { 80.0f, 30.0f, 50.0f, 0.40f, 0.0f, 75.0f};
WP WP::HardRainNoon = { 90.0f, 60.0f, 100.0f, 1.00f, 0.0f, 75.0f};
WP WP::SoftRainNoon = { 70.0f, 15.0f, 50.0f, 0.35f, 0.0f, 75.0f};
WP WP::ClearSunset = { 15.0f, 0.0f, 0.0f, 0.35f, 0.0f, 15.0f};
WP WP::CloudySunset = { 80.0f, 0.0f, 0.0f, 0.35f, 0.0f, 15.0f};
WP WP::WetSunset = { 20.0f, 0.0f, 50.0f, 0.35f, 0.0f, 15.0f};
WP WP::WetCloudySunset = { 90.0f, 0.0f, 50.0f, 0.35f, 0.0f, 15.0f};
WP WP::MidRainSunset = { 80.0f, 30.0f, 50.0f, 0.40f, 0.0f, 15.0f};
WP WP::HardRainSunset = { 80.0f, 60.0f, 100.0f, 1.00f, 0.0f, 15.0f};
WP WP::SoftRainSunset = { 90.0f, 15.0f, 50.0f, 0.35f, 0.0f, 15.0f};
// cloudiness precip. prec.dep. wind azimuth altitude fog dens. fog dist wetness
WP WP::Default = { -1.0f, -1.0f, -1.0f, -1.00f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f};
WP WP::ClearNoon = { 15.0f, 0.0f, 0.0f, 0.35f, 0.0f, 75.0f, 0.0f, 0.0f, 0.0f};
WP WP::CloudyNoon = { 80.0f, 0.0f, 0.0f, 0.35f, 0.0f, 75.0f, 0.0f, 0.0f, 0.0f};
WP WP::WetNoon = { 20.0f, 0.0f, 50.0f, 0.35f, 0.0f, 75.0f, 0.0f, 0.0f, 0.0f};
WP WP::WetCloudyNoon = { 80.0f, 0.0f, 50.0f, 0.35f, 0.0f, 75.0f, 0.0f, 0.0f, 0.0f};
WP WP::MidRainyNoon = { 80.0f, 30.0f, 50.0f, 0.40f, 0.0f, 75.0f, 0.0f, 0.0f, 0.0f};
WP WP::HardRainNoon = { 90.0f, 60.0f, 100.0f, 1.00f, 0.0f, 75.0f, 0.0f, 0.0f, 0.0f};
WP WP::SoftRainNoon = { 70.0f, 15.0f, 50.0f, 0.35f, 0.0f, 75.0f, 0.0f, 0.0f, 0.0f};
WP WP::ClearSunset = { 15.0f, 0.0f, 0.0f, 0.35f, 0.0f, 15.0f, 0.0f, 0.0f, 0.0f};
WP WP::CloudySunset = { 80.0f, 0.0f, 0.0f, 0.35f, 0.0f, 15.0f, 0.0f, 0.0f, 0.0f};
WP WP::WetSunset = { 20.0f, 0.0f, 50.0f, 0.35f, 0.0f, 15.0f, 0.0f, 0.0f, 0.0f};
WP WP::WetCloudySunset = { 90.0f, 0.0f, 50.0f, 0.35f, 0.0f, 15.0f, 0.0f, 0.0f, 0.0f};
WP WP::MidRainSunset = { 80.0f, 30.0f, 50.0f, 0.40f, 0.0f, 15.0f, 0.0f, 0.0f, 0.0f};
WP WP::HardRainSunset = { 80.0f, 60.0f, 100.0f, 1.00f, 0.0f, 15.0f, 0.0f, 0.0f, 0.0f};
WP WP::SoftRainSunset = { 90.0f, 15.0f, 50.0f, 0.35f, 0.0f, 15.0f, 0.0f, 0.0f, 0.0f};
} // namespace rpc
} // namespace carla

View File

@ -42,44 +42,59 @@ namespace rpc {
WeatherParameters() = default;
WeatherParameters(
float in_cloudyness,
float in_cloudiness,
float in_precipitation,
float in_precipitation_deposits,
float in_wind_intensity,
float in_sun_azimuth_angle,
float in_sun_altitude_angle)
: cloudyness(in_cloudyness),
float in_sun_altitude_angle,
float in_fog_density,
float in_fog_distance,
float in_wetness)
: cloudiness(in_cloudiness),
precipitation(in_precipitation),
precipitation_deposits(in_precipitation_deposits),
wind_intensity(in_wind_intensity),
sun_azimuth_angle(in_sun_azimuth_angle),
sun_altitude_angle(in_sun_altitude_angle) {}
sun_altitude_angle(in_sun_altitude_angle),
fog_density(in_fog_density),
fog_distance(in_fog_distance),
wetness(in_wetness) {}
float cloudyness = 0.0f;
float cloudiness = 0.0f;
float precipitation = 0.0f;
float precipitation_deposits = 0.0f;
float wind_intensity = 0.0f;
float sun_azimuth_angle = 0.0f;
float sun_altitude_angle = 0.0f;
float fog_density = 0.0f;
float fog_distance = 0.0f;
float wetness = 0.0f;
#ifdef LIBCARLA_INCLUDED_FROM_UE4
WeatherParameters(const FWeatherParameters &Weather)
: cloudyness(Weather.Cloudyness),
: cloudiness(Weather.Cloudiness),
precipitation(Weather.Precipitation),
precipitation_deposits(Weather.PrecipitationDeposits),
wind_intensity(Weather.WindIntensity),
sun_azimuth_angle(Weather.SunAzimuthAngle),
sun_altitude_angle(Weather.SunAltitudeAngle) {}
sun_altitude_angle(Weather.SunAltitudeAngle),
fog_density(Weather.FogDensity),
fog_distance(Weather.FogDistance),
wetness(Weather.Wetness) {}
operator FWeatherParameters() const {
FWeatherParameters Weather;
Weather.Cloudyness = cloudyness;
Weather.Cloudiness = cloudiness;
Weather.Precipitation = precipitation;
Weather.PrecipitationDeposits = precipitation_deposits;
Weather.WindIntensity = wind_intensity;
Weather.SunAzimuthAngle = sun_azimuth_angle;
Weather.SunAltitudeAngle = sun_altitude_angle;
Weather.FogDensity = fog_density;
Weather.FogDistance = fog_distance;
Weather.Wetness = wetness;
return Weather;
}
@ -87,12 +102,15 @@ namespace rpc {
bool operator!=(const WeatherParameters &rhs) const {
return
cloudyness != rhs.cloudyness ||
cloudiness != rhs.cloudiness ||
precipitation != rhs.precipitation ||
precipitation_deposits != rhs.precipitation_deposits ||
wind_intensity != rhs.wind_intensity ||
sun_azimuth_angle != rhs.sun_azimuth_angle ||
sun_altitude_angle != rhs.sun_altitude_angle;
sun_altitude_angle != rhs.sun_altitude_angle ||
fog_density != rhs.fog_density ||
fog_distance != rhs.fog_distance ||
wetness != rhs.wetness;
}
bool operator==(const WeatherParameters &rhs) const {
@ -100,12 +118,15 @@ namespace rpc {
}
MSGPACK_DEFINE_ARRAY(
cloudyness,
cloudiness,
precipitation,
precipitation_deposits,
wind_intensity,
sun_azimuth_angle,
sun_altitude_angle);
sun_altitude_angle,
fog_density,
fog_distance,
wetness);
};
} // namespace rpc

View File

@ -12,7 +12,7 @@ namespace carla {
namespace rpc {
std::ostream &operator<<(std::ostream &out, const WeatherParameters &weather) {
out << "WeatherParameters(cloudyness=" << std::to_string(weather.cloudyness)
out << "WeatherParameters(cloudiness=" << std::to_string(weather.cloudiness)
<< ", precipitation=" << std::to_string(weather.precipitation)
<< ", precipitation_deposits=" << std::to_string(weather.precipitation_deposits)
<< ", wind_intensity=" << std::to_string(weather.wind_intensity)
@ -29,19 +29,25 @@ void export_weather() {
namespace cr = carla::rpc;
auto cls = class_<cr::WeatherParameters>("WeatherParameters")
.def(init<float, float, float, float, float, float>(
(arg("cloudyness")=0.0f,
.def(init<float, float, float, float, float, float, float, float, float>(
(arg("cloudiness")=0.0f,
arg("precipitation")=0.0f,
arg("precipitation_deposits")=0.0f,
arg("wind_intensity")=0.0f,
arg("sun_azimuth_angle")=0.0f,
arg("sun_altitude_angle")=0.0f)))
.def_readwrite("cloudyness", &cr::WeatherParameters::cloudyness)
arg("sun_altitude_angle")=0.0f,
arg("fog_density")=0.0f,
arg("fog_distance")=0.0f,
arg("wetness")=0.0f)))
.def_readwrite("cloudiness", &cr::WeatherParameters::cloudiness)
.def_readwrite("precipitation", &cr::WeatherParameters::precipitation)
.def_readwrite("precipitation_deposits", &cr::WeatherParameters::precipitation_deposits)
.def_readwrite("wind_intensity", &cr::WeatherParameters::wind_intensity)
.def_readwrite("sun_azimuth_angle", &cr::WeatherParameters::sun_azimuth_angle)
.def_readwrite("sun_altitude_angle", &cr::WeatherParameters::sun_altitude_angle)
.def_readwrite("fog_density", &cr::WeatherParameters::fog_density)
.def_readwrite("fog_distance", &cr::WeatherParameters::fog_distance)
.def_readwrite("wetness", &cr::WeatherParameters::wetness)
.def("__eq__", &cr::WeatherParameters::operator==)
.def("__ne__", &cr::WeatherParameters::operator!=)
.def(self_ns::str(self_ns::self))

View File

@ -87,7 +87,7 @@ class Weather(object):
def tick(self, delta_seconds):
self._sun.tick(delta_seconds)
self._storm.tick(delta_seconds)
self.weather.cloudyness = self._storm.clouds
self.weather.cloudiness = self._storm.clouds
self.weather.precipitation = self._storm.rain
self.weather.precipitation_deposits = self._storm.puddles
self.weather.wind_intensity = self._storm.wind

View File

@ -20,12 +20,15 @@ void AWeather::ApplyWeather(const FWeatherParameters &InWeather)
#ifdef CARLA_WEATHER_EXTRA_LOG
UE_LOG(LogCarla, Log, TEXT("Changing weather:"));
UE_LOG(LogCarla, Log, TEXT(" - Cloudyness = %.2f"), Weather.Cloudyness);
UE_LOG(LogCarla, Log, TEXT(" - Cloudiness = %.2f"), Weather.Cloudiness);
UE_LOG(LogCarla, Log, TEXT(" - Precipitation = %.2f"), Weather.Precipitation);
UE_LOG(LogCarla, Log, TEXT(" - PrecipitationDeposits = %.2f"), Weather.PrecipitationDeposits);
UE_LOG(LogCarla, Log, TEXT(" - WindIntensity = %.2f"), Weather.WindIntensity);
UE_LOG(LogCarla, Log, TEXT(" - SunAzimuthAngle = %.2f"), Weather.SunAzimuthAngle);
UE_LOG(LogCarla, Log, TEXT(" - SunAltitudeAngle = %.2f"), Weather.SunAltitudeAngle);
UE_LOG(LogCarla, Log, TEXT(" - FogDensity = %.2f"), Weather.FogDensity);
UE_LOG(LogCarla, Log, TEXT(" - FogDistance = %.2f"), Weather.FogDistance);
UE_LOG(LogCarla, Log, TEXT(" - Wetness = %.2f"), Weather.Wetness);
#endif // CARLA_WEATHER_EXTRA_LOG
// Call the blueprint that actually changes the weather.

View File

@ -14,7 +14,7 @@ struct CARLA_API FWeatherParameters
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0"))
float Cloudyness = 0.0f;
float Cloudiness = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0"))
float Precipitation = 0.0f;
@ -30,4 +30,13 @@ struct CARLA_API FWeatherParameters
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "-90.0", ClampMax = "90.0", UIMin = "-90.0", UIMax = "90.0"))
float SunAltitudeAngle = 75.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0"))
float FogDensity = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", UIMin = "0.0", UIMax = "1000.0"))
float FogDistance = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0"))
float Wetness = 0.0f;
};