Added reset all traffic lights function.

This commit is contained in:
Axel 2020-09-21 18:09:54 +02:00 committed by Axel1092
parent f1dd2d77fa
commit a75fc59eb0
7 changed files with 27 additions and 0 deletions

View File

@ -150,6 +150,10 @@ namespace client {
return nullptr;
}
void World::ResetAllTrafficLights() {
_episode.Lock()->ResetAllTrafficLights();
}
SharedPtr<LightManager> World::GetLightManager() const {
return _episode.Lock()->GetLightManager();
}

View File

@ -138,6 +138,8 @@ namespace client {
SharedPtr<Actor> GetTrafficLight(const Landmark& landmark) const;
void ResetAllTrafficLights();
SharedPtr<LightManager> GetLightManager() const;
DebugHelper MakeDebugHelper() const {

View File

@ -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);
}

View File

@ -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

View File

@ -473,6 +473,10 @@ namespace detail {
_client.ResetTrafficLightGroup(trafficLight.GetId());
}
void ResetAllTrafficLights() {
_client.ResetAllTrafficLights();
}
std::vector<ActorId> GetGroupTrafficLights(TrafficLight &trafficLight) {
return _client.GetGroupTrafficLights(trafficLight.GetId());
}

View File

@ -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))

View File

@ -906,6 +906,16 @@ void FCarlaServer::FPimpl::BindActions()
return R<void>::Success();
};
BIND_SYNC(reset_all_traffic_lights) << [this]() -> R<void>
{
REQUIRE_CARLA_EPISODE();
for (TActorIterator<ATrafficLightGroup> It(Episode->GetWorld()); It; ++It)
{
It->ResetGroup();
}
return R<void>::Success();
};
BIND_SYNC(freeze_all_traffic_lights) << [this]
(bool frozen) -> R<void>
{