added gy80 dcm
Dependencies: mbed DCM_AHRS_GY80 PID MMA8451Q
Fork of quadCommand by
quadCommand/quadCommand.h@46:f1eb22f41ebc, 2013-06-10 (annotated)
- Committer:
- dereklmc
- Date:
- Mon Jun 10 02:10:19 2013 +0000
- Revision:
- 46:f1eb22f41ebc
- Parent:
- 43:e2fc699e8e8c
- Child:
- 47:adc1a438aa33
Added more debug state.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gabdo | 0:8681037b9a18 | 1 | /************************* quadCommand.h *********************************/ |
gabdo | 0:8681037b9a18 | 2 | /* */ |
gabdo | 0:8681037b9a18 | 3 | /*************************************************************************/ |
gabdo | 0:8681037b9a18 | 4 | |
gabdo | 0:8681037b9a18 | 5 | #ifndef QUAD_COMMAND_H |
gabdo | 0:8681037b9a18 | 6 | #define QUAD_COMMAND_H |
gabdo | 0:8681037b9a18 | 7 | |
gabdo | 0:8681037b9a18 | 8 | #include "mbed.h" |
gabdo | 0:8681037b9a18 | 9 | #include "motor.h" |
gabdo | 0:8681037b9a18 | 10 | #include "com.h" |
gabdo | 0:8681037b9a18 | 11 | #include "sensors.h" |
oprospero | 10:af3be8c6aad7 | 12 | #include "PID.h" |
gabdo | 0:8681037b9a18 | 13 | |
gabdo | 9:9e0d0ba5b6b1 | 14 | // Motor constants. |
gabdo | 0:8681037b9a18 | 15 | const PinName MOTOR1 = PTD4; // Pin used for motor 1. |
gabdo | 0:8681037b9a18 | 16 | const PinName MOTOR2 = PTA12; // Pin used for motor 2. |
gabdo | 0:8681037b9a18 | 17 | const PinName MOTOR3 = PTA4; // Pin used for motor 3. |
gabdo | 0:8681037b9a18 | 18 | const PinName MOTOR4 = PTA5; // Pin used for motor 4. |
gabdo | 0:8681037b9a18 | 19 | |
gabdo | 9:9e0d0ba5b6b1 | 20 | // Xbee constants. |
oprospero | 10:af3be8c6aad7 | 21 | // Alternative Pins |
oprospero | 10:af3be8c6aad7 | 22 | // RX = PTA1, TX PTA2 |
gabdo | 0:8681037b9a18 | 23 | const PinName TXPIN = PTD3; // Pin used for xbee TX. |
gabdo | 0:8681037b9a18 | 24 | const PinName RXPIN = PTD2; // Pin used for xbee RX. |
gabdo | 0:8681037b9a18 | 25 | |
oprospero | 10:af3be8c6aad7 | 26 | |
gabdo | 9:9e0d0ba5b6b1 | 27 | // Sensor constants. |
gabdo | 9:9e0d0ba5b6b1 | 28 | #define MMA8451_I2C_ADDRESS (0x1d<<1) // Address of I2C accelerometer. |
gabdo | 9:9e0d0ba5b6b1 | 29 | const PinName ACCSDA = PTE25; // Pin for accelerometer SDA line. |
gabdo | 9:9e0d0ba5b6b1 | 30 | const PinName ACCSCL = PTE24; // Pin for accelerometer SCL line. |
gabdo | 9:9e0d0ba5b6b1 | 31 | |
gabdo | 9:9e0d0ba5b6b1 | 32 | // PID constants. |
gabdo | 9:9e0d0ba5b6b1 | 33 | #define DEFAULT_WINDUP_GUARD 20.0f |
dereklmc | 6:21ae5e53bb5f | 34 | |
gabdo | 0:8681037b9a18 | 35 | class quadCommand |
gabdo | 0:8681037b9a18 | 36 | { |
gabdo | 0:8681037b9a18 | 37 | public: |
gabdo | 0:8681037b9a18 | 38 | quadCommand(); // Constructor. |
gabdo | 0:8681037b9a18 | 39 | void run(); // Loop. |
gabdo | 0:8681037b9a18 | 40 | void rxInput(); // Deal with new input from xbee. |
dereklmc | 8:72791d8c36b7 | 41 | void updateMotors(); |
gabdo | 43:e2fc699e8e8c | 42 | void updateCurrent(); |
gabdo | 40:8c01bf294768 | 43 | void sendTelemetry(); |
dereklmc | 20:4cdabb792d16 | 44 | |
dereklmc | 20:4cdabb792d16 | 45 | static const float MOTOR_UPDATE; |
dereklmc | 20:4cdabb792d16 | 46 | |
gabdo | 0:8681037b9a18 | 47 | private: |
gabdo | 0:8681037b9a18 | 48 | motor *myMotors[4]; // Array of motor objects. |
gabdo | 0:8681037b9a18 | 49 | com *myCom; // The com object. |
gabdo | 0:8681037b9a18 | 50 | sensors *world; // Sensors used to observe the world. |
gabdo | 0:8681037b9a18 | 51 | |
gabdo | 1:9b90e7de6e09 | 52 | float currentThrottle; |
gabdo | 1:9b90e7de6e09 | 53 | float currentPitch; |
gabdo | 1:9b90e7de6e09 | 54 | float currentRoll; |
gabdo | 1:9b90e7de6e09 | 55 | float currentYaw; |
gabdo | 0:8681037b9a18 | 56 | |
gabdo | 1:9b90e7de6e09 | 57 | float targetThrottle; |
gabdo | 1:9b90e7de6e09 | 58 | float targetPitch; |
gabdo | 1:9b90e7de6e09 | 59 | float targetRoll; |
gabdo | 1:9b90e7de6e09 | 60 | float targetYaw; |
dereklmc | 6:21ae5e53bb5f | 61 | |
dereklmc | 17:d73944c3c945 | 62 | PID pidThrottle; |
dereklmc | 17:d73944c3c945 | 63 | PID pidPitch; |
dereklmc | 17:d73944c3c945 | 64 | PID pidRoll; |
dereklmc | 17:d73944c3c945 | 65 | PID pidYaw; |
dereklmc | 46:f1eb22f41ebc | 66 | |
dereklmc | 46:f1eb22f41ebc | 67 | Ticker sensorProcess; |
gabdo | 0:8681037b9a18 | 68 | }; |
gabdo | 0:8681037b9a18 | 69 | |
gabdo | 0:8681037b9a18 | 70 | #endif |