most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown

Dependencies:   mbed MODSERIAL FATFileSystem

Revision:
22:a10ee088403b
Parent:
21:38c8544db6f4
Child:
23:434f04ef1fad
--- a/StateMachine/StateMachine.hpp	Wed Nov 22 23:04:11 2017 +0000
+++ b/StateMachine/StateMachine.hpp	Thu Nov 23 02:20:08 2017 +0000
@@ -14,16 +14,17 @@
     FLOAT_LEVEL,            // bce position to float, pitch loop active at zero, exits when stable near zero pitch
     FLOAT_BROADCAST,        // bce position to float, batt position forward to hold tail up, exits when actuators done
     EMERGENCY_CLIMB,        // bce position to full rise, batt position to full aft, exits when at surface
-    MULTI_DIVE,             // NEW: multi-dive sequence
-    MULTI_RISE              // NEW: multi-rise sequence
+    MULTI_DIVE,             // multi-dive sequence
+    MULTI_RISE              // multi-rise sequence
 };
  
 // find_neutral finite state machine enumerations
 enum {
-    NEUTRAL_SINKING,        // NEW: FIND_NEUTRAL immediately goes into "sinking" 
-    NEUTRAL_SLOWLY_RISE,    // NEW: Once sinking times out, goes into "check pitch"
-    NEUTRAL_CHECK_PITCH,    // NEW: Once pitch rate confirmed, saves the data and exits to RISE state
-    NEUTRAL_EXIT            // NEW: sub-FSM has completed all checks
+    NEUTRAL_FIRST_PITCH,    // NEW first state: find level by moving the battery
+    NEUTRAL_SINKING,        // increment the bce until really start sinking
+    NEUTRAL_SLOWLY_RISE,    // once sinking, arrest the sink
+    NEUTRAL_CHECK_PITCH,    // find level again, then save the data and exit
+    NEUTRAL_EXIT            // sub-FSM has completed all checks
 };
  
 //struct for saving the data
@@ -78,11 +79,12 @@
     
     Timer timer;
     
-    int _state;                         //Fine State Machine (FSM) state
-    int _sub_state;                     //substate on find_neutral function
-    int _previous_sub_state;            //previous substate so that what goes into the sub-state is not being changed as it is processed
-    float _neutral_sink_timer;
-    float _neutral_rise_timer;
+    int _state;                 // Fine State Machine (FSM) state
+    int _sub_state;             // substate on find_neutral function
+    int _previous_sub_state;    // previous substate so that what goes into the sub-state is not being changed as it is processed
+    float _neutral_sink_timer;  // keep time for sink incremnets
+    float _neutral_rise_timer;  // keep time for rise increment
+    float _level_timer;         // keep time for finding level increments
     
     bool isTimeoutRunning;