Added set_day_night_cycle parameter (#5322)
This commit is contained in:
parent
467d984a9a
commit
8d5204e048
|
@ -13,6 +13,7 @@
|
|||
* Added `NormalsSensor`, a new sensor with normals information
|
||||
* Added support for N wheeled vehicles
|
||||
* Added support for new batch commands ConsoleCommand, ApplyLocation (to actor), SetTrafficLightState
|
||||
* 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.
|
||||
|
||||
|
|
|
@ -1374,6 +1374,10 @@ Changes the color of each element in `lights` to the corresponding in `colors`.
|
|||
- **Parameters:**
|
||||
- `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed.
|
||||
- `colors` (_list([carla.Color](#carla.Color))_) - List of colors to be applied.
|
||||
- <a name="carla.LightManager.set_day_night_cycle"></a>**<font color="#7fb800">set_day_night_cycle</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**active**</font>)
|
||||
All scene lights have a day-night cycle, automatically turning on and off with the altitude of the sun. This interferes in cases where full control of the scene lights is required, so setting this to __False__ deactivates it. It can reactivated by setting it to __True__.
|
||||
- **Parameters:**
|
||||
- `active` (_bool_) - (De)activation of the day-night cycle.
|
||||
- <a name="carla.LightManager.set_intensities"></a>**<font color="#7fb800">set_intensities</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**lights**</font>, <font color="#00a6ed">**intensities**</font>)
|
||||
Changes the intensity of each element in `lights` to the corresponding in `intensities`.
|
||||
- **Parameters:**
|
||||
|
|
|
@ -321,5 +321,9 @@ void LightManager::ApplyChanges() {
|
|||
}
|
||||
}
|
||||
|
||||
void LightManager::SetDayNightCycle(const bool active) {
|
||||
_episode.Lock()->UpdateDayNightCycle(active);
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
} // namespace carla
|
||||
|
|
|
@ -84,6 +84,8 @@ public:
|
|||
void SetLightState(LightId id, const LightState& new_state);
|
||||
void SetLightGroup(LightId id, LightGroup group);
|
||||
|
||||
void SetDayNightCycle(const bool active);
|
||||
|
||||
private:
|
||||
|
||||
const LightState& RetrieveLightState(LightId id) const;
|
||||
|
|
|
@ -610,6 +610,10 @@ namespace detail {
|
|||
_pimpl->AsyncCall("update_lights_state", _pimpl->endpoint, std::move(lights), discard_client);
|
||||
}
|
||||
|
||||
void Client::UpdateDayNightCycle(const bool active) const {
|
||||
_pimpl->AsyncCall("update_day_night_cycle", _pimpl->endpoint, active);
|
||||
}
|
||||
|
||||
std::vector<geom::BoundingBox> Client::GetLevelBBs(uint8_t queried_tag) const {
|
||||
using return_t = std::vector<geom::BoundingBox>;
|
||||
return _pimpl->CallAndWait<return_t>("get_all_level_BBs", queried_tag);
|
||||
|
|
|
@ -388,6 +388,8 @@ namespace detail {
|
|||
std::vector<rpc::LightState>& lights,
|
||||
bool discard_client = false) const;
|
||||
|
||||
void UpdateDayNightCycle(const bool active) const;
|
||||
|
||||
/// Returns all the BBs of all the elements of the level
|
||||
std::vector<geom::BoundingBox> GetLevelBBs(uint8_t queried_tag) const;
|
||||
|
||||
|
|
|
@ -678,6 +678,10 @@ namespace detail {
|
|||
_client.UpdateServerLightsState(lights, discard_client);
|
||||
}
|
||||
|
||||
void UpdateDayNightCycle(const bool active) const {
|
||||
_client.UpdateDayNightCycle(active);
|
||||
}
|
||||
|
||||
size_t RegisterLightUpdateChangeEvent(std::function<void(WorldSnapshot)> callback) {
|
||||
DEBUG_ASSERT(_episode != nullptr);
|
||||
return _episode->RegisterLightUpdateChangeEvent(std::move(callback));
|
||||
|
|
|
@ -288,6 +288,12 @@ static boost::python::list LightManagerGetLightState(
|
|||
return result;
|
||||
}
|
||||
|
||||
static void LightManagerSetDayNightCycle(
|
||||
cc::LightManager& self,
|
||||
const bool active) {
|
||||
self.SetDayNightCycle(active);
|
||||
}
|
||||
|
||||
/*******************/
|
||||
|
||||
void export_lightmanager() {
|
||||
|
@ -345,6 +351,7 @@ void export_lightmanager() {
|
|||
.def("set_light_state", &LightManagerSetLightState, (arg("lights"), arg("light_state")))
|
||||
.def("set_light_states", &LightManagerSetVectorLightState, (arg("lights"), arg("light_states")))
|
||||
.def("get_light_state", &LightManagerGetLightState, (arg("lights")))
|
||||
.def("set_day_night_cycle", &LightManagerSetDayNightCycle, (arg("active")))
|
||||
;
|
||||
|
||||
}
|
||||
|
|
|
@ -388,3 +388,12 @@
|
|||
doc:
|
||||
List of state of the attributes to be applied.
|
||||
# --------------------------------------
|
||||
- def_name: set_day_night_cycle
|
||||
doc: >
|
||||
All scene lights have a day-night cycle, automatically turning on and off with the altitude of the sun. This interferes in cases where full control of the scene lights is required, so setting this to __False__ deactivates it. It can reactivated by setting it to __True__.
|
||||
params:
|
||||
- param_name: active
|
||||
type: bool
|
||||
doc:
|
||||
(De)activation of the day-night cycle.
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "CarlaLightSubsystem.h"
|
||||
#include "Carla/Weather/Weather.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
//using cr = carla::rpc;
|
||||
|
||||
|
@ -100,6 +102,19 @@ UCarlaLight* UCarlaLightSubsystem::GetLight(int Id)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void UCarlaLightSubsystem::SetDayNightCycle(const bool active) {
|
||||
TArray<AActor*> WeatherActors;
|
||||
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AWeather::StaticClass(), WeatherActors);
|
||||
if (WeatherActors.Num())
|
||||
{
|
||||
if (AWeather* WeatherActor = Cast<AWeather>(WeatherActors[0]))
|
||||
{
|
||||
WeatherActor->SetDayNightCycle(active);
|
||||
}
|
||||
}
|
||||
std::cout << "Calling the server weather to change the day night cycle to " << active << std::endl;
|
||||
}
|
||||
|
||||
void UCarlaLightSubsystem::SetClientStatesdirty(FString ClientThatUpdate)
|
||||
{
|
||||
for(auto& Client : ClientStates)
|
||||
|
|
|
@ -61,6 +61,9 @@ public:
|
|||
{
|
||||
return Lights;
|
||||
}
|
||||
|
||||
void SetDayNightCycle(const bool active);
|
||||
|
||||
private:
|
||||
|
||||
void SetClientStatesdirty(FString ClientThatUpdate);
|
||||
|
|
|
@ -2212,6 +2212,18 @@ void FCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
};
|
||||
|
||||
BIND_SYNC(update_day_night_cycle) << [this]
|
||||
(std::string client, const bool active) -> R<void>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
auto *World = Episode->GetWorld();
|
||||
if(World) {
|
||||
UCarlaLightSubsystem* CarlaLightSubsystem = World->GetSubsystem<UCarlaLightSubsystem>();
|
||||
CarlaLightSubsystem->SetDayNightCycle(active);
|
||||
}
|
||||
return R<void>::Success();
|
||||
};
|
||||
|
||||
|
||||
// ~~ Ray Casting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -49,3 +49,8 @@ void AWeather::SetWeather(const FWeatherParameters &InWeather)
|
|||
{
|
||||
Weather = InWeather;
|
||||
}
|
||||
|
||||
void AWeather::SetDayNightCycle(const bool &active)
|
||||
{
|
||||
DayNightCycle = active;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,16 @@ public:
|
|||
return Weather;
|
||||
}
|
||||
|
||||
/// Returns whether the day night cycle is active (automatic on/off switch when changin to night mode)
|
||||
UFUNCTION(BlueprintCallable)
|
||||
const bool &GetDayNightCycle() const
|
||||
{
|
||||
return DayNightCycle;
|
||||
}
|
||||
|
||||
/// Update the day night cycle
|
||||
void SetDayNightCycle(const bool &active);
|
||||
|
||||
protected:
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
|
@ -48,4 +58,7 @@ private:
|
|||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
FWeatherParameters Weather;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Weather")
|
||||
bool DayNightCycle = true;
|
||||
};
|
||||
|
|
|
@ -36,4 +36,4 @@
|
|||
0.9.11: 20201222_232b876
|
||||
0.9.12: 20210730_564bcdc
|
||||
0.9.13: 20211112_d5cfa12
|
||||
Latest: 20220404_1730439
|
||||
Latest: 20220412_75d259d
|
||||
|
|
Loading…
Reference in New Issue