Library containing Crazyflie 2.0 controller classes: - Attitude estimator - Horizontal estimator - Vertical estimator - Attitude controller - Horizontal controller - Vertical controller - Mixer
AttitudeController/AttitudeController.h@0:b1f2c9e88e32, 2018-08-31 (annotated)
- Committer:
- fbob
- Date:
- Fri Aug 31 18:41:31 2018 +0000
- Revision:
- 0:b1f2c9e88e32
- Child:
- 2:7e01bc32bf4c
Include attitude controller, attitude estimator and mixer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fbob | 0:b1f2c9e88e32 | 1 | #ifndef AttitudeController_h |
fbob | 0:b1f2c9e88e32 | 2 | #define AttitudeController_h |
fbob | 0:b1f2c9e88e32 | 3 | |
fbob | 0:b1f2c9e88e32 | 4 | #include "mbed.h" |
fbob | 0:b1f2c9e88e32 | 5 | |
fbob | 0:b1f2c9e88e32 | 6 | // Controller gains |
fbob | 0:b1f2c9e88e32 | 7 | float const K_phi = 6.25f; |
fbob | 0:b1f2c9e88e32 | 8 | float const K_theta = 6.25f; |
fbob | 0:b1f2c9e88e32 | 9 | float const K_psi = 5.0f; |
fbob | 0:b1f2c9e88e32 | 10 | float const K_p = 25.0f; |
fbob | 0:b1f2c9e88e32 | 11 | float const K_q = 25.0f; |
fbob | 0:b1f2c9e88e32 | 12 | float const K_r = 10.0f; |
fbob | 0:b1f2c9e88e32 | 13 | |
fbob | 0:b1f2c9e88e32 | 14 | // Quadcopter moments of inertia |
fbob | 0:b1f2c9e88e32 | 15 | float const I_xx = 16.0e-6f; |
fbob | 0:b1f2c9e88e32 | 16 | float const I_yy = 16.0e-6f; |
fbob | 0:b1f2c9e88e32 | 17 | float const I_zz = 29.0e-6f; |
fbob | 0:b1f2c9e88e32 | 18 | |
fbob | 0:b1f2c9e88e32 | 19 | class AttitudeController |
fbob | 0:b1f2c9e88e32 | 20 | { |
fbob | 0:b1f2c9e88e32 | 21 | public: |
fbob | 0:b1f2c9e88e32 | 22 | // Class constructor |
fbob | 0:b1f2c9e88e32 | 23 | AttitudeController(); |
fbob | 0:b1f2c9e88e32 | 24 | // Calculate torques given reference angles and current angles and rates |
fbob | 0:b1f2c9e88e32 | 25 | void calculate(float phi_r, float theta_r, float psi_r, float phi, float theta, float psi, float p, float q, float r); |
fbob | 0:b1f2c9e88e32 | 26 | // Torques (N.m) |
fbob | 0:b1f2c9e88e32 | 27 | float tau_phi, tau_theta, tau_psi; |
fbob | 0:b1f2c9e88e32 | 28 | private: |
fbob | 0:b1f2c9e88e32 | 29 | // Calculate torque given reference angle and current angle and rate (with given gains and moment of inertia) |
fbob | 0:b1f2c9e88e32 | 30 | float calculate_single(float angle_r, float angle, float rate, float K_angle, float K_rate, float I); |
fbob | 0:b1f2c9e88e32 | 31 | |
fbob | 0:b1f2c9e88e32 | 32 | }; |
fbob | 0:b1f2c9e88e32 | 33 | |
fbob | 0:b1f2c9e88e32 | 34 | #endif |