Added reset group function to API.
This commit is contained in:
parent
5ccaa39d60
commit
07d016d318
|
@ -70,5 +70,9 @@ namespace client {
|
|||
return result;
|
||||
}
|
||||
|
||||
void TrafficLight::ResetGroup() {
|
||||
GetEpisode().Lock()->ResetTrafficLightGroup(*this);
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
} // namespace carla
|
||||
|
|
|
@ -62,6 +62,9 @@ namespace client {
|
|||
/// @note This function calls the simulator
|
||||
std::vector<SharedPtr<TrafficLight>> GetGroupTrafficLights();
|
||||
|
||||
// resets the timers and states of all groups
|
||||
void ResetGroup();
|
||||
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
|
|
@ -322,6 +322,10 @@ namespace detail {
|
|||
_pimpl->AsyncCall("freeze_traffic_light", traffic_light, freeze);
|
||||
}
|
||||
|
||||
void Client::ResetTrafficLightGroup(rpc::ActorId traffic_light) {
|
||||
_pimpl->AsyncCall("reset_traffic_light_group", traffic_light);
|
||||
}
|
||||
|
||||
rpc::VehicleLightStateList Client::GetVehiclesLightStates() {
|
||||
return _pimpl->CallAndWait<std::vector<std::pair<carla::ActorId, uint32_t>>>("get_vehicle_light_states");
|
||||
}
|
||||
|
|
|
@ -202,6 +202,9 @@ namespace detail {
|
|||
rpc::ActorId traffic_light,
|
||||
bool freeze);
|
||||
|
||||
void ResetTrafficLightGroup(
|
||||
rpc::ActorId traffic_light);
|
||||
|
||||
/// Returns a list of pairs where the firts element is the vehicle ID
|
||||
/// and the second one is the light state
|
||||
rpc::VehicleLightStateList GetVehiclesLightStates();
|
||||
|
|
|
@ -460,6 +460,10 @@ namespace detail {
|
|||
_client.FreezeTrafficLight(trafficLight.GetId(), freeze);
|
||||
}
|
||||
|
||||
void ResetTrafficLightGroup(TrafficLight &trafficLight) {
|
||||
_client.ResetTrafficLightGroup(trafficLight.GetId());
|
||||
}
|
||||
|
||||
std::vector<ActorId> GetGroupTrafficLights(TrafficLight &trafficLight) {
|
||||
return _client.GetGroupTrafficLights(trafficLight.GetId());
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@ void export_actor() {
|
|||
.def("is_frozen", &cc::TrafficLight::IsFrozen)
|
||||
.def("get_pole_index", &cc::TrafficLight::GetPoleIndex)
|
||||
.def("get_group_traffic_lights", &GetGroupTrafficLights)
|
||||
.def("reset_group", &cc::TrafficLight::ResetGroup)
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
}
|
||||
|
|
|
@ -875,6 +875,24 @@ void FCarlaServer::FPimpl::BindActions()
|
|||
return R<void>::Success();
|
||||
};
|
||||
|
||||
BIND_SYNC(reset_traffic_light_group) << [this](
|
||||
cr::ActorId ActorId) -> R<void>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
auto ActorView = Episode->GetActorRegistry().Find(ActorId);
|
||||
if (!ActorView.IsValid() || ActorView.GetActor()->IsPendingKill())
|
||||
{
|
||||
RESPOND_ERROR("unable to reset traffic lights: actors not found");
|
||||
}
|
||||
auto TrafficLight = Cast<ATrafficLightBase>(ActorView.GetActor());
|
||||
if (TrafficLight == nullptr)
|
||||
{
|
||||
RESPOND_ERROR("unable to reset traffic lights: actor is not a traffic light");
|
||||
}
|
||||
TrafficLight->GetTrafficLightComponent()->GetGroup()->ResetGroup();
|
||||
return R<void>::Success();
|
||||
};
|
||||
|
||||
BIND_SYNC(get_vehicle_light_states) << [this]() -> R<cr::VehicleLightStateList>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
|
|
Loading…
Reference in New Issue