Library containing Crazyflie 2.0 controller classes: - Attitude estimator - Horizontal estimator - Vertical estimator - Attitude controller - Horizontal controller - Vertical controller - Mixer

Parameters/Parameters.h

Committer:
fbob
Date:
2018-10-18
Revision:
20:4d0614886c80
Parent:
19:83b357d6806e
Child:
21:169cc2b1d2ff

File content as of revision 20:4d0614886c80:

#ifndef Parameters_h
#define Parameters_h

// Interrupt frequencies
const float f = 500.0f;             // Hz
const float f_range = 20.0f;        // Hz 
const float f_flow = 200.0f;        // Hz 
const float dt = 1.0f/f;            // s
const float dt_range = 1.0f/f_range;// s
const float dt_flow = 1.0f/f_flow;  // s 

// Motor constants 
const float alpha = 1.16e-07f;
const float beta = 7.149e-10f;

// Propeller constants
const float kl = 1.726e-08f;        // N.s^2/rad^2
const float kd = 1.426e-10f;        // N.m.s^2/rad^2

// Quadcopter dimensions
const float l = 0.033f;             // m
const float m = 0.030f;             // kg
const float I_xx = 16.0e-6f;        // kg.m^2
const float I_yy = 16.0e-6f;        // kg.m^2
const float I_zz = 29.0e-6f;        // kg.m^2

// Gravity constant
const float pi = 3.1416f;
const float g = 9.81f;              // m/s^2

// Attitude estimator weighthing (accelerometer X gyroscope)
const float rho_att = 0.01f;        

// Attitude controller gains (roll/pitch)
const float Ts_phi = 0.32f;         // s
const float OS_phi = 0.0043f;       // %
const float zeta_phi = abs(log(OS_phi))/sqrt(pow(log(OS_phi),2)+pow(pi,2));
const float omega_n_phi = 4.0f/(Ts_phi*zeta_phi);
const float K_phi = pow(omega_n_phi,2.0f);       
const float K_p = 2.0f*zeta_phi*omega_n_phi; 
const float K_theta = K_phi;       
const float K_q = K_p; 

// Attitude controller gains (yaw)
const float Ts_psi = 0.8f;          // s
const float OS_psi = 0.0432f;       // %
const float zeta_psi = abs(log(OS_psi))/sqrt(pow(log(OS_psi),2)+pow(pi,2));
const float omega_n_psi = 4.0f/(Ts_psi*zeta_psi);
const float K_psi = pow(omega_n_psi,2.0f);       
const float K_r = 2.0f*zeta_psi*omega_n_psi; 

// Attitude controller time constants
const float T_phi = 0.12f;          // s
const float T_theta = 0.12f;        // s
const float T_psi = 0.2f;           // s
const float T_p = 0.04f;            // s
const float T_q = 0.04f;            // s
const float T_r = 0.1f;             // s

// Vertical estimator weighthing (measurement X prediction)
const float rho_ver = 0.3f;        

// Vertical controller gains
const float Ts_z = 2.8571f;         // s
const float OS_z = 0.0460f;          // %
const float zeta_z = abs(log(OS_z))/sqrt(pow(log(OS_z),2)+pow(pi,2));
const float omega_n_z = 4.0f/(Ts_z*zeta_z);
const float K_z = pow(omega_n_z,2.0f);       
const float K_w = 2.0f*zeta_z*omega_n_z; 

// Vertical controller gains
const float zeta_take_off = 1.4f;     
const float omega_n_take_off = 2.0f;// rad/s
const float K_z_take_off = pow(omega_n_take_off,2.0f);       
const float K_w_take_off = 2.0f*zeta_take_off*omega_n_take_off;  

// Horizontal estimator weighthing (measurement X prediction)
const float rho_hor = 0.5f;   

// Horizontal controller gains
const float Ts_x = 8.0f;         // s
const float zeta_x = 1.118;
const float omega_n_x = 4.0f/(Ts_x*zeta_x);
const float K_x = pow(omega_n_x,2.0f);       
const float K_u = 2.0f*zeta_x*omega_n_x; 
const float K_y = K_x;       
const float K_v = K_v; 

// Horizontal controller time constants
const float T_u = 2.0f;             // s  
const float T_v = 2.0f;             // s
const float T_u_take_off = 4.0f;    // s  
const float T_v_take_off = 4.0f;    // s

#endif