Library containing Crazyflie 2.0 controller classes: - Attitude estimator - Horizontal estimator - Vertical estimator - Attitude controller - Horizontal controller - Vertical controller - Mixer
HorizontaEstimator/HorizontalEstimator.cpp
- Committer:
- fbob
- Date:
- 2018-10-03
- Revision:
- 15:155ca63b7884
- Parent:
- 12:9fed6f656f88
- Child:
- 17:f682b4a5686d
File content as of revision 15:155ca63b7884:
#include "mbed.h" #include "HorizontalEstimator.h" // Class constructor HorizontalEstimator::HorizontalEstimator() : flow(PA_7,PA_6,PA_5,PB_4) { u = 0.0f; v = 0.0f; } // Initialize class void HorizontalEstimator::init() { // Initialize flow sensor object flow.init(); } // Predict vertical position and velocity void HorizontalEstimator::predict() { u = u; v = v; } // void HorizontalEstimator::update(float phi, float theta, float p, float q, float z) { // flow.read(); float div = (cos(phi)*cos(theta)); if (div>0.5f) { float d = z/div; float u_m = (flow.x+q)*d; float v_m = (flow.y-p)*d; u = (1-rho_hor)*u+rho_hor*u_m; v = (1-rho_hor)*v+rho_hor*v_m; } }