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
SequenceController/SequenceController.hpp@92:52a91656458a, 2019-05-13 (annotated)
- Committer:
- joel_ssc
- Date:
- Mon May 13 19:25:26 2019 +0000
- Revision:
- 92:52a91656458a
- Parent:
- 87:6d95f853dab3
version for first flight test, timeouts not yet set correctly
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tnhnrl | 17:7c16b5671d0e | 1 | #include "mbed.h" |
tnhnrl | 17:7c16b5671d0e | 2 | #include "ConfigFile.h" |
tnhnrl | 17:7c16b5671d0e | 3 | #include <string> //mbed doesn't use cstring |
tnhnrl | 17:7c16b5671d0e | 4 | |
tnhnrl | 17:7c16b5671d0e | 5 | #ifndef SEQUENCECONTROLLER_HPP |
tnhnrl | 17:7c16b5671d0e | 6 | #define SEQUENCECONTROLLER_HPP |
tnhnrl | 17:7c16b5671d0e | 7 | |
tnhnrl | 17:7c16b5671d0e | 8 | //struct for saving the data |
tnhnrl | 17:7c16b5671d0e | 9 | struct sequenceStruct { |
tnhnrl | 17:7c16b5671d0e | 10 | string title; |
tnhnrl | 17:7c16b5671d0e | 11 | int state; //for the current StateMachine, states are ID-ed with enumeration |
tnhnrl | 17:7c16b5671d0e | 12 | float timeout; |
tnhnrl | 17:7c16b5671d0e | 13 | float depth; |
tnhnrl | 17:7c16b5671d0e | 14 | float pitch; |
tnhnrl | 17:7c16b5671d0e | 15 | }; |
tnhnrl | 17:7c16b5671d0e | 16 | |
joel_ssc | 82:0981b9ada820 | 17 | //struct for saving the leg data |
joel_ssc | 82:0981b9ada820 | 18 | struct legStruct { |
joel_ssc | 82:0981b9ada820 | 19 | int state; //for the current StateMachine, states are ID-ed with enumeration |
joel_ssc | 82:0981b9ada820 | 20 | float timeout; |
joel_ssc | 82:0981b9ada820 | 21 | float yo_time; |
joel_ssc | 82:0981b9ada820 | 22 | float min_depth; |
joel_ssc | 82:0981b9ada820 | 23 | float max_depth; |
joel_ssc | 82:0981b9ada820 | 24 | float heading; |
joel_ssc | 82:0981b9ada820 | 25 | string title; |
joel_ssc | 82:0981b9ada820 | 26 | }; |
joel_ssc | 82:0981b9ada820 | 27 | |
tnhnrl | 17:7c16b5671d0e | 28 | class SequenceController { |
tnhnrl | 17:7c16b5671d0e | 29 | public: |
tnhnrl | 17:7c16b5671d0e | 30 | SequenceController(); |
tnhnrl | 17:7c16b5671d0e | 31 | |
tnhnrl | 17:7c16b5671d0e | 32 | sequenceStruct sequenceStructLoaded[256]; |
tnhnrl | 17:7c16b5671d0e | 33 | |
tnhnrl | 17:7c16b5671d0e | 34 | void loadSequence(); |
tnhnrl | 17:7c16b5671d0e | 35 | |
tnhnrl | 17:7c16b5671d0e | 36 | sequenceStruct process(string input_string); |
tnhnrl | 17:7c16b5671d0e | 37 | |
tnhnrl | 17:7c16b5671d0e | 38 | void sequenceFunction(); //process the sequence |
tnhnrl | 17:7c16b5671d0e | 39 | |
tnhnrl | 17:7c16b5671d0e | 40 | void setState(int input_state); //manually set the state of the system |
tnhnrl | 17:7c16b5671d0e | 41 | int getState(); |
tnhnrl | 17:7c16b5671d0e | 42 | void setTimeout(float input_timeout); |
tnhnrl | 17:7c16b5671d0e | 43 | void setDepthCommand(float input_depth_command); |
tnhnrl | 17:7c16b5671d0e | 44 | void setPitchCommand(float input_pitch_command); |
tnhnrl | 17:7c16b5671d0e | 45 | |
tnhnrl | 17:7c16b5671d0e | 46 | int getSequenceState(); |
tnhnrl | 17:7c16b5671d0e | 47 | |
tnhnrl | 17:7c16b5671d0e | 48 | private: |
tnhnrl | 17:7c16b5671d0e | 49 | char _neutral_sequence; |
tnhnrl | 17:7c16b5671d0e | 50 | char _dive_cycle; |
tnhnrl | 17:7c16b5671d0e | 51 | char _exit; |
tnhnrl | 17:7c16b5671d0e | 52 | |
tnhnrl | 17:7c16b5671d0e | 53 | int _number_of_sequences; |
tnhnrl | 17:7c16b5671d0e | 54 | int _sequence_counter; |
tnhnrl | 17:7c16b5671d0e | 55 | |
tnhnrl | 17:7c16b5671d0e | 56 | Ticker sequenceTicker; //Ticker for the sequenceFunction |
tnhnrl | 17:7c16b5671d0e | 57 | |
tnhnrl | 17:7c16b5671d0e | 58 | int _current_state; |
tnhnrl | 17:7c16b5671d0e | 59 | }; |
joel_ssc | 82:0981b9ada820 | 60 | class LegController { |
joel_ssc | 82:0981b9ada820 | 61 | public: |
joel_ssc | 82:0981b9ada820 | 62 | LegController(); |
joel_ssc | 82:0981b9ada820 | 63 | |
joel_ssc | 87:6d95f853dab3 | 64 | legStruct legStructLoaded[32]; |
joel_ssc | 82:0981b9ada820 | 65 | |
joel_ssc | 82:0981b9ada820 | 66 | int loadLeg(); |
joel_ssc | 82:0981b9ada820 | 67 | |
joel_ssc | 82:0981b9ada820 | 68 | legStruct process(string input_string); |
joel_ssc | 82:0981b9ada820 | 69 | legStruct load_def_leg(); //make sure defaults are in the leg structure |
joel_ssc | 82:0981b9ada820 | 70 | |
joel_ssc | 82:0981b9ada820 | 71 | void legFunction(); //process the sequence |
joel_ssc | 82:0981b9ada820 | 72 | |
joel_ssc | 82:0981b9ada820 | 73 | void setState(int input_state); //manually set the state of the system |
joel_ssc | 82:0981b9ada820 | 74 | int getState(); |
joel_ssc | 82:0981b9ada820 | 75 | void setTimeout(float input_timeout); |
joel_ssc | 82:0981b9ada820 | 76 | void setDepthCommand(float input_depth_command); |
joel_ssc | 82:0981b9ada820 | 77 | void setPitchCommand(float input_pitch_command); |
joel_ssc | 82:0981b9ada820 | 78 | |
joel_ssc | 82:0981b9ada820 | 79 | int getLegState(); |
joel_ssc | 82:0981b9ada820 | 80 | |
joel_ssc | 82:0981b9ada820 | 81 | private: |
joel_ssc | 82:0981b9ada820 | 82 | char _neutral_sequence; |
joel_ssc | 82:0981b9ada820 | 83 | char _dive_cycle; |
joel_ssc | 82:0981b9ada820 | 84 | char _exit; |
joel_ssc | 82:0981b9ada820 | 85 | |
joel_ssc | 82:0981b9ada820 | 86 | int _number_of_legs; |
joel_ssc | 82:0981b9ada820 | 87 | int _leg_counter; |
joel_ssc | 82:0981b9ada820 | 88 | |
joel_ssc | 82:0981b9ada820 | 89 | Ticker sequenceTicker; //Ticker for the sequenceFunction |
joel_ssc | 82:0981b9ada820 | 90 | |
joel_ssc | 82:0981b9ada820 | 91 | int _current_state; |
joel_ssc | 82:0981b9ada820 | 92 | }; |
tnhnrl | 17:7c16b5671d0e | 93 | #endif |