SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Branch:
Drift
Revision:
85:f3911aab41d9
Parent:
83:b2c7c6f76575
Child:
86:51048c1f132f
diff -r 2c22d01e8ae9 -r f3911aab41d9 StateMachine/RunningState.cpp
--- a/StateMachine/RunningState.cpp	Tue Apr 18 22:10:17 2017 +0000
+++ b/StateMachine/RunningState.cpp	Tue Apr 18 22:27:14 2017 +0000
@@ -15,7 +15,8 @@
     m_lastAngle(0.0f),
     m_lastAngleAbs(0.0f),
     m_cornerRatio(1.0f),
-    m_lastLineFound(BOTH_FOUND)
+    m_lastLineFound(BOTH_FOUND),
+    m_shouldTerminate(0)
 {}
 
 RunningState::~RunningState()
@@ -36,8 +37,9 @@
     image_processing();
     uint8_t shouldTerminate = ardu_cam_get_is_encounter_terminate();
     
-    if(shouldTerminate)
+    if(shouldTerminate || m_shouldTerminate)
     {
+        m_shouldTerminate = 0;
         TerminateProcess();
         return;
     }
@@ -159,7 +161,8 @@
 
 void RunningState::TouchIrqCallback()
 {
-    TerminateProcess();
+    //TerminateProcess();
+    m_shouldTerminate = 1;
 }
 
 void RunningState::TerminateProcess()