Hlimi Omar
/
biniou
TRR2018 omar
Fork of biniou by
Diff: stateMachines.cpp
- Revision:
- 27:f8c3f1524a64
- Parent:
- 26:3b144f243646
- Child:
- 29:fc984fe08ca7
diff -r 3b144f243646 -r f8c3f1524a64 stateMachines.cpp --- a/stateMachines.cpp Sun Sep 16 17:11:15 2018 +0000 +++ b/stateMachines.cpp Mon Sep 17 11:00:56 2018 +0000 @@ -81,8 +81,10 @@ int tachyStepsRegister = 0; int tachySectionDist_cm = 0; +#ifdef FREINAGE_ADAPTATIF Timer brakingTimer; int brakingDurationNeeded_us = 0; +#endif //Etats MUR_ST st_murs; @@ -444,7 +446,7 @@ } else if( strengthLidar > LIDAR_STRENGTH_THRESOLD && strengthLidarPrev > LIDAR_STRENGTH_THRESOLD && distLidar < p_sectionCourante->lidarWarningDist_cm && - distLidarPrev-distLidar > 0) + distLidarPrev-distLidar > 3) { st_tmpMaxSpeed = BLOCKED; } @@ -471,26 +473,36 @@ st_maxSpeed == BLOCKED ) { st_tmpThro = BRAKING; - } else if(tachySpeed_cmps > (maxSpeed_cmps + SPEED_DELTA_CMPS)) + } +#ifdef FREINAGE_ADAPTATIF + else if(tachySpeed_cmps > (maxSpeed_cmps + SPEED_DELTA_CMPS)) { st_tmpThro = BRAKING; brakingDurationNeeded_us = (10000)* MASSE_BINIOU_KG *((tachySpeed_cmps-maxSpeed_cmps)*(tachySpeed_cmps+maxSpeed_cmps)) / (PUISSANCE_FREINAGE_W *2) ;//vitesse en m/s et temps en us brakingTimer.reset(); brakingTimer.start(); - } else + } +#endif + else { return; } break; case BRAKING: - if(brakingTimer.read_us() < brakingDurationNeeded_us || BLOCKED)//put a timer here + if( BLOCKED + #ifdef FREINAGE_ADAPTATIF + || brakingTimer.read_us() < brakingDurationNeeded_us + #endif + ) { st_tmpThro = BRAKING; }else if(st_currentSection == ARRET) { st_tmpThro = STOPPED; } else{ + #ifdef FREINAGE_ADAPTATIF brakingDurationNeeded_us = 0; + #endif st_tmpThro = REGULATION_SPEED; } break;