Deadalus
/home/usappz/DeadalusSim/source/dependencies/resources.hh
00001 #ifndef _RESOURCES_HH_ 
00002 #define _RESOURCES_HH_
00003 
00004 #include <string>
00005 
00006 //#include <math.h>
00007 
00008 #include <gazebo/gazebo.hh>
00009 
00010 #include <gazebo/physics/physics.hh>
00011 #include <gazebo/msgs/msgs.hh>
00012 #include <gazebo/math/Vector3.hh>
00013 
00014 #include <stdio.h>
00015 #include "constants.hh" 
00016 
00017 using namespace gazebo;
00018 
00020 class AngularVel 
00021 {
00023   public: AngularVel() : 
00024     motor()
00025   {};
00026     
00027   public: 
00028     double motor[4];
00029   
00035   public: AngularVel get_acceleration( AngularVel angular_vel_current, AngularVel angular_vel_last, double dT )
00036   {
00037     AngularVel alpha;
00038     for (int i=0; i<4; i++)
00039     {
00040       // alpha = (Omega_current - Omega_last) / dt     
00041       alpha.motor[i] = ( angular_vel_current.motor[i] - angular_vel_last.motor[i] ) / dT;
00042     }
00043     return alpha;
00044   }
00045 };
00046 
00048 class ActuationVal 
00049 {
00051   public: ActuationVal() :
00052     motor()
00053   {};
00054   
00055   public:
00056     int motor[4]; // never negative
00057 };
00058 
00060 class Thrust
00061 {
00063   public: Thrust() :
00064     motor()
00065   {};
00066 
00067   public:
00068     double motor[4];
00069 
00070   private:   
00071     gazebo::math::Vector3 motor_vec3[4];        
00072 
00073  public: 
00077     gazebo::math::Vector3 vec3(int nmb_motor)
00078     {
00079       motor_vec3[nmb_motor].Set (0.0, 0.0, motor[nmb_motor]);
00080       return motor_vec3[nmb_motor];
00081     } 
00082 
00083  public:
00086     gazebo::math::Vector3 all_vec3()
00087     {
00088       gazebo::math::Vector3 myThrust (0.0, 0.0, motor[0] + motor[1] + motor[2] + motor[3]);
00089       return myThrust;
00090     }
00091        
00092 };
00093 
00095 class Torque //in Torque umbenennen
00096 {
00097   public:
00098     double roll;// = 0.0;
00099     double pitch;// = 0.0;
00100     double yaw;// = 0.0;  
00101 
00102   private:
00103     gazebo::math::Vector3 torque_vec3;
00104 
00105  public:
00107     gazebo::math::Vector3 vec3()
00108     {
00109       torque_vec3.Set (roll, pitch, yaw);
00110       return torque_vec3;
00111     };
00112 
00117   public: void set_torque(double r, double p, double y)
00118   {
00119     roll = r;
00120     pitch = p;
00121     yaw = y;
00122   };
00123 };
00124 
00126 class Mechanics
00127 { 
00128   public: 
00129     Thrust  thrust; 
00130     Torque  torque; 
00131 };
00132 
00134 class GPS
00135 {
00136   // GPS 
00137   public:
00138     double altitude;
00139     double latitude_deg;
00140     double longitude_deg;
00141 };
00142 
00144 class IMU 
00145 {
00146   public:
00147     double acc_x, acc_y, acc_z;
00148     double gyro_x, gyro_y, gyro_z;
00149     double roll_actual, pitch_actual, yaw_actual;
00150   
00151   private: 
00152     gazebo::msgs::Vector3d acc_vec3;
00153     gazebo::msgs::Vector3d gyro_vec3;
00154 
00155     /*public: gazebo::msgs::Vector3d get_acc_vec3()
00156     {
00157       acc_vec3.Set (acc_x, acc_y, acc_z);
00158       return acc_vec3;
00159     };
00160 
00161     public: gazebo::msgs::Vector3d get_gyro_vec3()
00162     {
00163       gyro_vec3.Set (gyro_x, gyro_y, gyro_z);
00164       return gyro_vec3;
00165     };*/
00166 
00168   public: void set_acc(double a_x, double a_y, double a_z)
00169   {
00170     acc_x = a_x;
00171     acc_y = a_y;
00172     acc_z = a_z;
00173   };
00174 
00176   public: void set_acc(gazebo::msgs::Vector3d acc)
00177   {
00178     acc_vec3 = acc;
00179     acc_x = acc_vec3.x();
00180     acc_y = acc_vec3.y();
00181     acc_z = acc_vec3.z();
00182   };
00183 
00185   public: void set_gyro(double g_x, double g_y, double g_z)
00186   {
00187     gyro_x = g_x;
00188     gyro_y = g_y;
00189     gyro_z = g_z;
00190   };
00191 
00193   public: void set_gyro(gazebo::msgs::Vector3d gyro)
00194   {
00195     gyro_vec3 = gyro;
00196     gyro_x = gyro_vec3.x();
00197     gyro_y = gyro_vec3.y();
00198     gyro_z = gyro_vec3.z();
00199   };
00200   
00202   public: void set(gazebo::msgs::Vector3d acc, gazebo::msgs::Vector3d gyro)
00203   {
00204     set_gyro(acc);
00205     set_acc(gyro);
00206   };
00207 
00208 };
00209  
00211 class MAG
00212 {
00213   public:
00214     double mag_x, mag_y, mag_z;
00215 
00216   private:
00217     gazebo::math::Vector3 mag_vec3;
00218     
00219     /*public: gazebo::math::Vector3 get_mag_vec3()
00220     {
00221       mag_vec3.Set (mag_x, mag_y, mag_z);
00222       return mag_vec3;
00223     };*/
00224 
00226   public: void set(double m_x, double m_y, double m_z)
00227   {
00228     mag_x = m_x;
00229     mag_y = m_y;
00230     mag_z = m_z;
00231   };
00232  
00234   public: void set(gazebo::math::Vector3 mag)
00235   {
00236     mag_vec3 = mag;
00237     mag_x = mag_vec3.x;
00238     mag_y = mag_vec3.y;
00239     mag_z = mag_vec3.z;
00240   };
00241 
00242   //public: gazebo::msgs::Vector3d
00243 
00244 };
00245 
00247 class Sensors
00248 {
00249   public:
00250     IMU         imu;
00251     MAG         mag;
00252     GPS         gps;
00253 };
00254 
00255 
00256 #endif
 All Classes Functions Variables