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

Committer:
fbob
Date:
Fri Aug 31 18:41:31 2018 +0000
Revision:
0:b1f2c9e88e32
Child:
1:24effec9e9aa
Include attitude controller, attitude estimator and mixer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fbob 0:b1f2c9e88e32 1 #ifndef AttitudeEstimator_h
fbob 0:b1f2c9e88e32 2 #define AttitudeEstimator_h
fbob 0:b1f2c9e88e32 3
fbob 0:b1f2c9e88e32 4 #include "mbed.h"
fbob 0:b1f2c9e88e32 5 #include "MPU9250.h"
fbob 0:b1f2c9e88e32 6
fbob 0:b1f2c9e88e32 7 // Estimator constants
fbob 0:b1f2c9e88e32 8 float const rho = 0.05f;
fbob 0:b1f2c9e88e32 9 float const dt = 0.005f;
fbob 0:b1f2c9e88e32 10
fbob 0:b1f2c9e88e32 11 // Attitude estimator class
fbob 0:b1f2c9e88e32 12 class AttitudeEstimator
fbob 0:b1f2c9e88e32 13 {
fbob 0:b1f2c9e88e32 14 public:
fbob 0:b1f2c9e88e32 15 // Class constructor
fbob 0:b1f2c9e88e32 16 AttitudeEstimator();
fbob 0:b1f2c9e88e32 17 // Initialize class
fbob 0:b1f2c9e88e32 18 void init();
fbob 0:b1f2c9e88e32 19 // Estimate Euler angles (rad) and angular velocities (rad/s)
fbob 0:b1f2c9e88e32 20 void estimate();
fbob 0:b1f2c9e88e32 21 // Euler angles (rad)
fbob 0:b1f2c9e88e32 22 float phi, theta, psi;
fbob 0:b1f2c9e88e32 23 // Angular velocities (rad/s)
fbob 0:b1f2c9e88e32 24 float p, q, r;
fbob 0:b1f2c9e88e32 25 private:
fbob 0:b1f2c9e88e32 26 // IMU sensor object
fbob 0:b1f2c9e88e32 27 MPU9250 imu;
fbob 0:b1f2c9e88e32 28 // Calibrates gyroscope by calculating angular velocity bias (rad/s)
fbob 0:b1f2c9e88e32 29 void calibrate_gyro();
fbob 0:b1f2c9e88e32 30 // Estimate Euler angles (rad) from accelerometer data
fbob 0:b1f2c9e88e32 31 void estimate_accel();
fbob 0:b1f2c9e88e32 32 // Estimate Euler angles (rad) and angular velocities (rad/s) from gyroscope data
fbob 0:b1f2c9e88e32 33 void estimate_gyro();
fbob 0:b1f2c9e88e32 34 // Euler angles (rad) from accelerometer data
fbob 0:b1f2c9e88e32 35 float phi_accel, theta_accel;
fbob 0:b1f2c9e88e32 36 // Euler angles (rad) from gyroscope data
fbob 0:b1f2c9e88e32 37 float phi_gyro, theta_gyro;
fbob 0:b1f2c9e88e32 38 // Angular velocities bias (rad/s)
fbob 0:b1f2c9e88e32 39 float p_bias, q_bias, r_bias;
fbob 0:b1f2c9e88e32 40
fbob 0:b1f2c9e88e32 41 };
fbob 0:b1f2c9e88e32 42
fbob 0:b1f2c9e88e32 43 #endif