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:
24:c7d9b5bf3829
Parent:
23:434f04ef1fad
Child:
27:0a5b90cd65d6
--- a/main.cpp	Tue Nov 28 18:00:09 2017 +0000
+++ b/main.cpp	Wed Nov 29 15:19:14 2017 +0000
@@ -1,105 +1,8 @@
 /*
-    Starting from Trent's Linear Actuator code from 2017-10-19, these modifications
-    by Dan add an outer loop controller for depth and pitch to command the inner
-    linear actuator loops.
-    Modified 2017-10-20 revA by Dan
-        - added outer loop controller, but it is hanging the mbed. (turns out it was the imu update)
-    Modified 2017-10-22 revA by Dan
-        - outer loop now works with a call to outerloop.update() in main loop(), not with an attached ticker
-    Modified 2017-10-22 revB by Dan
-        - enabled both depth and pitch outer loop controllers
-        - added ability to keyboard reset
-    Modified 2017-10-22 revC by Dan
-        - major update to the IMU library processing to make a state machine that doesn't hang
-        - added lat/lon/alt and GNSS fix information to the IMU library
-        - brought out the pin names into the constructors of IMU, omega, SpiADC
-    Modified 2017-10-22 revD by Dan
-        - everything seems to be working, shy of re-checking on the hardware
-        - Depth sensor call done inside the OuterLoop, but should somehow be set as a callback instead
-        - IMU sensor call done inside the OuterLoop, but should somehow be set as a callback instead
-    Modified 2017-10-23 revA by Dan/Matt
-        - linear actuator hardware works great, limit switches, sensing, etc.
-        - outer loops run, but move the BCE in the wrong direction.
-        - new IMU code doesn't read from the sensor correctly, but doesn't hang up either.
-        - depth sensor worked fine, just needs zero bias adjustment.
-    Modified 2017-10-24 by Troy
-        - added offset to outerloop
-    Modified 2017-10-26 by Dan
-        - brought over a state machine and new keyboard controls ... currently just dumped into main.
-    Modified 2017-10-26 by Matt
-        - new IMU code imported and working well with the hardware.
-    Modified 2017-10-26 revB by Dan
-        - This version has been in the pool.
-        - Get occasional ADC bad string pot batt & piston. On initial sensor reads, see negative positions.
-            But after running FLOAT_BROADCAST, string pot positions are normal. Not sure why.
-        - Repeatedly got stuck in RISE with a +60s timeout.  Battery hit end bell and stalled out.
-        - keyboard and state machine are in main, probably shouldn't be, but easier to debug.
-        - Really happy with the logic and flow of the state machine. Timeouts work.
-        - Need to add a means to drive the linear actuators manually ... toggle out stop() in SIT_IDLE.
-        - Need to add keyboard commands to modify the zeroOffset positions.
-    Modified 2017-10-30 by Dan, Trent, Matt, Troy
-        - changed .stop() to .pause() and many .start() to .unpause() ... fixed the negative ADC and lets
-            the PVF's keep running even though the motor isn't moving.
-        - changed exit conditions to use filtered depth from the outer loop.  less noisy.
-    Modified 2017-10-31 by Dan, Matt
-        - added oversampling and a tare function to the depth sensor.
-        - updated main and keyboard to include tare in setup() and a keyboard tare option.
-        - looks like the piston isn't zeroing correctly, unclear why, should be unrelated to depth sensor.
-    Modified 2017-10-31 (again) by Dan, Matt, and Troy
-        - POOL TESTED!
-        - Tuned the PID gains with magic.  Works to hold mostly level during BCE runs.  Dive is awesome.
-        - Neutral won't do what we want ... without large depth P, it won't get to depth.
-        - Dive with just P doesn't overshoot depth at 0.0 deg, but does with -20 deg.  Timeout should probably be RISE.
-        - Files depth/pitch updated with tuned defaults.
-    Modified 2017-11-06 by Troy
-        - Added acronyms to print statements (when running this with XBee you don't know what mode the 
-            hardware is in because of signal dropping out)
-        - Fixed print error with setpoints by printing out the setpoint variable, not the outerloop getCommand
-            (command is sent every time hardware dives, finds neutral, etc.)
-        - Set the pitchCommand input to 0 on the "find neutral" command, it was sending a non-zero pitch command
-        - Created a class for the StateMachine
-    Modified 2017-11-14 by Troy
-        - Changed tare to void function (functions does not return anything when called)
-        - Added a "subclass" in the cases for the Neutral Finding Sequence (Sinking, Slowly Rise, Check Pitch (and save positions))
-    Modified 2017-11-20 by Troy
-        - Modified StateMachine class to separate keyboard inputs from FSM
-        - Added Neutral Finding sub-statemachine
-        - Verified both state machines are working with hardware on desktop
-        - Added class to save neutral battery and buoyancy engine positions to neutral.cfg file
-    Modified 2017-11-21 by Troy
-        - Need to check remove ConfigFileIO and place saving functions into config_functions.cpp (rename ConfigFunctions.cpp)
-        - Added multi-dive (and multi-rise) states to FSM (may incorporate single dive states into states)
-        - Need to double-check behavior of sub-FSM but bench-top testing showed correct behavior for transition from sinking, to slowly rise, to check pitch
-        - Need to add a check for the multi-dive sequence file (sequence.cfg) being loaded on the MBED
-    Modified 2017-11-21 by Dan
-        - removed blocker and set up a loop rate timer that runs the state machine and keyboard at 10 Hz.
-        - work inside StateMachine and particularly in the findNeutralSubState.
-    Modified 2017-11-22 by Troy
-        - Placed config_functions into ConfigFileIO and added the ability to write the neutral positions to the depth & pitch files
-        - Streamlined sub-FSM and Find_Neutral state
-        - PID depth and pitch gains have been made into class variables so that they can be resaved to the depth/pitch files
-        - Added the ability to save depth & pitch gains and neutral offsets (configfile writes entire file at once)
-        - Minor formatting fixes
-        - Fixed issue with keyboard function, the keyboard function was continuously active instead of checking pc readable in sit idle
-        - Bench tested neutral finding sequence and multi-dive sequence, so far so good
-        - Question: Why do we want the keyboard and FSM to run together, specifically allowing the FSM call the keyboard?
-    Modified 2017-11-22 by Dan
-        - added ability for substate NEUTRAL_CHECK_PITCH to move the battery toward level, then saves offsets.
-        - added new entry state NEUTRAL_FIRST_PITCH that also moves the battery toward level, but doesn't save.
-    Modified 2017-11-27 by Troy
-        - Fixed exit condition (restart at NEUTRAL_FIRST_PITCH)
-        - Pool tested, needed to run timer for longer than 5 minutes (neutral finding sequence timed out)
-        - IMU fell off tape
-    Modified 2017-11-28 Rev A by Dan/Troy
-        - Modified NEUTRAL_FIRST_PITCH to save the battery offset into the Pitch Outer Loop before beginning neutral finding sequence before sinking
-        - Pitch Outer Loop now runs NEUTRAL_SINKING and NEUTRAL_SLOWLY_RISE states (instead of batt fixed position control)
-        - NEUTRAL_SINKING has been changed to a 5-second timer (vice 10 seconds)
-        - NEUTRAL_SLOWLY_RISE has been changed to move the piston 2 mm each interval (vice 1 mm)
-    Modified 2017-11-28 Rev B by Dan/Troy
-        - Changed pitch rate margin from absolute value < 0.5 deg/sec to 5.0 deg/s
-        - Changed sink timer to move piston 5 mm at a time instead of 10 mm
-        - Find level motion will now run every 10 seconds instead of 5 seconds
-        - Created an integer array to do a quick check of what states Find Neutral sub-FSM ran through (press "c" to see states)
+    Modified 2017-11-29 revA by Troy
+        - changelog.txt carries previous changes
+        - Incorporated email changes and did quick bench test
+        - Redid the sub-state recording method to only update on state changes
 */
  
 #include "mbed.h"
@@ -112,7 +15,7 @@
  
 void setup() {
     pc().baud(57600);
-    pc().printf("\n\n\rFSG 2017-11-27\n\n\r");
+    pc().printf("\n\n\rFSG POOL TEST 2017-11-29\n\n\r");
  
     // start up the system timer
     systemTime().start();