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

Committer:
tnhnrl
Date:
Tue Aug 14 21:06:48 2018 +0000
Revision:
74:d281aaef9766
Parent:
39:58375ca6b6ff
Child:
79:3688c3a0d7f4
1) Fixed deadband on float broadcast ; 2) Fixed find neutral commands

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tnhnrl 24:c7d9b5bf3829 1 Starting from Trent's Linear Actuator code from 2017-10-19, these modifications
tnhnrl 24:c7d9b5bf3829 2 by Dan add an outer loop controller for depth and pitch to command the inner
tnhnrl 24:c7d9b5bf3829 3 linear actuator loops.
tnhnrl 24:c7d9b5bf3829 4 Modified 2017-10-20 revA by Dan
tnhnrl 24:c7d9b5bf3829 5 - added outer loop controller, but it is hanging the mbed. (turns out it was the imu update)
tnhnrl 24:c7d9b5bf3829 6 Modified 2017-10-22 revA by Dan
tnhnrl 24:c7d9b5bf3829 7 - outer loop now works with a call to outerloop.update() in main loop(), not with an attached ticker
tnhnrl 24:c7d9b5bf3829 8 Modified 2017-10-22 revB by Dan
tnhnrl 24:c7d9b5bf3829 9 - enabled both depth and pitch outer loop controllers
tnhnrl 24:c7d9b5bf3829 10 - added ability to keyboard reset
tnhnrl 24:c7d9b5bf3829 11 Modified 2017-10-22 revC by Dan
tnhnrl 24:c7d9b5bf3829 12 - major update to the IMU library processing to make a state machine that doesn't hang
tnhnrl 24:c7d9b5bf3829 13 - added lat/lon/alt and GNSS fix information to the IMU library
tnhnrl 24:c7d9b5bf3829 14 - brought out the pin names into the constructors of IMU, omega, SpiADC
tnhnrl 24:c7d9b5bf3829 15 Modified 2017-10-22 revD by Dan
tnhnrl 24:c7d9b5bf3829 16 - everything seems to be working, shy of re-checking on the hardware
tnhnrl 24:c7d9b5bf3829 17 - Depth sensor call done inside the OuterLoop, but should somehow be set as a callback instead
tnhnrl 24:c7d9b5bf3829 18 - IMU sensor call done inside the OuterLoop, but should somehow be set as a callback instead
tnhnrl 24:c7d9b5bf3829 19 Modified 2017-10-23 revA by Dan/Matt
tnhnrl 24:c7d9b5bf3829 20 - linear actuator hardware works great, limit switches, sensing, etc.
tnhnrl 24:c7d9b5bf3829 21 - outer loops run, but move the BCE in the wrong direction.
tnhnrl 24:c7d9b5bf3829 22 - new IMU code doesn't read from the sensor correctly, but doesn't hang up either.
tnhnrl 24:c7d9b5bf3829 23 - depth sensor worked fine, just needs zero bias adjustment.
tnhnrl 24:c7d9b5bf3829 24 Modified 2017-10-24 by Troy
tnhnrl 24:c7d9b5bf3829 25 - added offset to outerloop
tnhnrl 24:c7d9b5bf3829 26 Modified 2017-10-26 by Dan
tnhnrl 24:c7d9b5bf3829 27 - brought over a state machine and new keyboard controls ... currently just dumped into main.
tnhnrl 24:c7d9b5bf3829 28 Modified 2017-10-26 by Matt
tnhnrl 24:c7d9b5bf3829 29 - new IMU code imported and working well with the hardware.
tnhnrl 24:c7d9b5bf3829 30 Modified 2017-10-26 revB by Dan
tnhnrl 24:c7d9b5bf3829 31 - This version has been in the pool.
tnhnrl 24:c7d9b5bf3829 32 - Get occasional ADC bad string pot batt & piston. On initial sensor reads, see negative positions.
tnhnrl 24:c7d9b5bf3829 33 But after running FLOAT_BROADCAST, string pot positions are normal. Not sure why.
tnhnrl 24:c7d9b5bf3829 34 - Repeatedly got stuck in RISE with a +60s timeout. Battery hit end bell and stalled out.
tnhnrl 24:c7d9b5bf3829 35 - keyboard and state machine are in main, probably shouldn't be, but easier to debug.
tnhnrl 24:c7d9b5bf3829 36 - Really happy with the logic and flow of the state machine. Timeouts work.
tnhnrl 24:c7d9b5bf3829 37 - Need to add a means to drive the linear actuators manually ... toggle out stop() in SIT_IDLE.
tnhnrl 24:c7d9b5bf3829 38 - Need to add keyboard commands to modify the zeroOffset positions.
tnhnrl 24:c7d9b5bf3829 39 Modified 2017-10-30 by Dan, Trent, Matt, Troy
tnhnrl 24:c7d9b5bf3829 40 - changed .stop() to .pause() and many .start() to .unpause() ... fixed the negative ADC and lets
tnhnrl 24:c7d9b5bf3829 41 the PVF's keep running even though the motor isn't moving.
tnhnrl 24:c7d9b5bf3829 42 - changed exit conditions to use filtered depth from the outer loop. less noisy.
tnhnrl 24:c7d9b5bf3829 43 Modified 2017-10-31 by Dan, Matt
tnhnrl 24:c7d9b5bf3829 44 - added oversampling and a tare function to the depth sensor.
tnhnrl 24:c7d9b5bf3829 45 - updated main and keyboard to include tare in setup() and a keyboard tare option.
tnhnrl 24:c7d9b5bf3829 46 - looks like the piston isn't zeroing correctly, unclear why, should be unrelated to depth sensor.
tnhnrl 24:c7d9b5bf3829 47 Modified 2017-10-31 (again) by Dan, Matt, and Troy
tnhnrl 24:c7d9b5bf3829 48 - POOL TESTED!
tnhnrl 24:c7d9b5bf3829 49 - Tuned the PID gains with magic. Works to hold mostly level during BCE runs. Dive is awesome.
tnhnrl 24:c7d9b5bf3829 50 - Neutral won't do what we want ... without large depth P, it won't get to depth.
tnhnrl 24:c7d9b5bf3829 51 - Dive with just P doesn't overshoot depth at 0.0 deg, but does with -20 deg. Timeout should probably be RISE.
tnhnrl 24:c7d9b5bf3829 52 - Files depth/pitch updated with tuned defaults.
tnhnrl 24:c7d9b5bf3829 53 Modified 2017-11-06 by Troy
tnhnrl 24:c7d9b5bf3829 54 - Added acronyms to print statements (when running this with XBee you don't know what mode the
tnhnrl 24:c7d9b5bf3829 55 hardware is in because of signal dropping out)
tnhnrl 24:c7d9b5bf3829 56 - Fixed print error with setpoints by printing out the setpoint variable, not the outerloop getCommand
tnhnrl 24:c7d9b5bf3829 57 (command is sent every time hardware dives, finds neutral, etc.)
tnhnrl 24:c7d9b5bf3829 58 - Set the pitchCommand input to 0 on the "find neutral" command, it was sending a non-zero pitch command
tnhnrl 24:c7d9b5bf3829 59 - Created a class for the StateMachine
tnhnrl 24:c7d9b5bf3829 60 Modified 2017-11-14 by Troy
tnhnrl 24:c7d9b5bf3829 61 - Changed tare to void function (functions does not return anything when called)
tnhnrl 24:c7d9b5bf3829 62 - Added a "subclass" in the cases for the Neutral Finding Sequence (Sinking, Slowly Rise, Check Pitch (and save positions))
tnhnrl 24:c7d9b5bf3829 63 Modified 2017-11-20 by Troy
tnhnrl 24:c7d9b5bf3829 64 - Modified StateMachine class to separate keyboard inputs from FSM
tnhnrl 24:c7d9b5bf3829 65 - Added Neutral Finding sub-statemachine
tnhnrl 24:c7d9b5bf3829 66 - Verified both state machines are working with hardware on desktop
tnhnrl 24:c7d9b5bf3829 67 - Added class to save neutral battery and buoyancy engine positions to neutral.cfg file
tnhnrl 24:c7d9b5bf3829 68 Modified 2017-11-21 by Troy
tnhnrl 24:c7d9b5bf3829 69 - Need to check remove ConfigFileIO and place saving functions into config_functions.cpp (rename ConfigFunctions.cpp)
tnhnrl 24:c7d9b5bf3829 70 - Added multi-dive (and multi-rise) states to FSM (may incorporate single dive states into states)
tnhnrl 24:c7d9b5bf3829 71 - 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
tnhnrl 24:c7d9b5bf3829 72 - Need to add a check for the multi-dive sequence file (sequence.cfg) being loaded on the MBED
tnhnrl 24:c7d9b5bf3829 73 Modified 2017-11-21 by Dan
tnhnrl 24:c7d9b5bf3829 74 - removed blocker and set up a loop rate timer that runs the state machine and keyboard at 10 Hz.
tnhnrl 24:c7d9b5bf3829 75 - work inside StateMachine and particularly in the findNeutralSubState.
tnhnrl 24:c7d9b5bf3829 76 Modified 2017-11-22 by Troy
tnhnrl 24:c7d9b5bf3829 77 - Placed config_functions into ConfigFileIO and added the ability to write the neutral positions to the depth & pitch files
tnhnrl 24:c7d9b5bf3829 78 - Streamlined sub-FSM and Find_Neutral state
tnhnrl 24:c7d9b5bf3829 79 - PID depth and pitch gains have been made into class variables so that they can be resaved to the depth/pitch files
tnhnrl 24:c7d9b5bf3829 80 - Added the ability to save depth & pitch gains and neutral offsets (configfile writes entire file at once)
tnhnrl 24:c7d9b5bf3829 81 - Minor formatting fixes
tnhnrl 24:c7d9b5bf3829 82 - Fixed issue with keyboard function, the keyboard function was continuously active instead of checking pc readable in sit idle
tnhnrl 24:c7d9b5bf3829 83 - Bench tested neutral finding sequence and multi-dive sequence, so far so good
tnhnrl 24:c7d9b5bf3829 84 - Question: Why do we want the keyboard and FSM to run together, specifically allowing the FSM call the keyboard?
tnhnrl 24:c7d9b5bf3829 85 Modified 2017-11-22 by Dan
tnhnrl 24:c7d9b5bf3829 86 - added ability for substate NEUTRAL_CHECK_PITCH to move the battery toward level, then saves offsets.
tnhnrl 24:c7d9b5bf3829 87 - added new entry state NEUTRAL_FIRST_PITCH that also moves the battery toward level, but doesn't save.
tnhnrl 24:c7d9b5bf3829 88 Modified 2017-11-27 by Troy
tnhnrl 24:c7d9b5bf3829 89 - Fixed exit condition (restart at NEUTRAL_FIRST_PITCH)
tnhnrl 24:c7d9b5bf3829 90 - Pool tested, needed to run timer for longer than 5 minutes (neutral finding sequence timed out)
tnhnrl 24:c7d9b5bf3829 91 - IMU fell off tape
tnhnrl 24:c7d9b5bf3829 92 Modified 2017-11-28 Rev A by Dan/Troy
tnhnrl 24:c7d9b5bf3829 93 - Modified NEUTRAL_FIRST_PITCH to save the battery offset into the Pitch Outer Loop before beginning neutral finding sequence before sinking
tnhnrl 24:c7d9b5bf3829 94 - Pitch Outer Loop now runs NEUTRAL_SINKING and NEUTRAL_SLOWLY_RISE states (instead of batt fixed position control)
tnhnrl 24:c7d9b5bf3829 95 - NEUTRAL_SINKING has been changed to a 5-second timer (vice 10 seconds)
tnhnrl 24:c7d9b5bf3829 96 - NEUTRAL_SLOWLY_RISE has been changed to move the piston 2 mm each interval (vice 1 mm)
tnhnrl 24:c7d9b5bf3829 97 Modified 2017-11-28 Rev B by Dan/Troy
tnhnrl 24:c7d9b5bf3829 98 - Changed pitch rate margin from absolute value < 0.5 deg/sec to 5.0 deg/s
tnhnrl 24:c7d9b5bf3829 99 - Changed sink timer to move piston 5 mm at a time instead of 10 mm
tnhnrl 24:c7d9b5bf3829 100 - Find level motion will now run every 10 seconds instead of 5 seconds
tnhnrl 24:c7d9b5bf3829 101 - Created an integer array to do a quick check of what states Find Neutral sub-FSM ran through (press "c" to see states)
tnhnrl 24:c7d9b5bf3829 102 - FLOAT_BROADCAST now uses limits of battery and BCE from LinearActuator.getPosition
tnhnrl 24:c7d9b5bf3829 103 Modified 2017-11-28 Rev C by Dan/Troy
tnhnrl 24:c7d9b5bf3829 104 - State FIND_NEUTRAL sends pitch offset from file as first commanded
tnhnrl 24:c7d9b5bf3829 105 - NEUTRAL_FIRST_PITCH and NEUTRAL_CHECK_PITCH are now moving the battery mass with getSetPosition_mm command instead of the getPosition command
tnhnrl 24:c7d9b5bf3829 106 to allow the sub-FSM time to adequately move the battery mass
tnhnrl 24:c7d9b5bf3829 107 - Added "else if (substate == NEUTRAL_CHECK_PITCH)" to the NEUTRAL_FIRST_PITCH/NEUTRAL_CHECK_PITCH(NFP/NCP) state to confirm that NEUTRAL_CHECK_PITCH is working
tnhnrl 24:c7d9b5bf3829 108 - Added "else" to the NFP/NCP state as an error catching mechanism
tnhnrl 24:c7d9b5bf3829 109 - Modified NFP/NCP state to use pitchLoop().getPosition() instead of imu().getPitch() to use the filtered readings
tnhnrl 24:c7d9b5bf3829 110 - Added several "isSubStateTimerRunning = false;" statements to the sub-FSM exits to make sure the one-shot actions work in the next state! Definitely a fix.
tnhnrl 24:c7d9b5bf3829 111 - Reworked the exiting sub-FSM to be a little clearer.
tnhnrl 24:c7d9b5bf3829 112 - Moved the sub-state logger into all the sub-state transitions ... this should be done in FIND_NEUTRAL on sub-state changes instead (less copy/paste).
tnhnrl 39:58375ca6b6ff 113 Modified 2017-11-29 revA by Troy
tnhnrl 39:58375ca6b6ff 114 - changelog.txt carries previous changes
tnhnrl 39:58375ca6b6ff 115 - Incorporated email changes and did quick bench test
tnhnrl 39:58375ca6b6ff 116 1) In FIND_NEUTRAL, add bce().setPosition_mm(bceFloatPosition) to the one-shot actions after the unpause().
tnhnrl 39:58375ca6b6ff 117 2) NEUTRAL_FIRST_PITCH, changed batt position by half from 1.0 to 0.5.
tnhnrl 39:58375ca6b6ff 118 3) NEUTRAL_SINKING and NEUTRAL_SLOWLY_RISE are using getSetPosition now
tnhnrl 39:58375ca6b6ff 119 4) previousPosition_mm deleted (and print statements changed)
tnhnrl 39:58375ca6b6ff 120 5) NEUTRAL_SLOWLY_RISE check is using bce().getSetPosition_mm()
tnhnrl 39:58375ca6b6ff 121 6) Timers replaced with _neutral_timer variable
tnhnrl 39:58375ca6b6ff 122 7) Default timeout is 8 minutes = 480 seconds
tnhnrl 39:58375ca6b6ff 123 - Redid the sub-state recording method to only update on state changes
tnhnrl 39:58375ca6b6ff 124 Modified 2017-11-29 revB by Troy
tnhnrl 39:58375ca6b6ff 125 - minor print fixes
tnhnrl 39:58375ca6b6ff 126 Modified 2017-11-29 revC by Troy
tnhnrl 39:58375ca6b6ff 127 - removed depthTolerance variable that was not being used.
tnhnrl 39:58375ca6b6ff 128 Modified 2017-11-30 revA by Troy/Dan
tnhnrl 39:58375ca6b6ff 129 - Modified state RISE to setCommand to -1.0 feet (force out of water) and go to next state (float level) when above 0.5 feet
tnhnrl 39:58375ca6b6ff 130 - Modified sub-state NEUTRAL_SINKING to only move 2.5 mm per cycle instead of 5 mm
tnhnrl 39:58375ca6b6ff 131 - Commented out home function (accidentally hit home and got stuck while at LASR)
tnhnrl 39:58375ca6b6ff 132 - Added max depth neutral and dive variables
tnhnrl 39:58375ca6b6ff 133 - Print max recorded depths and current neutral buoyancy positions
tnhnrl 39:58375ca6b6ff 134 Modified 2017-11-30 revB by Troy/Dan
tnhnrl 39:58375ca6b6ff 135 - Dive and Multi-Dive cycles now exit to FLOAT_BROADCAST state
tnhnrl 39:58375ca6b6ff 136 - FLOAT_LEVEL pitchTolerance variable increased from 1.0 degree to 5.0 degrees (PV was difficult to level in LASR pool)
tnhnrl 39:58375ca6b6ff 137 - Added the ability to record the states of the FSM and print to user using keyboard "Z"
tnhnrl 39:58375ca6b6ff 138 Modified 2017-12-01 revA by Troy
tnhnrl 39:58375ca6b6ff 139 - Minor update to 2017-11-30 revB
tnhnrl 39:58375ca6b6ff 140 - Now printing current neutral battery and BCE setpoints and max depth in neutral and dive cycle with "C" (and current sensor data)
tnhnrl 39:58375ca6b6ff 141 - Pool-tested with successful dives.
tnhnrl 39:58375ca6b6ff 142 1) Dive working correctly. (And max dive tracker shows that it is reaching the correct commanded depth.)
tnhnrl 39:58375ca6b6ff 143 2) Float broadcast working correctly. (And we are now going directly from dive and rise to float broadcast.)
tnhnrl 39:58375ca6b6ff 144 3) Neutral sequence has PV diving with -10 to -20 degrees of pitch, battery command seems to be slow or inactive.
tnhnrl 39:58375ca6b6ff 145 3) Float broadcast working correctly.
tnhnrl 39:58375ca6b6ff 146 4) FSM tracker and sub-FSM tracker working.
tnhnrl 39:58375ca6b6ff 147 5) Antenna working until tail just under water (last depth recorded varies between 1.0 and 1.5 feet)
tnhnrl 39:58375ca6b6ff 148 Modified 2017-12-06 revA by Troy
tnhnrl 39:58375ca6b6ff 149 - Added "_isTimeoutRunning = false;" to the FIND_NEUTRAL successful exit case ("else if (runNeutralStateMachine() == NEUTRAL_EXIT)"
tnhnrl 39:58375ca6b6ff 150 1) This will reset the timeout when the PV has successfully found and saved the neutral BCE and battery positions
tnhnrl 39:58375ca6b6ff 151 - Successful dive and multi-dive sequences exit to FLOAT_BROADCAST state (fix was implemented in code that did not respond, reimplemented here)
tnhnrl 39:58375ca6b6ff 152 1) Also made the change to the SequenceController (which loads a file that has multiple sequences)
tnhnrl 39:58375ca6b6ff 153 - FIND_NEUTRAL starts in NEUTRAL_SINKING with fix on sub-FSM to start with NEUTRAL_SINKING (verified via mbed on bench)
tnhnrl 39:58375ca6b6ff 154 Modified 2017-12-07 revA by Troy
tnhnrl 39:58375ca6b6ff 155 - Using new neutral finding sequence, dive slowly, rise slowly, then check pitch (pitch is not active at all until final state)
tnhnrl 39:58375ca6b6ff 156 - Added additional print information (showing neutral parameters with "C")
tnhnrl 39:58375ca6b6ff 157 Modified 2017-12-07 revB by Troy
tnhnrl 39:58375ca6b6ff 158 - Momentum offsets reintroduced:
tnhnrl 39:58375ca6b6ff 159 1) CASE DIVE uses "else if (depthLoop().getPosition() > depthLoop().getCommand() - 0.5) { // including offset for low momentum approaches"
tnhnrl 39:58375ca6b6ff 160 2) CASE RISE uses "else if (depthLoop().getPosition() < depthLoop().getCommand() + 0.5) { // including offset for low momentum approaches"
tnhnrl 39:58375ca6b6ff 161 - Momentum on rise command does not exit properly, removed
tnhnrl 39:58375ca6b6ff 162 Modified 2017-12-11 revA by Troy
tnhnrl 39:58375ca6b6ff 163 - Added a logger function the main while loop
tnhnrl 39:58375ca6b6ff 164 - Added vectors (essentially resizable arrays) to hold the data in the State Machine because of memory limitations
tnhnrl 39:58375ca6b6ff 165 Modified 2017-12-12 revA by Troy
tnhnrl 39:58375ca6b6ff 166 - Logger directly implemented in StateMachine (records every 5 seconds)
tnhnrl 39:58375ca6b6ff 167 Modified 2017-12-12 revB by Troy
tnhnrl 39:58375ca6b6ff 168 - Logger fixes implemented in StateMachine, was not logging each state, fixed the reset
tnhnrl 39:58375ca6b6ff 169 - Made logger into a function call
tnhnrl 39:58375ca6b6ff 170 Modified 2017-12-13 revA by Troy
tnhnrl 39:58375ca6b6ff 171 - Added function to print log file to screen (tested on bench with multiple dives and timers)
tnhnrl 39:58375ca6b6ff 172 Modified 2017-12-18 revA by Troy
tnhnrl 39:58375ca6b6ff 173 - Redo of the code to stop opening and closing files each time
tnhnrl 39:58375ca6b6ff 174 - This should allow you to write to the open file, then close it once you exit the sequence back to SIT_IDLE
tnhnrl 39:58375ca6b6ff 175 - Start record in dive, end when you exit float broadcast...
tnhnrl 74:d281aaef9766 176 Modified 2018-07-23
tnhnrl 74:d281aaef9766 177 - Tested out multiple data transmission methods, most consistent was requesting data one packet at a time
tnhnrl 74:d281aaef9766 178 - Added more descriptive data to terminal output
tnhnrl 74:d281aaef9766 179 Modified 2018-08-02
tnhnrl 74:d281aaef9766 180 - Timing issue where servo jumps from 1710 to 1940, not clear why this deadband exist, need to do the math on this
tnhnrl 24:c7d9b5bf3829 181 */