From d431bf322f197c00ba66c2b5d2bd60c3a7ef54e4 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 14 May 2022 21:55:07 +0200 Subject: [PATCH] fix --- Car.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Car.py b/Car.py index 45904f1..8904024 100644 --- a/Car.py +++ b/Car.py @@ -64,7 +64,7 @@ class Car(): self.a=10 self.b=20 self.minSpace=10 - self.interMinSpace=20 + self.interMinSpace=10 self.distToInter=0 self.timeStopped=0 self.speedPercentage=0 @@ -421,7 +421,7 @@ class Car(): nextInternalIndex = self.index # Pour la voiture actuelle, dans l'ideal on calculerait la durée selon la vitesse sur chaque troncon while not self.route[nextInternalIndex].isSpecial(): # Mais pour l'instant on prend juste la vitesse sur le troncon interne (le plus lent en general) nextInternalIndex += 1 - tti, sai = self.calcTti(self.distToInter, self.v, self.route[nextInternalIndex].getLane(0).getSpeed(), self.a) # TODO : laneID + tti, sai = self.calcTti(self.distToInter, self.v, self.route[nextInternalIndex].getSpeed(), self.a) ltti, lsai = self.calcTti(self.leaderAtInterDist, vleader, lvmax, leaderAtInter.a) lta = (lvmax-vleader) / leaderAtInter.a # temps ou le leader accelere (i.e on ne gagne pas de vitesse relative) (on considere que leader.a==self.a) @@ -436,17 +436,16 @@ class Car(): if self.leader is None and self.timeAtInter >= 0: cd, maxInterTime = self.circularLeaderDep(self.leaderAtInter, 0, 20) if cd and self.timeAtInter >= maxInterTime: - print(maxInterTime) self.forceThrough = True # Ou si notre leader est bloqué devant un autre leader - #if self.leader is None and self.leaderAtInter.v == 0 and self.leaderAtInter.leaderAtInter is not None and self.leaderAtInter.leaderAtInterDist > 20: - # self.forceThrough = True + if self.leader is None and self.leaderAtInter.v == 0 and self.leaderAtInter.leaderAtInter is not None and self.leaderAtInter.leaderAtInterDist > self.interMinSpace: + self.forceThrough = True # si on est suffisement loin de l'intersection (i.e on s'en fout du leader) # ou si on as le temps d'arriver à l'intersection avant le leader (plus un marge pour garder un distance de sécu) # alors on accelere pour s'inserer #print(tti, leader.T, marg, ltti) - if self.distToInter > self.interMinSpace + dts or (tti + leaderAtInter.T + marg) < ltti: + if self.distToInter > self.interMinSpace + dts or (tti + leaderAtInter.T + 0.1 + marg) < ltti: vsecInter = min(vmax, self.v + self.a*dt) #print(self.id, "ca passe") else:# sinon on freine