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

StateMachine/StateMachine.hpp

Committer:
tnhnrl
Date:
2017-11-06
Revision:
16:3363b9f14913
Child:
17:7c16b5671d0e

File content as of revision 16:3363b9f14913:

#ifndef STATEMACHINE_HPP
#define STATEMACHINE_HPP

#include "mbed.h"
//#include "StaticDefs.hpp"

extern "C" void mbed_reset();           // utilized to reset the mbed

// state enumerations
enum {
    SIT_IDLE,           // stops both motors, exits after a keyboard input
    KEYBOARD,           // handles an individual keypress, exits to state by a keyboard menu
    FIND_NEUTRAL,       // dives to depth at zero pitch, exits when stable
    DIVE,               // dives to depth at negative pitch, exits when crossing a defined depth
    RISE,               // rises to surface at positive pitch, exits when near surface
    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
};

class StateMachine {
public:
    StateMachine();
    
    void runStateMachine();
    
    void showMenu();
    
    int keyboard();
    
    void keyboard_menu_BCE_PID_settings();
    void keyboard_menu_BATT_PID_settings();
    void keyboard_menu_DEPTH_PID_settings();
    void keyboard_menu_PITCH_PID_settings();
    
    float getDepthCommand();
    float getPitchCommand();
    
private:
    int timeout;                // generic timeout for every state, seconds
    float depthTolerance;       // depth tolerance for neutral finding exit critera
    float pitchTolerance;       // pitch angle tolerance for neutral finding exit criteria
    float bceFloatPosition;     // bce position for "float" states
    float battFloatPosition;    // batt position for "broadcast" state
    
    float depthCommand;         // user keyboard depth
    float pitchCommand;         // user keyboard depth
    
    Timer timer;
};

#endif