Deadalus
/home/usappz/DeadalusSim/source/quadrotor_dynamics/quadrotor_dynamics.hh
00001 /* -----------------------------------------------------------------------------
00002  *
00003  *
00004  *  ____                   _____     _
00005  * / ___|  __ _ _ __  _ __|__  /  __| | ___
00006  * \___ \ / _` | '_ \| '_ \ / /  / _` |/ _ \
00007  *  ___) | (_| | |_) | |_) / /_ | (_| |  __/
00008  * |____/ \__,_| .__/| .__/____(_)__,_|\___|
00009  *             |_|   |_|
00010  *
00011  *
00012  *
00013  * Author: Andreas Gschossmann
00014  * Email:  andreas.gschossmann@hs-regensburg.de
00015  *
00016  * quadrotor_dynamics.hh - Relationship between rotor-speed or alternatively
00017  * digital value for brushless drivers and resulting thrust of the motor.  *
00018  * -----------------------------------------------------------------------------*/
00019 #ifndef _GAZEBO_DYNAMICS_HH_ 
00020 #define _GAZEBO_DYNAMICS_HH_
00021 
00022 #include <string>
00023 
00024 #include <math.h>
00025 #include <gazebo/math/Vector3.hh>
00026 
00027 #include "../dependencies/resources.hh"
00028 #include "../dependencies/constants.hh"
00029 
00037 
00038 class QuadRotorDynamics 
00039 { 
00043     public: QuadRotorDynamics(
00044                  double k_t = 1.0,              
00045                  double k_m = 1.0,              
00046                  double moment_arm = 0.220,     
00047                  int error_type = NO_ERROR,     
00048                  double K = 1.0,                
00049                  double C = 0.0,                
00050                  double T = 0.0,                
00051                  double dead_time = 0.0         
00052                  ); 
00053 
00055     public: virtual ~QuadRotorDynamics();
00056 
00065     public: Mechanics update(ActuationVal actuation_value, double deltaT);
00066     //public: Mechanics update(AngularVel rotor_speed, double deltaT);
00067   
00075     private: void check_limits();
00076     
00079     private: void aerodynamics();
00080 
00086     private: void roll_pitch_torque();
00087 
00094     private: void disturbance();
00095 
00096     private:
00097       AngularVel        _rotor_speed;           
00098       AngularVel        _rotor_speed_prev;      
00099       AngularVel        _rotor_acceleration;    
00100       ActuationVal      _actuation_value;       
00101       Mechanics         _mechanics;             
00102       double    _dT;                            
00103 
00104     // aerodynamics constants
00105     private:
00106       double _k_t;              
00107       double _k_m;              
00108       
00109     private:
00110       double _moment_arm;       
00111 
00112     private:
00113       int _error_type;          
00114       double _sine_index;       
00115   
00116     // For PT1 K*u + C = T*(d/dt)omega + omega 
00117     private:
00118       double _K;                
00119       double _C;                
00120       double _T;                
00121       double _dead_time;        
00122     
00124     private: void pt1_element(); // K*u + C = T*(d/dt)omega + omega
00125    
00126     // values for limit check 
00127     private:
00128       double _rotor_speed_max;          
00129       double _rotor_acceleration_max;   
00130       bool   _limit_const_act;          
00131 
00132       bool   _limit_transient_act;      
00133 
00134 
00135     private:
00136       bool   _gyroscopic_torque_active; 
00137 
00138 
00139     // for check_limits()
00140     public: void activate_limit_constant( bool active );                
00141     public: void activate_limit_transient( bool active );               
00142     public: void set_limit_const(double rotor_speed_max);               
00143     public: void set_limit_transient(double rotor_acceleration_max);    
00144 
00145     public: void activate_gyroscopic_torque( bool active );             
00146    
00147     // set functions for pt1 element
00148     public: void set_k_pt1(double K);                   
00149     public: void set_t_pt1(double T);                   
00150     public: void set_c_pt1(double C);                   
00151     public: void set_dead_time_pt1(double dead_time);   
00152      
00153     public:
00154       Mechanics getMechanics(); 
00155       Thrust    getThrust();    
00156       Torque    getTorque();    
00157 
00158     public: void setErrorType(int error_type); 
00159 
00160 };
00161 #endif
 All Classes Functions Variables