diff --git a/LibCarla/source/carla/client/World.cpp b/LibCarla/source/carla/client/World.cpp index df477cbab..bb11f89d2 100644 --- a/LibCarla/source/carla/client/World.cpp +++ b/LibCarla/source/carla/client/World.cpp @@ -150,6 +150,10 @@ namespace client { return nullptr; } + void World::ResetAllTrafficLights() { + _episode.Lock()->ResetAllTrafficLights(); + } + SharedPtr World::GetLightManager() const { return _episode.Lock()->GetLightManager(); } diff --git a/LibCarla/source/carla/client/World.h b/LibCarla/source/carla/client/World.h index 41086e19f..981598b37 100644 --- a/LibCarla/source/carla/client/World.h +++ b/LibCarla/source/carla/client/World.h @@ -138,6 +138,8 @@ namespace client { SharedPtr GetTrafficLight(const Landmark& landmark) const; + void ResetAllTrafficLights(); + SharedPtr GetLightManager() const; DebugHelper MakeDebugHelper() const { diff --git a/LibCarla/source/carla/client/detail/Client.cpp b/LibCarla/source/carla/client/detail/Client.cpp index 5859cf870..a415ef048 100644 --- a/LibCarla/source/carla/client/detail/Client.cpp +++ b/LibCarla/source/carla/client/detail/Client.cpp @@ -326,6 +326,10 @@ namespace detail { _pimpl->AsyncCall("reset_traffic_light_group", traffic_light); } + void Client::ResetAllTrafficLights() { + _pimpl->AsyncCall("reset_all_traffic_lights"); + } + void Client::FreezeAllTrafficLights(bool frozen) { _pimpl->AsyncCall("freeze_all_traffic_lights", frozen); } diff --git a/LibCarla/source/carla/client/detail/Client.h b/LibCarla/source/carla/client/detail/Client.h index 45d3d96ac..b8ed9fb50 100644 --- a/LibCarla/source/carla/client/detail/Client.h +++ b/LibCarla/source/carla/client/detail/Client.h @@ -205,6 +205,8 @@ namespace detail { void ResetTrafficLightGroup( rpc::ActorId traffic_light); + void ResetAllTrafficLights(); + void FreezeAllTrafficLights(bool frozen); /// Returns a list of pairs where the firts element is the vehicle ID diff --git a/LibCarla/source/carla/client/detail/Simulator.h b/LibCarla/source/carla/client/detail/Simulator.h index 2243f4216..36c14e0c6 100644 --- a/LibCarla/source/carla/client/detail/Simulator.h +++ b/LibCarla/source/carla/client/detail/Simulator.h @@ -473,6 +473,10 @@ namespace detail { _client.ResetTrafficLightGroup(trafficLight.GetId()); } + void ResetAllTrafficLights() { + _client.ResetAllTrafficLights(); + } + std::vector GetGroupTrafficLights(TrafficLight &trafficLight) { return _client.GetGroupTrafficLights(trafficLight.GetId()); } diff --git a/PythonAPI/carla/source/libcarla/World.cpp b/PythonAPI/carla/source/libcarla/World.cpp index 387efb605..d5ca4df28 100644 --- a/PythonAPI/carla/source/libcarla/World.cpp +++ b/PythonAPI/carla/source/libcarla/World.cpp @@ -202,6 +202,7 @@ void export_world() { .def("set_pedestrians_cross_factor", CALL_WITHOUT_GIL_1(cc::World, SetPedestriansCrossFactor, float), (arg("percentage"))) .def("get_traffic_sign", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficSign, cc::Landmark), arg("landmark")) .def("get_traffic_light", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficLight, cc::Landmark), arg("landmark")) + .def("reset_all_traffic_lights", &cc::World::ResetAllTrafficLights) .def("get_lightmanager", CONST_CALL_WITHOUT_GIL(cc::World, GetLightManager)) .def("freeze_all_traffic_lights", &cc::World::FreezeAllTrafficLights, (arg("frozen"))) .def("get_level_bbs", &GetLevelBBs, (arg("actor_type")=cr::CityObjectLabel::None)) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp index 6ce07a0b9..a4ff229f6 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp @@ -906,6 +906,16 @@ void FCarlaServer::FPimpl::BindActions() return R::Success(); }; + BIND_SYNC(reset_all_traffic_lights) << [this]() -> R + { + REQUIRE_CARLA_EPISODE(); + for (TActorIterator It(Episode->GetWorld()); It; ++It) + { + It->ResetGroup(); + } + return R::Success(); + }; + BIND_SYNC(freeze_all_traffic_lights) << [this] (bool frozen) -> R {