added gy80 dcm
Dependencies: mbed DCM_AHRS_GY80 PID MMA8451Q
Fork of quadCommand by
quadCommand/quadCommand.h@6:21ae5e53bb5f, 2013-06-09 (annotated)
- Committer:
- dereklmc
- Date:
- Sun Jun 09 23:05:22 2013 +0000
- Revision:
- 6:21ae5e53bb5f
- Parent:
- 1:9b90e7de6e09
- Child:
- 8:72791d8c36b7
Added PID controller objects to quadcommand
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" |
gabdo | 0:8681037b9a18 | 12 | |
gabdo | 0:8681037b9a18 | 13 | const PinName MOTOR1 = PTD4; // Pin used for motor 1. |
gabdo | 0:8681037b9a18 | 14 | const PinName MOTOR2 = PTA12; // Pin used for motor 2. |
gabdo | 0:8681037b9a18 | 15 | const PinName MOTOR3 = PTA4; // Pin used for motor 3. |
gabdo | 0:8681037b9a18 | 16 | const PinName MOTOR4 = PTA5; // Pin used for motor 4. |
gabdo | 0:8681037b9a18 | 17 | |
gabdo | 0:8681037b9a18 | 18 | const PinName TXPIN = PTD3; // Pin used for xbee TX. |
gabdo | 0:8681037b9a18 | 19 | const PinName RXPIN = PTD2; // Pin used for xbee RX. |
gabdo | 0:8681037b9a18 | 20 | |
dereklmc | 6:21ae5e53bb5f | 21 | #define DEFAULT_WINDUP_GUARD 20.0f |
dereklmc | 6:21ae5e53bb5f | 22 | |
gabdo | 0:8681037b9a18 | 23 | class quadCommand |
gabdo | 0:8681037b9a18 | 24 | { |
gabdo | 0:8681037b9a18 | 25 | public: |
gabdo | 0:8681037b9a18 | 26 | quadCommand(); // Constructor. |
gabdo | 0:8681037b9a18 | 27 | void run(); // Loop. |
gabdo | 0:8681037b9a18 | 28 | void rxInput(); // Deal with new input from xbee. |
gabdo | 0:8681037b9a18 | 29 | void updatePosition(); |
gabdo | 0:8681037b9a18 | 30 | void txPosition(); |
gabdo | 0:8681037b9a18 | 31 | |
gabdo | 0:8681037b9a18 | 32 | private: |
gabdo | 0:8681037b9a18 | 33 | motor *myMotors[4]; // Array of motor objects. |
gabdo | 0:8681037b9a18 | 34 | com *myCom; // The com object. |
gabdo | 0:8681037b9a18 | 35 | sensors *world; // Sensors used to observe the world. |
gabdo | 0:8681037b9a18 | 36 | |
gabdo | 1:9b90e7de6e09 | 37 | float currentThrottle; |
gabdo | 1:9b90e7de6e09 | 38 | float currentPitch; |
gabdo | 1:9b90e7de6e09 | 39 | float currentRoll; |
gabdo | 1:9b90e7de6e09 | 40 | float currentYaw; |
gabdo | 0:8681037b9a18 | 41 | |
gabdo | 1:9b90e7de6e09 | 42 | float targetThrottle; |
gabdo | 1:9b90e7de6e09 | 43 | float targetPitch; |
gabdo | 1:9b90e7de6e09 | 44 | float targetRoll; |
gabdo | 1:9b90e7de6e09 | 45 | float targetYaw; |
dereklmc | 6:21ae5e53bb5f | 46 | |
dereklmc | 6:21ae5e53bb5f | 47 | PID pidPitch(1.5,0.1,1.20,DEFAULT_WINDUP_GUARD); |
dereklmc | 6:21ae5e53bb5f | 48 | PID pidRoll(1.5,0.1,1.20,DEFAULT_WINDUP_GUARD); |
dereklmc | 6:21ae5e53bb5f | 49 | PID pidYaw(1.5,0.1,1.20,DEFAULT_WINDUP_GUARD); |
gabdo | 0:8681037b9a18 | 50 | }; |
gabdo | 0:8681037b9a18 | 51 | |
gabdo | 0:8681037b9a18 | 52 | #endif |