added gy80 dcm

Dependencies:   mbed DCM_AHRS_GY80 PID MMA8451Q

Fork of quadCommand by Greg Abdo

Committer:
gabdo
Date:
Sun Jun 09 23:56:44 2013 +0000
Revision:
9:9e0d0ba5b6b1
Parent:
8:72791d8c36b7
Child:
10:af3be8c6aad7
Child:
16:84c7db5b4464
Minor mods

Who changed what in which revision?

UserRevisionLine numberNew 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 9:9e0d0ba5b6b1 13 // Motor constants.
gabdo 0:8681037b9a18 14 const PinName MOTOR1 = PTD4; // Pin used for motor 1.
gabdo 0:8681037b9a18 15 const PinName MOTOR2 = PTA12; // Pin used for motor 2.
gabdo 0:8681037b9a18 16 const PinName MOTOR3 = PTA4; // Pin used for motor 3.
gabdo 0:8681037b9a18 17 const PinName MOTOR4 = PTA5; // Pin used for motor 4.
gabdo 0:8681037b9a18 18
gabdo 9:9e0d0ba5b6b1 19 // Xbee constants.
gabdo 0:8681037b9a18 20 const PinName TXPIN = PTD3; // Pin used for xbee TX.
gabdo 0:8681037b9a18 21 const PinName RXPIN = PTD2; // Pin used for xbee RX.
gabdo 0:8681037b9a18 22
gabdo 9:9e0d0ba5b6b1 23 // Sensor constants.
gabdo 9:9e0d0ba5b6b1 24 #define MMA8451_I2C_ADDRESS (0x1d<<1) // Address of I2C accelerometer.
gabdo 9:9e0d0ba5b6b1 25 const PinName ACCSDA = PTE25; // Pin for accelerometer SDA line.
gabdo 9:9e0d0ba5b6b1 26 const PinName ACCSCL = PTE24; // Pin for accelerometer SCL line.
gabdo 9:9e0d0ba5b6b1 27
gabdo 9:9e0d0ba5b6b1 28 // PID constants.
gabdo 9:9e0d0ba5b6b1 29 #define DEFAULT_WINDUP_GUARD 20.0f
dereklmc 6:21ae5e53bb5f 30
gabdo 0:8681037b9a18 31 class quadCommand
gabdo 0:8681037b9a18 32 {
gabdo 0:8681037b9a18 33 public:
gabdo 0:8681037b9a18 34 quadCommand(); // Constructor.
gabdo 0:8681037b9a18 35 void run(); // Loop.
gabdo 0:8681037b9a18 36 void rxInput(); // Deal with new input from xbee.
dereklmc 8:72791d8c36b7 37 void updateMotors();
gabdo 0:8681037b9a18 38
gabdo 0:8681037b9a18 39 private:
gabdo 0:8681037b9a18 40 motor *myMotors[4]; // Array of motor objects.
gabdo 0:8681037b9a18 41 com *myCom; // The com object.
gabdo 0:8681037b9a18 42 sensors *world; // Sensors used to observe the world.
gabdo 0:8681037b9a18 43
gabdo 1:9b90e7de6e09 44 float currentThrottle;
gabdo 1:9b90e7de6e09 45 float currentPitch;
gabdo 1:9b90e7de6e09 46 float currentRoll;
gabdo 1:9b90e7de6e09 47 float currentYaw;
gabdo 0:8681037b9a18 48
gabdo 1:9b90e7de6e09 49 float targetThrottle;
gabdo 1:9b90e7de6e09 50 float targetPitch;
gabdo 1:9b90e7de6e09 51 float targetRoll;
gabdo 1:9b90e7de6e09 52 float targetYaw;
dereklmc 6:21ae5e53bb5f 53
dereklmc 6:21ae5e53bb5f 54 PID pidPitch(1.5,0.1,1.20,DEFAULT_WINDUP_GUARD);
dereklmc 6:21ae5e53bb5f 55 PID pidRoll(1.5,0.1,1.20,DEFAULT_WINDUP_GUARD);
dereklmc 6:21ae5e53bb5f 56 PID pidYaw(1.5,0.1,1.20,DEFAULT_WINDUP_GUARD);
dereklmc 8:72791d8c36b7 57
dereklmc 8:72791d8c36b7 58 static const float MOTOR_UPDATE;
gabdo 0:8681037b9a18 59 };
gabdo 0:8681037b9a18 60
gabdo 0:8681037b9a18 61 #endif