TRR2018 omar

Dependencies:   mbed

Fork of biniou by TRR 2018

Revision:
42:3f12252862b9
Parent:
41:4dd36f607279
Child:
43:d2164ee3336a
--- a/stateMachines.cpp	Wed Sep 19 13:42:04 2018 +0000
+++ b/stateMachines.cpp	Wed Sep 19 20:44:07 2018 +0000
@@ -12,6 +12,7 @@
 
 Timer timeSinceStart;// temps.start()/stop()/sec: read()/ms: read_ms()/µs: read_us()
 Timer timerSinceTachy;
+Timer timersinceSerial;
 
 double distMurG90[NB_ECHANTILLONS_IR];//buffer tournant ir coté gauche pour moyenne
 double distMurD90[NB_ECHANTILLONS_IR];//buffer tournant ir coté droit pour moyenne
@@ -305,6 +306,8 @@
                 distLidar=uart[2]+uart[3]*256;// calculate distance value
                 strengthLidarPrev = strengthLidar;
                 strengthLidar=uart[4]+uart[5]*256;// calculate signal strength value
+                timersinceSerial.reset();
+                timersinceSerial.start();
             }
         }
     }
@@ -559,11 +562,14 @@
             }
             break;
         case BRAKING:
-            if( st_maxSpeed == BLOCKED
+            if(st_maxSpeed == BLOCKED && timersinceSerial.read_us() > 200000) {
+                p_sectionCourante= NULL;
+                st_tmpThro = STOPPED;
+            } else if( st_maxSpeed == BLOCKED
 #ifdef FREINAGE_ADAPTATIF
-                    || brakingTimer.read_us() < brakingDurationNeeded_us
+                       || brakingTimer.read_us() < brakingDurationNeeded_us
 #endif
-              ) {
+                     ) {
                 st_tmpThro = BRAKING;
             } else if(st_currentSection == ARRET) {
                 st_tmpThro = STOPPED;