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
Diff: StateMachine/StateMachine.hpp
- Revision:
- 32:f2f8ae34aadc
- Parent:
- 28:16c83a2fdefa
- Child:
- 33:29a4268fbc74
- Child:
- 34:9b66c5188051
--- a/StateMachine/StateMachine.hpp Wed Dec 06 22:45:23 2017 +0000 +++ b/StateMachine/StateMachine.hpp Wed Dec 20 13:52:50 2017 +0000 @@ -2,6 +2,8 @@ #define STATEMACHINE_HPP #include "mbed.h" +#include <vector> +#include "DirectoryList.h" extern "C" void mbed_reset(); // utilized to reset the mbed @@ -16,17 +18,20 @@ EMERGENCY_CLIMB, // bce position to full rise, batt position to full aft, exits when at surface MULTI_DIVE, // multi-dive sequence MULTI_RISE, // multi-rise sequence - KEYBOARD // "state" for tracking only + KEYBOARD, // "state" for tracking only + FIND_AUTO_NEUTRAL_DEPTH, + FIND_AUTO_NEUTRAL_PITCH }; // find_neutral finite state machine enumerations enum { - NEUTRAL_FIRST_PITCH, // NEW first state: find level by moving the battery NEUTRAL_SINKING, // increment the bce until really start sinking NEUTRAL_SLOWLY_RISE, // once sinking, arrest the sink NEUTRAL_CHECK_PITCH, // find level again, then save the data and exit - NEUTRAL_EXIT // sub-FSM has completed all checks + NEUTRAL_EXIT, // sub-FSM has completed all checks }; + +// test idea //struct for saving the data struct currentSequenceStruct { @@ -53,8 +58,11 @@ float getDepthCommand(); float getPitchCommand(); + float getDepthReading(); + float getPitchReading(); + float getTimerReading(); - int runNeutralStateMachine(); //substate returns the state (which is used in overall FSM) + int runNeutralStateMachine(); //substate returns the state (which is used in overall FSM) int getState(); void setState(int input_state); @@ -69,14 +77,30 @@ void getDiveSequence(); //used in multi-dive sequence with public variables for now + void runActiveNeutralStateMachine(); //new neutral substate returns the state (which is used in overall FSM) + + float * getLoggerArray(); //delete soon + + void recordData(); //record log data to file using MbedLogger class + void printDirectory(); + void recordState(int input_state); + void printCurrentSdLog(); //more tricky for SD card, work in progress + + void createNewFile(); + + void transmitData(); + private: int _timeout; // generic timeout for every state, seconds 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 + float _depth_command; // user keyboard depth + float _pitch_command; // user keyboard depth + float _depth_reading; // depth reading (to get the readings at the same time) + float _pitch_reading; // pitch reading (to get the readings at the same time) + float _timer_reading; // pitch reading (to get the readings at the same time) Timer timer; @@ -117,6 +141,20 @@ float _max_recorded_depth_neutral; float _max_recorded_depth_dive; + + float _neutral_sink_command_mm; //defaults for neutral finding sub-FSM + float _neutral_rise_command_mm; + float _neutral_pitch_command_mm; + + float _max_recorded_auto_neutral_depth; + + //float _logger_array[1048][5]; //array to hold the input, one log per dive (row/col) + bool _is_log_timer_running; + float _log_timer; + + float _data_log[9]; + + volatile bool _file_closed; }; #endif \ No newline at end of file