![](/media/cache/profiles/8158fa3e4de806e614f7ff02e7b22fde.jpg.50x50_q85.png)
New version of quadcopter software written to OO principles
Dependencies: mbed MODSERIAL filter mbed-rtos ConfigFile PID PPM FreeIMU_external_magnetometer TinyGPS
NavigationController/NavigationController.h@4:9ffbf9101992, 2015-05-08 (annotated)
- Committer:
- joe4465
- Date:
- Fri May 08 09:07:38 2015 +0000
- Revision:
- 4:9ffbf9101992
- Parent:
- 2:969dfa4f2436
End of FYP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joe4465 | 2:969dfa4f2436 | 1 | #ifndef NavigationController_H |
joe4465 | 2:969dfa4f2436 | 2 | #define NavigationController_H |
joe4465 | 2:969dfa4f2436 | 3 | |
joe4465 | 2:969dfa4f2436 | 4 | #include "mbed.h" |
joe4465 | 2:969dfa4f2436 | 5 | #include "Global.h" |
joe4465 | 2:969dfa4f2436 | 6 | #include "Status.h" |
joe4465 | 2:969dfa4f2436 | 7 | #include "rtos.h" |
joe4465 | 2:969dfa4f2436 | 8 | #include "Rc.h" |
joe4465 | 2:969dfa4f2436 | 9 | #include "Sensors.h" |
joe4465 | 2:969dfa4f2436 | 10 | #include "AltitudeController.h" |
joe4465 | 2:969dfa4f2436 | 11 | #include "ConfigFileWrapper.h" |
joe4465 | 2:969dfa4f2436 | 12 | |
joe4465 | 2:969dfa4f2436 | 13 | class NavigationController |
joe4465 | 2:969dfa4f2436 | 14 | { |
joe4465 | 2:969dfa4f2436 | 15 | public: |
joe4465 | 2:969dfa4f2436 | 16 | NavigationController(Status& status, Sensors& sensors, Rc& rc, ConfigFileWrapper& configFileWrapper); |
joe4465 | 2:969dfa4f2436 | 17 | ~NavigationController(); |
joe4465 | 2:969dfa4f2436 | 18 | |
joe4465 | 2:969dfa4f2436 | 19 | struct SetPoint |
joe4465 | 2:969dfa4f2436 | 20 | { |
joe4465 | 2:969dfa4f2436 | 21 | double yaw; |
joe4465 | 2:969dfa4f2436 | 22 | double pitch; |
joe4465 | 2:969dfa4f2436 | 23 | double roll; |
joe4465 | 2:969dfa4f2436 | 24 | double throttle; |
joe4465 | 2:969dfa4f2436 | 25 | double yawTarget; |
joe4465 | 2:969dfa4f2436 | 26 | double yawDifference; |
joe4465 | 2:969dfa4f2436 | 27 | double climbRate; |
joe4465 | 2:969dfa4f2436 | 28 | double targetAltitude; |
joe4465 | 2:969dfa4f2436 | 29 | }; |
joe4465 | 2:969dfa4f2436 | 30 | |
joe4465 | 2:969dfa4f2436 | 31 | SetPoint getSetPoint(); |
joe4465 | 2:969dfa4f2436 | 32 | void updateYawTarget(); |
joe4465 | 2:969dfa4f2436 | 33 | void updateAltitudeTarget(); |
joe4465 | 2:969dfa4f2436 | 34 | PidWrapper::NavigationControllerPidParameters getPidParameters(); |
joe4465 | 2:969dfa4f2436 | 35 | void setAltitudeRatePidParameters(PidWrapper::PidParameter pidParameters); |
joe4465 | 2:969dfa4f2436 | 36 | void setAltitudeStabPidParameters(PidWrapper::PidParameter pidParameters); |
joe4465 | 2:969dfa4f2436 | 37 | |
joe4465 | 2:969dfa4f2436 | 38 | private: |
joe4465 | 2:969dfa4f2436 | 39 | static void threadStarter(void const *p); |
joe4465 | 2:969dfa4f2436 | 40 | void threadWorker(); |
joe4465 | 2:969dfa4f2436 | 41 | double map(double input, double inputMin, double inputMax, double outputMin, double outputMax); |
joe4465 | 2:969dfa4f2436 | 42 | |
joe4465 | 2:969dfa4f2436 | 43 | Thread* _thread; |
joe4465 | 2:969dfa4f2436 | 44 | Status& _status; |
joe4465 | 2:969dfa4f2436 | 45 | Sensors& _sensors; |
joe4465 | 2:969dfa4f2436 | 46 | Rc& _rc; |
joe4465 | 2:969dfa4f2436 | 47 | ConfigFileWrapper& _configFileWrapper; |
joe4465 | 2:969dfa4f2436 | 48 | void saveSettings(); |
joe4465 | 2:969dfa4f2436 | 49 | SetPoint _setPoints; |
joe4465 | 2:969dfa4f2436 | 50 | AltitudeController* _altitudeController; |
joe4465 | 2:969dfa4f2436 | 51 | Status::State _state; |
joe4465 | 2:969dfa4f2436 | 52 | Status::NavigationMode _navigationMode; |
joe4465 | 2:969dfa4f2436 | 53 | Rc::MappedRc _mappedRc; |
joe4465 | 2:969dfa4f2436 | 54 | Imu::Angle _angle; |
joe4465 | 2:969dfa4f2436 | 55 | Sensors::Altitude _altitude; |
joe4465 | 2:969dfa4f2436 | 56 | double _altitudeHoldPidOutput; |
joe4465 | 2:969dfa4f2436 | 57 | }; |
joe4465 | 2:969dfa4f2436 | 58 | |
joe4465 | 2:969dfa4f2436 | 59 | #endif |