diff --git a/.gitignore b/.gitignore index 49932fa..fdfb5fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.avi .vscode -.DS_Store \ No newline at end of file +.DS_Store +__pycache__ +gipps/result \ No newline at end of file diff --git a/gipps/gipps.png b/gipps/gipps.png new file mode 100644 index 0000000..9e1bde9 Binary files /dev/null and b/gipps/gipps.png differ diff --git a/gipps/gipps.py b/gipps/gipps.py index 0a53a42..bdc083e 100644 --- a/gipps/gipps.py +++ b/gipps/gipps.py @@ -2,10 +2,11 @@ import numpy as np import matplotlib.pyplot as plt import time from colour import Color +import imagesV1 as images # =========== t0 = 0 -tf = 30 +tf = 40 dt = 1 t = t0 # =========== @@ -25,6 +26,7 @@ An = 1.7 # accel max sampled from a nor Bn = -2 * An # frein max equated to - 2An Sn = 6.5 # taille de la voiture plus marge sampled from a normal distribution. N(6.5,0.3²) m Vd = 20.0 # vitesse désirée sampled from a normal distribution. N(20.0,3.2²) m/sec +Vmin = 1 # X*n # position fin de freinage (calculable) Tr = 2/3 + (2/3)/2 # temps de réaction + sûreté (= tau + θ = 2/3 + tau/2) # B supposé égal à Bn-1 (si pas égal alors amplifications ??) @@ -40,83 +42,85 @@ def rainbow_gradient(num_colors): return colors colors = rainbow_gradient(nbv) -def px(xx): # Avance au cours du temps - xx += 1 - return xx +def px(tt): # Avance au cours du temps + tt += 1 + return tt -def vitesseatt(t, yy): # Vitesse qu'il peut réellement atteindre d'un point de vue dynamique - - - - Vnt = yy[-1] - - value = Vnt + 2.5 * An * Tr * ( 1 - (Vnt/Vd) ) * np.sqrt( ( 0.025 + (Vnt/Vd) )) - print('value: ', value) - - yy[0] = value - newyy = yy - print('newyy: ', newyy) - return newyy +def vitesseatt(vtold): # Vitesse qu'il peut réellement atteindre d'un point de vue dynamique + value = vtold + 2.5 * An * Tr * ( 1 - (vtold/Vd) ) * np.sqrt( ( 0.025 + (vtold/Vd) )) + return value -def vitesseadop(t, yy): # Vitesse qu'il est possible d'adopter en connaissant les contraintes de sécurité liées à la présence du véhicule leader - t = t + Tr - pass +def vitesseadop(vtold, xxpold): # Vitesse qu'il est possible d'adopter en connaissant les contraintes de sécurité liées à la présence du véhicule leader + dst = np.diff(xxpold) + value = Bn * Tr + np.sqrt( ((Bn)**2) * ((Tr)**2) - Bn * ( 2 * dst) - vtold[0] * Tr - ( (xxold[-1])**2 / Bn ) ) + newvalue = np.insert(value, 1, vtold[1]) + print('newvalue: ', newvalue) + return newvalue -def vitessereelle(t, yyold): # Vitesse du véhicule - print(len(yy)) - t = t + Tr - if (t>= 0) and (t<=10): - yy[-1] = 0 # Arrêt du leader - elif (t>= 15) and (t<=20): - - else: - yy[-1] = Vd # Leader avance normalement - - -# a = np.where(t <= 10, (Umax - Umin) / 10, - (Umax - Umin) / 10) -# vt = np.where(t <= 10, Umin + a * t, Umax + 2 * a * (t - 10)) +def vitessereelle(t, vtold, xxpold): # Vitesse du véhicule + t+=t + if t==0: + vtold[-1] = 0.1 + elif (t> 0) and (t<=10): # Accélération du leader + a = (Vd - Vmin) / 10 + vtleader = Vmin + a * t + vtold[-1] = vtleader + elif (t>= 16) and (t<=20): # Leader freine + a = - (Vd - Vmin) / 10 + vtleader = Vd + 2 * a * (t - 16) + vtold[-1] = vtleader + elif (t>= 20) and (t<=30): # Accélération du leader + a = (Vd - Vmin) / 10 + vtleader = Vmin + a * (t-20) + vtold[-1] = vtleader + else: # Leader avance normalement + vtold[-1] = Vd + + vatt = vitesseatt(vtold) + vadop = vitesseadop(vtold, xxpold) + minimum = np.minimum(vatt, vadop) + print('minimum: ', minimum) + return minimum +def position(fposition, newv): + newp = fposition + newv * dt + return newp - vatt = vitesseatt(t, yyold) - vadop = vitesseadop(t, yyold) - # return min(vatt, vadop) - return vatt - - -xxbase = np.linspace(-nbv, -1, nbv) -yybase = np.linspace(0, 0, nbv) +xxbase = np.linspace(-nbv, 1, nbv) +xxpbase = np.linspace(0, 1, nbv) +yybase = np.linspace(0, 1, nbv) xxold = xxbase.copy() -yyold = yybase.copy() +xxpold = xxpbase.copy() +vtold = yybase.copy() while(t 0) and (t<=10): # Accélération du leader + a = (10 - Vmin) / 10 + vtleader = Vmin + a * t + vtold[-1] = vtleader + elif (t>= 16) and (t<=20): # Leader freine + a = - (10 - Vmin) / 10 + vtleader = 10 + 2 * a * (t - 16) + vtold[-1] = vtleader + elif (t> 20) and (t<=29): # Accélération du leader + a = (Vd - Vmin) / 10 + vtleader = Vmin + a * (t-19) + vtold[-1] = vtleader + elif (t> 29) and (t<=40): # Accélération du leader + vtold[-1] = 20 + else: # Leader avance normalement + vtold[-1] = 10 + + vatt = vitesseatt(vtold) + vadop = vitesseadop(vtold, xxpold) + minimum = np.minimum(vatt, vadop) + print('minimum: ', minimum) + return minimum + + + +def position(fposition, newv): + newp = fposition + newv * dt + return newp + +xxbase = np.linspace(-nbv, 1, nbv) +xxpbase = np.linspace(0, 1, nbv) +yybase = np.linspace(0, 1, nbv) + +xxold = xxbase.copy() +xxpold = xxpbase.copy() +vtold = yybase.copy() + +while(t