ESE350 project, Spring 2016, University of Pennsylvania
Dependencies: Adafruit9-DOf Receiver mbed-rtos mbed
quadcopter.h@8:326e7009ce0c, 2016-04-02 (annotated)
- Committer:
- ivo_david_michelle
- Date:
- Sat Apr 02 13:47:58 2016 +0000
- Revision:
- 8:326e7009ce0c
- Parent:
- 7:f3f94eadc5b5
- Child:
- 9:f1bd96708a21
added publich members to quadcopter
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 | 6:6f3ffd97d808 | 6 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 7 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 8 | struct state { |
ivo_david_michelle | 8:326e7009ce0c | 9 | double phi; |
ivo_david_michelle | 8:326e7009ce0c | 10 | double theta; |
ivo_david_michelle | 8:326e7009ce0c | 11 | double psi; |
ivo_david_michelle | 6:6f3ffd97d808 | 12 | }; |
ivo_david_michelle | 7:f3f94eadc5b5 | 13 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 14 | struct force { |
ivo_david_michelle | 8:326e7009ce0c | 15 | double fx; |
ivo_david_michelle | 8:326e7009ce0c | 16 | double y; |
ivo_david_michelle | 8:326e7009ce0c | 17 | double fz; |
ivo_david_michelle | 7:f3f94eadc5b5 | 18 | }; |
ivo_david_michelle | 7:f3f94eadc5b5 | 19 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 20 | struct offset { |
ivo_david_michelle | 7:f3f94eadc5b5 | 21 | double x_offset; |
ivo_david_michelle | 7:f3f94eadc5b5 | 22 | double y_offset; |
ivo_david_michelle | 7:f3f94eadc5b5 | 23 | double z_offset; |
ivo_david_michelle | 7:f3f94eadc5b5 | 24 | }; |
ivo_david_michelle | 7:f3f94eadc5b5 | 25 | |
ivo_david_michelle | 6:6f3ffd97d808 | 26 | class Quadcopter |
ivo_david_michelle | 6:6f3ffd97d808 | 27 | { |
ivo_david_michelle | 6:6f3ffd97d808 | 28 | private: |
ivo_david_michelle | 8:326e7009ce0c | 29 | state state_; |
ivo_david_michelle | 8:326e7009ce0c | 30 | force force_; |
ivo_david_michelle | 7:f3f94eadc5b5 | 31 | //pwmOut * _pwmOut; // give address to constructor, than change this value |
ivo_david_michelle | 7:f3f94eadc5b5 | 32 | |
ivo_david_michelle | 8:326e7009ce0c | 33 | Adafruit_9DOF dof_; |
ivo_david_michelle | 8:326e7009ce0c | 34 | Adafruit_LSM303_Accel_Unified accel_; |
ivo_david_michelle | 8:326e7009ce0c | 35 | Adafruit_LSM303_Mag_Unified mag_; |
ivo_david_michelle | 8:326e7009ce0c | 36 | Adafruit_L3GD20_Unified gyro_; |
ivo_david_michelle | 7:f3f94eadc5b5 | 37 | |
ivo_david_michelle | 8:326e7009ce0c | 38 | offset offsetAngRate_; |
ivo_david_michelle | 8:326e7009ce0c | 39 | offset offsetAttitude_; |
ivo_david_michelle | 7:f3f94eadc5b5 | 40 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 41 | |
ivo_david_michelle | 6:6f3ffd97d808 | 42 | public: |
ivo_david_michelle | 6:6f3ffd97d808 | 43 | Quadcopter(); |
ivo_david_michelle | 7:f3f94eadc5b5 | 44 | |
ivo_david_michelle | 8:326e7009ce0c | 45 | void setState(double phi, double theta, double psi); |
ivo_david_michelle | 8:326e7009ce0c | 46 | |
ivo_david_michelle | 7:f3f94eadc5b5 | 47 | state getState() { |
ivo_david_michelle | 8:326e7009ce0c | 48 | return state_; |
ivo_david_michelle | 7:f3f94eadc5b5 | 49 | } |
ivo_david_michelle | 8:326e7009ce0c | 50 | void setPwm(); |
ivo_david_michelle | 8:326e7009ce0c | 51 | void initializePwm(); |
ivo_david_michelle | 8:326e7009ce0c | 52 | void controller(); |
ivo_david_michelle | 8:326e7009ce0c | 53 | void setState(); |
ivo_david_michelle | 8:326e7009ce0c | 54 | void readSensorValues(); |
ivo_david_michelle | 8:326e7009ce0c | 55 | void initSensors(); |
ivo_david_michelle | 6:6f3ffd97d808 | 56 | }; |
ivo_david_michelle | 7:f3f94eadc5b5 | 57 | |
ivo_david_michelle | 6:6f3ffd97d808 | 58 | #endif |