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:
- 28:16c83a2fdefa
- Parent:
- 27:0a5b90cd65d6
- Child:
- 32:f2f8ae34aadc
--- a/StateMachine/StateMachine.hpp Wed Nov 29 22:37:47 2017 +0000 +++ b/StateMachine/StateMachine.hpp Fri Dec 01 22:43:14 2017 +0000 @@ -15,7 +15,8 @@ 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 MULTI_DIVE, // multi-dive sequence - MULTI_RISE // multi-rise sequence + MULTI_RISE, // multi-rise sequence + KEYBOARD // "state" for tracking only }; // find_neutral finite state machine enumerations @@ -55,8 +56,9 @@ int runNeutralStateMachine(); //substate returns the state (which is used in overall FSM) + int getState(); void setState(int input_state); - int getState(); + void setTimeout(float input_timeout); void setDepthCommand(float input_depth_command); void setPitchCommand(float input_pitch_command); @@ -69,28 +71,30 @@ 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 _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 _depthCommand; // user keyboard depth + float _pitchCommand; // user keyboard depth Timer timer; int _state; // Fine State Machine (FSM) state + int _previous_state; // record previous state int _sub_state; // substate on find_neutral function int _previous_sub_state; // previous substate so that what goes into the sub-state is not being changed as it is processed float _neutral_timer; // keep time for rise/sink/level timer incremnets - bool isTimeoutRunning; + bool _isTimeoutRunning; - bool isSubStateTimerRunning; + bool _isSubStateTimerRunning; float _neutral_bce_pos_mm; float _neutral_batt_pos_mm; int _multi_dive_counter; + currentSequenceStruct currentStateStruct; //type_of_struct struct_name bool _neutral_sub_state_active; // controls neutral_sub_state @@ -102,11 +106,17 @@ float _pitch_KP; float _pitch_KI; float _pitch_KD; + + int _state_array[1024]; //used to print out the states + int _state_array_counter; //used to iterate through state records + int _substate_array[1024]; //used to print out the sub-states + int _substate_array_counter; //used to iterate through sub-state records - int _state_array[1024]; //used to print out the states - int _state_array_counter; //variables used to record NEUTRAL sub-FSM states int _substate; int _previous_substate; + + float _max_recorded_depth_neutral; + float _max_recorded_depth_dive; }; #endif \ No newline at end of file