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:
Mon Nov 06 22:57:56 2017 +0000
Revision:
16:3363b9f14913
Child:
17:7c16b5671d0e
Update to FSG test program used in the LASR pool

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tnhnrl 16:3363b9f14913 1 #ifndef STATEMACHINE_HPP
tnhnrl 16:3363b9f14913 2 #define STATEMACHINE_HPP
tnhnrl 16:3363b9f14913 3
tnhnrl 16:3363b9f14913 4 #include "mbed.h"
tnhnrl 16:3363b9f14913 5 //#include "StaticDefs.hpp"
tnhnrl 16:3363b9f14913 6
tnhnrl 16:3363b9f14913 7 extern "C" void mbed_reset(); // utilized to reset the mbed
tnhnrl 16:3363b9f14913 8
tnhnrl 16:3363b9f14913 9 // state enumerations
tnhnrl 16:3363b9f14913 10 enum {
tnhnrl 16:3363b9f14913 11 SIT_IDLE, // stops both motors, exits after a keyboard input
tnhnrl 16:3363b9f14913 12 KEYBOARD, // handles an individual keypress, exits to state by a keyboard menu
tnhnrl 16:3363b9f14913 13 FIND_NEUTRAL, // dives to depth at zero pitch, exits when stable
tnhnrl 16:3363b9f14913 14 DIVE, // dives to depth at negative pitch, exits when crossing a defined depth
tnhnrl 16:3363b9f14913 15 RISE, // rises to surface at positive pitch, exits when near surface
tnhnrl 16:3363b9f14913 16 FLOAT_LEVEL, // bce position to float, pitch loop active at zero, exits when stable near zero pitch
tnhnrl 16:3363b9f14913 17 FLOAT_BROADCAST, // bce position to float, batt position forward to hold tail up, exits when actuators done
tnhnrl 16:3363b9f14913 18 EMERGENCY_CLIMB // bce position to full rise, batt position to full aft, exits when at surface
tnhnrl 16:3363b9f14913 19 };
tnhnrl 16:3363b9f14913 20
tnhnrl 16:3363b9f14913 21 class StateMachine {
tnhnrl 16:3363b9f14913 22 public:
tnhnrl 16:3363b9f14913 23 StateMachine();
tnhnrl 16:3363b9f14913 24
tnhnrl 16:3363b9f14913 25 void runStateMachine();
tnhnrl 16:3363b9f14913 26
tnhnrl 16:3363b9f14913 27 void showMenu();
tnhnrl 16:3363b9f14913 28
tnhnrl 16:3363b9f14913 29 int keyboard();
tnhnrl 16:3363b9f14913 30
tnhnrl 16:3363b9f14913 31 void keyboard_menu_BCE_PID_settings();
tnhnrl 16:3363b9f14913 32 void keyboard_menu_BATT_PID_settings();
tnhnrl 16:3363b9f14913 33 void keyboard_menu_DEPTH_PID_settings();
tnhnrl 16:3363b9f14913 34 void keyboard_menu_PITCH_PID_settings();
tnhnrl 16:3363b9f14913 35
tnhnrl 16:3363b9f14913 36 float getDepthCommand();
tnhnrl 16:3363b9f14913 37 float getPitchCommand();
tnhnrl 16:3363b9f14913 38
tnhnrl 16:3363b9f14913 39 private:
tnhnrl 16:3363b9f14913 40 int timeout; // generic timeout for every state, seconds
tnhnrl 16:3363b9f14913 41 float depthTolerance; // depth tolerance for neutral finding exit critera
tnhnrl 16:3363b9f14913 42 float pitchTolerance; // pitch angle tolerance for neutral finding exit criteria
tnhnrl 16:3363b9f14913 43 float bceFloatPosition; // bce position for "float" states
tnhnrl 16:3363b9f14913 44 float battFloatPosition; // batt position for "broadcast" state
tnhnrl 16:3363b9f14913 45
tnhnrl 16:3363b9f14913 46 float depthCommand; // user keyboard depth
tnhnrl 16:3363b9f14913 47 float pitchCommand; // user keyboard depth
tnhnrl 16:3363b9f14913 48
tnhnrl 16:3363b9f14913 49 Timer timer;
tnhnrl 16:3363b9f14913 50 };
tnhnrl 16:3363b9f14913 51
tnhnrl 16:3363b9f14913 52 #endif