ESE350 project, Spring 2016, University of Pennsylvania

Dependencies:   Adafruit9-DOf Receiver mbed-rtos mbed

Revision:
10:e7d1801e966a
Parent:
9:f1bd96708a21
Child:
11:5c54826d23a7
--- a/quadcopter.h	Sat Apr 02 14:54:46 2016 +0000
+++ b/quadcopter.h	Sat Apr 02 17:41:37 2016 +0000
@@ -7,62 +7,86 @@
 
 
 struct state {
-    double phi;
-    double theta;
-    double psi;
+    double phi; // roll
+    double theta; // pitch
+    double psi; // yaw
+    double p; // omega x
+    double q; // omega y
+    double r; // omega z
+
 };
 
-struct force {
-    double fx;
-    double y;
-    double fz;
+struct controlInput {
+    double f;
+    double mx;
+    double my;
+    double mz;
 };
 
+// do one struct called "vector", or use standart template library
 struct offset {
-    double x_offset;
-    double y_offset;
-    double z_offset;
+    double x;
+    double y;
+    double z;
 };
 
+
+
 class Quadcopter
 {
 private:
     state state_;
-    force force_;
-//pwmOut * _pwmOut; // give address to constructor, than change this value
+    state desiredState_;
+    controlInput controlInput_;
+    //pwmOut * _pwmOut; // give address to constructor, than change this value
 
-Adafruit_9DOF dof_;
-Adafruit_LSM303_Accel_Unified accel_;
-Adafruit_LSM303_Mag_Unified mag_;
-Adafruit_L3GD20_Unified gyro_;
+    Adafruit_9DOF dof_;
+    Adafruit_LSM303_Accel_Unified accel_;
+    Adafruit_LSM303_Mag_Unified mag_;
+    Adafruit_L3GD20_Unified gyro_;
 
-   sensors_event_t accel_event_;
+    sensors_event_t accel_event_;
     sensors_event_t mag_event_;
     sensors_event_t gyro_event_;
     sensors_vec_t   orientation_;
 
-offset offsetAngRate_;
-offset offsetAttitude_;
-Serial *pcPntr_;
+    offset offsetAngRate_;
+    offset offsetAttitude_; // used later to compensate tilt of IMU
+    
+    Serial *pcPntr_; // used to access serial communication
+
+    double g_;  // gravity [m/s^2]
+    double m_; // mass [kg]
+    // proportional attitude control gains
+    double kp_phi_;
+    double kp_theta_;
+    double kp_psi_;
+
+    // derivative attitude control gains
+    double kd_phi_;
+    double kd_theta_;
+    double kd_psi_;
+
+    // desired force (will come from joystick)
+    double F_des_; // desired thrust force (excluding weight compensation)
 
 
 public:
-    Quadcopter();
-
-    void setState(double phi, double theta, double psi);
-    
-    /*state getState() {
-        return state_;
-    } */
-    
-    void setPwm();
-    void initializePwm();
+    Quadcopter(); // constructor
+    void setState(state *source, state *goal);
     void controller();
-    void setState();
     void readSensorValues();
     void initAllSensors();
-    void setSerial(Serial *pcPntr){pcPntr_=pcPntr;};
-    void print(char * myString);
+    void setSerial(Serial *pcPntr) {
+        pcPntr_=pcPntr;
+    };
+    void print(char * myString); // overload in order to print numbers
+
+
+    // not implemented yet
+    void setGains();
+    //void setPwm();
+    //void initializePwm();
 };
 
 #endif
\ No newline at end of file