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 `NormalsSensor`, a new sensor with normals information
|
||||||
* Added support for N wheeled vehicles
|
* Added support for N wheeled vehicles
|
||||||
* Added support for new batch commands ConsoleCommand, ApplyLocation (to actor), SetTrafficLightState
|
* 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
|
* Switch to boost::variant2 for rpc::Command as that allows more than 20 RPC commands
|
||||||
* Added post process effects for rainy and dusty weathers.
|
* 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:**
|
- **Parameters:**
|
||||||
- `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed.
|
- `lights` (_list([carla.Light](#carla.Light))_) - List of lights to be changed.
|
||||||
- `colors` (_list([carla.Color](#carla.Color))_) - List of colors to be applied.
|
- `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>)
|
- <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`.
|
Changes the intensity of each element in `lights` to the corresponding in `intensities`.
|
||||||
- **Parameters:**
|
- **Parameters:**
|
||||||
|
@ -4454,4 +4458,4 @@ for (let i = 0; i < buttons.length; i++) {
|
||||||
buttons[i].addEventListener("click",function(){ButtonAction(buttons[i].id);},true);
|
buttons[i].addEventListener("click",function(){ButtonAction(buttons[i].id);},true);
|
||||||
}
|
}
|
||||||
window.onresize = WindowResize;
|
window.onresize = WindowResize;
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -321,5 +321,9 @@ void LightManager::ApplyChanges() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LightManager::SetDayNightCycle(const bool active) {
|
||||||
|
_episode.Lock()->UpdateDayNightCycle(active);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace client
|
} // namespace client
|
||||||
} // namespace carla
|
} // namespace carla
|
||||||
|
|
|
@ -84,6 +84,8 @@ public:
|
||||||
void SetLightState(LightId id, const LightState& new_state);
|
void SetLightState(LightId id, const LightState& new_state);
|
||||||
void SetLightGroup(LightId id, LightGroup group);
|
void SetLightGroup(LightId id, LightGroup group);
|
||||||
|
|
||||||
|
void SetDayNightCycle(const bool active);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const LightState& RetrieveLightState(LightId id) const;
|
const LightState& RetrieveLightState(LightId id) const;
|
||||||
|
|
|
@ -610,6 +610,10 @@ namespace detail {
|
||||||
_pimpl->AsyncCall("update_lights_state", _pimpl->endpoint, std::move(lights), discard_client);
|
_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 {
|
std::vector<geom::BoundingBox> Client::GetLevelBBs(uint8_t queried_tag) const {
|
||||||
using return_t = std::vector<geom::BoundingBox>;
|
using return_t = std::vector<geom::BoundingBox>;
|
||||||
return _pimpl->CallAndWait<return_t>("get_all_level_BBs", queried_tag);
|
return _pimpl->CallAndWait<return_t>("get_all_level_BBs", queried_tag);
|
||||||
|
|
|
@ -302,7 +302,7 @@ namespace detail {
|
||||||
const rpc::WalkerBoneControlIn &bones);
|
const rpc::WalkerBoneControlIn &bones);
|
||||||
|
|
||||||
void BlendPose(
|
void BlendPose(
|
||||||
rpc::ActorId walker,
|
rpc::ActorId walker,
|
||||||
float blend);
|
float blend);
|
||||||
|
|
||||||
void GetPoseFromAnimation(
|
void GetPoseFromAnimation(
|
||||||
|
@ -388,6 +388,8 @@ namespace detail {
|
||||||
std::vector<rpc::LightState>& lights,
|
std::vector<rpc::LightState>& lights,
|
||||||
bool discard_client = false) const;
|
bool discard_client = false) const;
|
||||||
|
|
||||||
|
void UpdateDayNightCycle(const bool active) const;
|
||||||
|
|
||||||
/// Returns all the BBs of all the elements of the level
|
/// Returns all the BBs of all the elements of the level
|
||||||
std::vector<geom::BoundingBox> GetLevelBBs(uint8_t queried_tag) const;
|
std::vector<geom::BoundingBox> GetLevelBBs(uint8_t queried_tag) const;
|
||||||
|
|
||||||
|
|
|
@ -678,6 +678,10 @@ namespace detail {
|
||||||
_client.UpdateServerLightsState(lights, discard_client);
|
_client.UpdateServerLightsState(lights, discard_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateDayNightCycle(const bool active) const {
|
||||||
|
_client.UpdateDayNightCycle(active);
|
||||||
|
}
|
||||||
|
|
||||||
size_t RegisterLightUpdateChangeEvent(std::function<void(WorldSnapshot)> callback) {
|
size_t RegisterLightUpdateChangeEvent(std::function<void(WorldSnapshot)> callback) {
|
||||||
DEBUG_ASSERT(_episode != nullptr);
|
DEBUG_ASSERT(_episode != nullptr);
|
||||||
return _episode->RegisterLightUpdateChangeEvent(std::move(callback));
|
return _episode->RegisterLightUpdateChangeEvent(std::move(callback));
|
||||||
|
|
|
@ -288,6 +288,12 @@ static boost::python::list LightManagerGetLightState(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void LightManagerSetDayNightCycle(
|
||||||
|
cc::LightManager& self,
|
||||||
|
const bool active) {
|
||||||
|
self.SetDayNightCycle(active);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************/
|
/*******************/
|
||||||
|
|
||||||
void export_lightmanager() {
|
void export_lightmanager() {
|
||||||
|
@ -345,6 +351,7 @@ void export_lightmanager() {
|
||||||
.def("set_light_state", &LightManagerSetLightState, (arg("lights"), arg("light_state")))
|
.def("set_light_state", &LightManagerSetLightState, (arg("lights"), arg("light_state")))
|
||||||
.def("set_light_states", &LightManagerSetVectorLightState, (arg("lights"), arg("light_states")))
|
.def("set_light_states", &LightManagerSetVectorLightState, (arg("lights"), arg("light_states")))
|
||||||
.def("get_light_state", &LightManagerGetLightState, (arg("lights")))
|
.def("get_light_state", &LightManagerGetLightState, (arg("lights")))
|
||||||
|
.def("set_day_night_cycle", &LightManagerSetDayNightCycle, (arg("active")))
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,3 +388,12 @@
|
||||||
doc:
|
doc:
|
||||||
List of state of the attributes to be applied.
|
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>.
|
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||||
|
|
||||||
#include "CarlaLightSubsystem.h"
|
#include "CarlaLightSubsystem.h"
|
||||||
|
#include "Carla/Weather/Weather.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
//using cr = carla::rpc;
|
//using cr = carla::rpc;
|
||||||
|
|
||||||
|
@ -100,6 +102,19 @@ UCarlaLight* UCarlaLightSubsystem::GetLight(int Id)
|
||||||
return nullptr;
|
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)
|
void UCarlaLightSubsystem::SetClientStatesdirty(FString ClientThatUpdate)
|
||||||
{
|
{
|
||||||
for(auto& Client : ClientStates)
|
for(auto& Client : ClientStates)
|
||||||
|
|
|
@ -61,6 +61,9 @@ public:
|
||||||
{
|
{
|
||||||
return Lights;
|
return Lights;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetDayNightCycle(const bool active);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void SetClientStatesdirty(FString ClientThatUpdate);
|
void SetClientStatesdirty(FString ClientThatUpdate);
|
||||||
|
|
|
@ -1499,9 +1499,9 @@ void FCarlaServer::FPimpl::BindActions()
|
||||||
Response,
|
Response,
|
||||||
" Actor Id: " + FString::FromInt(ActorId));
|
" Actor Id: " + FString::FromInt(ActorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<carla::rpc::BoneTransformDataOut> BoneData;
|
std::vector<carla::rpc::BoneTransformDataOut> BoneData;
|
||||||
for (auto Bone : Bones.BoneTransforms)
|
for (auto Bone : Bones.BoneTransforms)
|
||||||
{
|
{
|
||||||
carla::rpc::BoneTransformDataOut Data;
|
carla::rpc::BoneTransformDataOut Data;
|
||||||
Data.bone_name = std::string(TCHAR_TO_UTF8(*Bone.Get<0>()));
|
Data.bone_name = std::string(TCHAR_TO_UTF8(*Bone.Get<0>()));
|
||||||
|
@ -1537,7 +1537,7 @@ void FCarlaServer::FPimpl::BindActions()
|
||||||
Response,
|
Response,
|
||||||
" Actor Id: " + FString::FromInt(ActorId));
|
" Actor Id: " + FString::FromInt(ActorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return R<void>::Success();
|
return R<void>::Success();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1563,7 +1563,7 @@ void FCarlaServer::FPimpl::BindActions()
|
||||||
Response,
|
Response,
|
||||||
" Actor Id: " + FString::FromInt(ActorId));
|
" Actor Id: " + FString::FromInt(ActorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return R<void>::Success();
|
return R<void>::Success();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1588,7 +1588,7 @@ void FCarlaServer::FPimpl::BindActions()
|
||||||
Response,
|
Response,
|
||||||
" Actor Id: " + FString::FromInt(ActorId));
|
" Actor Id: " + FString::FromInt(ActorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return R<void>::Success();
|
return R<void>::Success();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2212,6 +2212,18 @@ void FCarlaServer::FPimpl::BindActions()
|
||||||
return R<void>::Success();
|
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~ Ray Casting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -49,3 +49,8 @@ void AWeather::SetWeather(const FWeatherParameters &InWeather)
|
||||||
{
|
{
|
||||||
Weather = InWeather;
|
Weather = InWeather;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AWeather::SetDayNightCycle(const bool &active)
|
||||||
|
{
|
||||||
|
DayNightCycle = active;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,16 @@ public:
|
||||||
return Weather;
|
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:
|
protected:
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
|
@ -48,4 +58,7 @@ private:
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY(VisibleAnywhere)
|
||||||
FWeatherParameters Weather;
|
FWeatherParameters Weather;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Weather")
|
||||||
|
bool DayNightCycle = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,4 +36,4 @@
|
||||||
0.9.11: 20201222_232b876
|
0.9.11: 20201222_232b876
|
||||||
0.9.12: 20210730_564bcdc
|
0.9.12: 20210730_564bcdc
|
||||||
0.9.13: 20211112_d5cfa12
|
0.9.13: 20211112_d5cfa12
|
||||||
Latest: 20220404_1730439
|
Latest: 20220412_75d259d
|
||||||
|
|
Loading…
Reference in New Issue