![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ESE350 project, Spring 2016, University of Pennsylvania
Dependencies: Adafruit9-DOf Receiver mbed-rtos mbed
quadcopter.h@9:f1bd96708a21, 2016-04-02 (annotated)
- Committer:
- ivo_david_michelle
- Date:
- Sat Apr 02 14:54:46 2016 +0000
- Revision:
- 9:f1bd96708a21
- Parent:
- 8:326e7009ce0c
- Child:
- 10:e7d1801e966a
implemented printing and sensor reading
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ivo_david_michelle | 6:6f3ffd97d808 | 1 | #ifndef QUADCOPTER_H |
ivo_david_michelle | 6:6f3ffd97d808 | 2 | #define QUADCOPTER_H |
ivo_david_michelle | 6:6f3ffd97d808 | 3 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 4 | #include "mbed.h" |
ivo_david_michelle | 7:f3f94eadc5b5 | 5 | #include "Adafruit_9DOF.h" |
ivo_david_michelle | 9:f1bd96708a21 | 6 | #include "Serial_base.h" |
ivo_david_michelle | 6:6f3ffd97d808 | 7 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 8 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 9 | struct state { |
ivo_david_michelle | 8:326e7009ce0c | 10 | double phi; |
ivo_david_michelle | 8:326e7009ce0c | 11 | double theta; |
ivo_david_michelle | 8:326e7009ce0c | 12 | double psi; |
ivo_david_michelle | 6:6f3ffd97d808 | 13 | }; |
ivo_david_michelle | 7:f3f94eadc5b5 | 14 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 15 | struct force { |
ivo_david_michelle | 8:326e7009ce0c | 16 | double fx; |
ivo_david_michelle | 8:326e7009ce0c | 17 | double y; |
ivo_david_michelle | 8:326e7009ce0c | 18 | double fz; |
ivo_david_michelle | 7:f3f94eadc5b5 | 19 | }; |
ivo_david_michelle | 7:f3f94eadc5b5 | 20 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 21 | struct offset { |
ivo_david_michelle | 7:f3f94eadc5b5 | 22 | double x_offset; |
ivo_david_michelle | 7:f3f94eadc5b5 | 23 | double y_offset; |
ivo_david_michelle | 7:f3f94eadc5b5 | 24 | double z_offset; |
ivo_david_michelle | 7:f3f94eadc5b5 | 25 | }; |
ivo_david_michelle | 7:f3f94eadc5b5 | 26 | |
ivo_david_michelle | 6:6f3ffd97d808 | 27 | class Quadcopter |
ivo_david_michelle | 6:6f3ffd97d808 | 28 | { |
ivo_david_michelle | 6:6f3ffd97d808 | 29 | private: |
ivo_david_michelle | 8:326e7009ce0c | 30 | state state_; |
ivo_david_michelle | 8:326e7009ce0c | 31 | force force_; |
ivo_david_michelle | 7:f3f94eadc5b5 | 32 | //pwmOut * _pwmOut; // give address to constructor, than change this value |
ivo_david_michelle | 7:f3f94eadc5b5 | 33 | |
ivo_david_michelle | 8:326e7009ce0c | 34 | Adafruit_9DOF dof_; |
ivo_david_michelle | 8:326e7009ce0c | 35 | Adafruit_LSM303_Accel_Unified accel_; |
ivo_david_michelle | 8:326e7009ce0c | 36 | Adafruit_LSM303_Mag_Unified mag_; |
ivo_david_michelle | 8:326e7009ce0c | 37 | Adafruit_L3GD20_Unified gyro_; |
ivo_david_michelle | 7:f3f94eadc5b5 | 38 | |
ivo_david_michelle | 9:f1bd96708a21 | 39 | sensors_event_t accel_event_; |
ivo_david_michelle | 9:f1bd96708a21 | 40 | sensors_event_t mag_event_; |
ivo_david_michelle | 9:f1bd96708a21 | 41 | sensors_event_t gyro_event_; |
ivo_david_michelle | 9:f1bd96708a21 | 42 | sensors_vec_t orientation_; |
ivo_david_michelle | 9:f1bd96708a21 | 43 | |
ivo_david_michelle | 8:326e7009ce0c | 44 | offset offsetAngRate_; |
ivo_david_michelle | 8:326e7009ce0c | 45 | offset offsetAttitude_; |
ivo_david_michelle | 9:f1bd96708a21 | 46 | Serial *pcPntr_; |
ivo_david_michelle | 7:f3f94eadc5b5 | 47 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 48 | |
ivo_david_michelle | 6:6f3ffd97d808 | 49 | public: |
ivo_david_michelle | 6:6f3ffd97d808 | 50 | Quadcopter(); |
ivo_david_michelle | 7:f3f94eadc5b5 | 51 | |
ivo_david_michelle | 8:326e7009ce0c | 52 | void setState(double phi, double theta, double psi); |
ivo_david_michelle | 8:326e7009ce0c | 53 | |
ivo_david_michelle | 9:f1bd96708a21 | 54 | /*state getState() { |
ivo_david_michelle | 8:326e7009ce0c | 55 | return state_; |
ivo_david_michelle | 9:f1bd96708a21 | 56 | } */ |
ivo_david_michelle | 9:f1bd96708a21 | 57 | |
ivo_david_michelle | 8:326e7009ce0c | 58 | void setPwm(); |
ivo_david_michelle | 8:326e7009ce0c | 59 | void initializePwm(); |
ivo_david_michelle | 8:326e7009ce0c | 60 | void controller(); |
ivo_david_michelle | 8:326e7009ce0c | 61 | void setState(); |
ivo_david_michelle | 8:326e7009ce0c | 62 | void readSensorValues(); |
ivo_david_michelle | 9:f1bd96708a21 | 63 | void initAllSensors(); |
ivo_david_michelle | 9:f1bd96708a21 | 64 | void setSerial(Serial *pcPntr){pcPntr_=pcPntr;}; |
ivo_david_michelle | 9:f1bd96708a21 | 65 | void print(char * myString); |
ivo_david_michelle | 6:6f3ffd97d808 | 66 | }; |
ivo_david_michelle | 7:f3f94eadc5b5 | 67 | |
ivo_david_michelle | 6:6f3ffd97d808 | 68 | #endif |