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:
Wed Nov 29 15:19:14 2017 +0000
Revision:
24:c7d9b5bf3829
Child:
39:58375ca6b6ff
Xbee / Pool version of code with latest code morning of 11/29/17

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 24:c7d9b5bf3829 113 */