![](/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
Global/PidWrapper/PidWrapper.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 | #include "mbed.h" |
joe4465 | 2:969dfa4f2436 | 2 | #include "Global.h" |
joe4465 | 2:969dfa4f2436 | 3 | #include "PID.h" |
joe4465 | 2:969dfa4f2436 | 4 | |
joe4465 | 2:969dfa4f2436 | 5 | #ifndef PidWrapper_H |
joe4465 | 2:969dfa4f2436 | 6 | #define PidWrapper_H |
joe4465 | 2:969dfa4f2436 | 7 | |
joe4465 | 2:969dfa4f2436 | 8 | class PidWrapper // begin declaration of the class |
joe4465 | 2:969dfa4f2436 | 9 | { |
joe4465 | 2:969dfa4f2436 | 10 | public: // begin public section |
joe4465 | 2:969dfa4f2436 | 11 | PidWrapper(); // constructor |
joe4465 | 2:969dfa4f2436 | 12 | ~PidWrapper(); |
joe4465 | 2:969dfa4f2436 | 13 | |
joe4465 | 2:969dfa4f2436 | 14 | struct PidOutput |
joe4465 | 2:969dfa4f2436 | 15 | { |
joe4465 | 2:969dfa4f2436 | 16 | double yaw; |
joe4465 | 2:969dfa4f2436 | 17 | double pitch; |
joe4465 | 2:969dfa4f2436 | 18 | double roll; |
joe4465 | 2:969dfa4f2436 | 19 | }; |
joe4465 | 2:969dfa4f2436 | 20 | |
joe4465 | 2:969dfa4f2436 | 21 | struct PidParameter |
joe4465 | 2:969dfa4f2436 | 22 | { |
joe4465 | 2:969dfa4f2436 | 23 | double p; |
joe4465 | 2:969dfa4f2436 | 24 | double i; |
joe4465 | 2:969dfa4f2436 | 25 | double d; |
joe4465 | 2:969dfa4f2436 | 26 | }; |
joe4465 | 2:969dfa4f2436 | 27 | |
joe4465 | 2:969dfa4f2436 | 28 | struct PidState |
joe4465 | 2:969dfa4f2436 | 29 | { |
joe4465 | 2:969dfa4f2436 | 30 | double setPoint; |
joe4465 | 2:969dfa4f2436 | 31 | double processValue; |
joe4465 | 2:969dfa4f2436 | 32 | double output; |
joe4465 | 2:969dfa4f2436 | 33 | }; |
joe4465 | 2:969dfa4f2436 | 34 | |
joe4465 | 2:969dfa4f2436 | 35 | struct FlightControllerPidParameters |
joe4465 | 2:969dfa4f2436 | 36 | { |
joe4465 | 2:969dfa4f2436 | 37 | PidParameter yawRate; |
joe4465 | 2:969dfa4f2436 | 38 | PidParameter pitchRate; |
joe4465 | 2:969dfa4f2436 | 39 | PidParameter rollRate; |
joe4465 | 2:969dfa4f2436 | 40 | PidParameter yawStab; |
joe4465 | 2:969dfa4f2436 | 41 | PidParameter pitchStab; |
joe4465 | 2:969dfa4f2436 | 42 | PidParameter rollStab; |
joe4465 | 2:969dfa4f2436 | 43 | }; |
joe4465 | 2:969dfa4f2436 | 44 | |
joe4465 | 2:969dfa4f2436 | 45 | struct NavigationControllerPidParameters |
joe4465 | 2:969dfa4f2436 | 46 | { |
joe4465 | 2:969dfa4f2436 | 47 | PidParameter altitudeRate; |
joe4465 | 2:969dfa4f2436 | 48 | PidParameter altitudeStab; |
joe4465 | 2:969dfa4f2436 | 49 | }; |
joe4465 | 2:969dfa4f2436 | 50 | |
joe4465 | 2:969dfa4f2436 | 51 | struct RatePidState |
joe4465 | 2:969dfa4f2436 | 52 | { |
joe4465 | 2:969dfa4f2436 | 53 | PidState yawRate; |
joe4465 | 2:969dfa4f2436 | 54 | PidState pitchRate; |
joe4465 | 2:969dfa4f2436 | 55 | PidState rollRate; |
joe4465 | 2:969dfa4f2436 | 56 | }; |
joe4465 | 2:969dfa4f2436 | 57 | |
joe4465 | 2:969dfa4f2436 | 58 | struct StabPidState |
joe4465 | 2:969dfa4f2436 | 59 | { |
joe4465 | 2:969dfa4f2436 | 60 | PidState yawRate; |
joe4465 | 2:969dfa4f2436 | 61 | PidState pitchRate; |
joe4465 | 2:969dfa4f2436 | 62 | PidState rollRate; |
joe4465 | 2:969dfa4f2436 | 63 | PidState yawStab; |
joe4465 | 2:969dfa4f2436 | 64 | PidState pitchStab; |
joe4465 | 2:969dfa4f2436 | 65 | PidState rollStab; |
joe4465 | 2:969dfa4f2436 | 66 | }; |
joe4465 | 2:969dfa4f2436 | 67 | |
joe4465 | 2:969dfa4f2436 | 68 | bool initialise(PidParameter pidParameter, double inputMin, double inputMax, double outputMin, double outputMax, float updateTime); |
joe4465 | 2:969dfa4f2436 | 69 | double compute(double setPoint, double processValue); |
joe4465 | 2:969dfa4f2436 | 70 | PidWrapper::PidParameter getPidParameters(); |
joe4465 | 2:969dfa4f2436 | 71 | void reset(); |
joe4465 | 2:969dfa4f2436 | 72 | void setPidParameters(PidWrapper::PidParameter pidParameters); |
joe4465 | 2:969dfa4f2436 | 73 | void setBias(float bias); |
joe4465 | 2:969dfa4f2436 | 74 | |
joe4465 | 2:969dfa4f2436 | 75 | private: |
joe4465 | 2:969dfa4f2436 | 76 | PID* _pid; |
joe4465 | 2:969dfa4f2436 | 77 | }; |
joe4465 | 2:969dfa4f2436 | 78 | |
joe4465 | 2:969dfa4f2436 | 79 | #endif |