This commit is contained in:
leo 2022-05-14 21:55:07 +02:00
parent 2f65aee90d
commit d431bf322f
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB

11
Car.py
View File

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