opti forceThrough
This commit is contained in:
parent
f7e700342c
commit
2f65aee90d
31
Car.py
31
Car.py
@ -433,8 +433,14 @@ class Car():
|
||||
#print(self.distToInter, self.minSpace, dts)
|
||||
|
||||
# Si on est bloqué dans une dépendance circulaire
|
||||
if self.timeAtInter >= 1 and self.leader is None and self.circularLeaderDep(self.leaderAtInter, 20):
|
||||
self.forceThrough = True
|
||||
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
|
||||
|
||||
# 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)
|
||||
@ -447,7 +453,6 @@ class Car():
|
||||
vsecInter = max(0, self.v - self.b*dt)
|
||||
|
||||
if self.forceThrough:
|
||||
self.leaderAtInter = None # On supprime le leader (pour que seulement la premiere voiture detecte la dependance circulaire)
|
||||
vsecInter = min(vmax, self.v + self.a*dt)
|
||||
|
||||
vsec = vmax
|
||||
@ -464,21 +469,27 @@ class Car():
|
||||
self.updateGraph(self.v, vmax, vsec, vsecInter)
|
||||
|
||||
# fonction pour verifier si on as pas une dependence circulaire de leader
|
||||
def circularLeaderDep(self, car, timeout):
|
||||
def circularLeaderDep(self, car, maxTimeStopped, timeout):
|
||||
if timeout <= 0:
|
||||
return False
|
||||
return False, 0
|
||||
|
||||
if car is None:
|
||||
return False
|
||||
return False, 0
|
||||
|
||||
if car.forceThrough:
|
||||
return False, 0
|
||||
|
||||
maxTimeStopped = max(maxTimeStopped, car.timeAtInter)
|
||||
|
||||
if car.id == self.id:
|
||||
return True
|
||||
return True, maxTimeStopped
|
||||
|
||||
timeout -= 1
|
||||
res = self.circularLeaderDep(car.leader, timeout)
|
||||
res |= self.circularLeaderDep(car.leaderAtInter, timeout)
|
||||
res,mts = self.circularLeaderDep(car.leader, maxTimeStopped, timeout)
|
||||
res2,mts2 = self.circularLeaderDep(car.leaderAtInter, maxTimeStopped, timeout)
|
||||
maxTimeStopped = max(mts, mts2)
|
||||
|
||||
return res
|
||||
return (res or res2), maxTimeStopped
|
||||
|
||||
def updateGraph(self, v, vmax, vsec, interVsec):
|
||||
if self.infoWidg is None:
|
||||
|
4
main.py
4
main.py
@ -76,6 +76,10 @@ class MainWindow(QMainWindow):
|
||||
self.setPhTimerInterval.emit(17)
|
||||
elif e.key() == Qt.Key_F:
|
||||
self.setPhTimerInterval.emit(500)
|
||||
elif e.key() == Qt.Key_C:
|
||||
self.mainLoop.controller.dt = 0.3
|
||||
elif e.key() == Qt.Key_P:
|
||||
self.mainLoop.controller.dt = 1/60
|
||||
else:
|
||||
self.mainLoop.quickLoad(e.key())
|
||||
|
||||
|
@ -16,7 +16,8 @@ class mainLoop(QObject):
|
||||
Qt.Key_2 : ["comp_rdp.net.xml", "comp_rdp.rou.xml"],
|
||||
Qt.Key_3 : ["comp_rdp.net.xml", "comp_rdp_t3.rou.xml"],
|
||||
Qt.Key_4 : ["rdpt_polytech_fixed.net.xml", "rdpt_polytech_burst.rou.xml"],
|
||||
Qt.Key_5 : ["rdpt_polytech_fixed.net.xml", "rdpt_polytech_burst_2.rou.xml"]
|
||||
Qt.Key_5 : ["rdpt_polytech_fixed.net.xml", "rdpt_polytech_burst_2.rou.xml"],
|
||||
Qt.Key_6 : ["rdpt_polytech_fixed.net.xml", "rdpt_polytech_burst_2_IA.rou.xml"]
|
||||
}
|
||||
|
||||
def __init__(self, parent):
|
||||
|
Loading…
x
Reference in New Issue
Block a user