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:
- 82:0981b9ada820
- Parent:
- 80:4e5d306d695b
- Child:
- 84:eccd8e837134
--- a/StateMachine/StateMachine.hpp Thu Nov 08 22:30:32 2018 +0000 +++ b/StateMachine/StateMachine.hpp Fri Feb 15 16:00:17 2019 +0000 @@ -21,8 +21,11 @@ MULTI_DIVE, // multi-dive sequence MULTI_RISE, // multi-rise sequence KEYBOARD, // "state" for tracking only + LEG_POSITION_DIVE, // leg has heading and min,max depths and timeout + LEG_POSITION_RISE, TX_MBED_LOG, - RX_SEQUENCE + RX_SEQUENCE, + FB_EXIT }; // find_neutral finite state machine enumerations @@ -42,6 +45,15 @@ float depth; float pitch; }; +//new struct for saving the leg data +struct currentLegStruct { + int state; //for the current StateMachine, states are ID-ed with enumeration + float timeout; + float yo_time; + float min_depth; + float max_depth; + float heading; +}; class StateMachine { public: @@ -85,6 +97,7 @@ void setNeutralPositions(float batt_pos_mm, float bce_pos_mm); void getDiveSequence(); //used in multi-dive sequence with public variables for now + void getLegParams(); //used in multi-leg sequence with public variables for now void runActiveNeutralStateMachine(); //new neutral substate returns the state (which is used in overall FSM) @@ -108,6 +121,7 @@ bool _debug_menu_on; // default is false to show simple menu, debug allows more tuning and has a lot of keyboard commands int _timeout; // generic timeout for every state, seconds + int _yo_time; // time allowed for one up or down in a leg of yo-yos float _pitchTolerance; // pitch angle tolerance for neutral finding exit criteria float _bceFloatPosition; // bce position for "float" states float _battFloatPosition; // batt position for "broadcast" state @@ -121,6 +135,7 @@ float _timer_reading; // pitch reading (to get the readings at the same time) Timer _fsm_timer; //timing variable used in class + Timer _yotimer; // timer for each yo in a yoyo leg volatile int _state; // current state of Finite State Machine (FSM) int _previous_state; // record previous state @@ -136,8 +151,10 @@ float _neutral_batt_pos_mm; int _multi_dive_counter; + int _multi_leg_counter; currentSequenceStruct currentStateStruct; //type_of_struct struct_name + currentLegStruct currentLegStateStruct; //type_of_struct struct_name float _depth_KP; float _depth_KI;