Fixes vehicle elimination algorithm
This commit is contained in:
parent
7f6c2b3594
commit
4052fa4be6
|
@ -313,9 +313,7 @@ void ALSM::UpdateUnregisteredActorsData() {
|
|||
void ALSM::UpdateIdleTime(std::pair<ActorId, double>& max_idle_time, const ActorId& actor_id) {
|
||||
if (idle_time.find(actor_id) != idle_time.end()) {
|
||||
double &idle_duration = idle_time.at(actor_id);
|
||||
TrafficLightState tl_state = simulation_state.GetTLS(actor_id);
|
||||
if (simulation_state.GetVelocity(actor_id).SquaredLength() > SQUARE(STOPPED_VELOCITY_THRESHOLD)
|
||||
|| (tl_state.at_traffic_light && tl_state.tl_state != TLS::Green && tl_state.tl_state != TLS::Off)) {
|
||||
if (simulation_state.GetVelocity(actor_id).SquaredLength() > SQUARE(STOPPED_VELOCITY_THRESHOLD)) {
|
||||
idle_duration = current_timestamp.elapsed_seconds;
|
||||
}
|
||||
|
||||
|
@ -329,7 +327,13 @@ void ALSM::UpdateIdleTime(std::pair<ActorId, double>& max_idle_time, const Actor
|
|||
bool ALSM::IsVehicleStuck(const ActorId& actor_id) {
|
||||
if (idle_time.find(actor_id) != idle_time.end()) {
|
||||
double delta_idle_time = current_timestamp.elapsed_seconds - idle_time.at(actor_id);
|
||||
if (delta_idle_time >= BLOCKED_TIME_THRESHOLD) {
|
||||
TrafficLightState tl_state = simulation_state.GetTLS(actor_id);
|
||||
if (!tl_state.at_traffic_light && tl_state.tl_state != TLS::Red && delta_idle_time >= BLOCKED_TIME_THRESHOLD) {
|
||||
std::cout << "Destroying not at Red TL" << std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (delta_idle_time >= RED_TL_BLOCKED_TIME_THRESHOLD) {
|
||||
std::cout << "Destroying at Red TL" << std::endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ static const int64_t TM_TIMEOUT = 2000; // ms
|
|||
namespace VehicleRemoval {
|
||||
static const float STOPPED_VELOCITY_THRESHOLD = 0.8f;
|
||||
static const double BLOCKED_TIME_THRESHOLD = 90.0;
|
||||
static const double RED_TL_BLOCKED_TIME_THRESHOLD = 180.0;
|
||||
static const double DELTA_TIME_BETWEEN_DESTRUCTIONS = 10.0;
|
||||
} // namespace VehicleRemoval
|
||||
|
||||
|
|
Loading…
Reference in New Issue