Code for our FYDP -only one IMU works right now -RTOS is working

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers robot.h Source File

robot.h

00001 #ifndef ROBOT_H
00002 #define ROBOT_H
00003 
00004 #include "mbed.h"
00005 #include "rtos.h"
00006 #include "stdint.h"
00007 
00008 #include "HC05.h"
00009 #include "nRF24L01P.h "
00010 
00011 #include "MPU6050_6Axis_MotionApps20.h"
00012 #include "MPU6051_6Axis_MotionApps20.h"
00013 #include "DMP.h"
00014 #include "IMUDATA.h"
00015 #include "ADNS5090.h"
00016 #include "ACS712.h"
00017 
00018 #include "reckon.h"
00019 #include "motors.h"
00020 
00021 #define BT_BAUD_RATE        115200        //Baud rate of 9600
00022 #define TX_BT               PTA2        //Bluetooth connection pins
00023 #define RX_BT               PTA1        //Bluetooth connection pins
00024 #define EN_BT               PTE30        //Bluetooth connection pins
00025 
00026 #define MOSI_MOUSE          PTB16        //Bluetooth connection pins
00027 #define MISO_MOUSE          PTB17        //Bluetooth connection pins
00028 #define SCLK_MOUSE          PTB11        //Bluetooth connection pins
00029 #define NCS_MOUSE_L         PTB9        //Bluetooth connection pins
00030 #define NCS_MOUSE_R         PTB8        //Bluetooth connection pins
00031 
00032 //#define IMU_SDA_PIN         PTE0
00033 //#define IMU_SCL_PIN         PTE1
00034 #define IMU_POWER_PIN       PTD6
00035 #define IMU2_POWER_PIN      PTD4 //PTD4
00036 //#define IMU_NOTUSED_PIN     PTE23
00037 
00038 #define LED_PIN     PTE3        //status LED pin
00039 #define LED_OFF  led = 1;        //status LED pin
00040 #define LED_ON   led = 0;        //status LED pin
00041 
00042 //#define CURRENTSENSOR_PIN PTC2
00043 #define VOLTAGESENSOR_PIN PTB0
00044 //#define HIGH_CURRENT_SWITCH PTB18   //turn this to high to get high current flow
00045 
00046 
00047 //#define CURRENT_R1 180 //160.0     //values of the current sensor opamp resistors
00048 //#define CURRENT_R2 10
00049 //#define CURRENT_R3 80
00050 //#define CURRENT_R4 84.7
00051 //#define VREF3_3 3.3        //digital logic voltage
00052 //#define VREF5 5.0       //5v voltage        //NOTE: 5v voltage is consistent when using new batts, but not using old blue batts
00053 
00054 #define IR_L PTB1
00055 #define IR_C PTB2
00056 #define IR_R PTB3
00057 #define IR_B PTC6     //turn GPIO to high to multiplex L,C,R ADC to rear sensors
00058 
00059 
00060 #define MOT_AIN1_PIN   PTA14
00061 #define MOT_AIN2_PIN   PTA13
00062 #define MOT_PWMA_PIN   PTA4    //Motor control pins  
00063 
00064 #define MOT_BIN1_PIN   PTA16
00065 #define MOT_BIN2_PIN   PTA17
00066 #define MOT_PWMB_PIN   PTA5
00067 
00068 #define MOT_STBY_PIN   PTA15
00069 
00070 //used for RF device
00071 #define TRANSFER_SIZE   4
00072 #define ROBOT1_ADDRESS      ((unsigned long long) 0x17E7E7E7E7 )
00073 #define ROBOT2_ADDRESS      ((unsigned long long) 0xC2C2C2C2C2 )
00074 #define ROBOT3_ADDRESS      ((unsigned long long) 0x37E7E7E7E7 )
00075 #define ALLROBOT_ADDRESS    ((unsigned long long) 0xE7E7E7E7E7 )
00076 #define ADDRESS_WIDTH       5
00077 const float M_PI = 3.14159265;
00078 
00079 extern DigitalOut led;
00080 
00081 extern HC05 bt;
00082 
00083 extern bool send_flag;
00084 extern bool obstacle_flag;   //this alerts the robot if there is an obstacle somewhere. 
00085 extern bool fwd_flag;   //indicates that the robot is trying to move forward
00086 extern bool calibrate_flag;
00087 extern bool calibrate_optFlow_flag;
00088 
00089 extern AnalogIn irL;
00090 extern AnalogIn irC;
00091 extern AnalogIn irR;
00092 extern DigitalOut irBack;
00093 extern AnalogIn voltage_sensor;
00094 
00095 extern ACS712 current_sensor;
00096 extern ADNS5090 opt_flow_L;
00097 extern ADNS5090 opt_flow_R;
00098 
00099 extern MPU6050 mpu;
00100 extern MPU6051 mpu2;
00101 
00102 extern DigitalOut imuSwitch;
00103 extern DigitalOut imu2Switch;
00104 extern IMU_DATA imu_data;
00105 extern IMU_DATA imu2_data;
00106 
00107 extern Reckon  reckon;
00108 
00109 extern Motors motors;
00110 extern RtosTimer *MotorStopTimer;
00111 
00112 extern nRF24L01P rf;    // RF communication device
00113 
00114 extern unsigned long long long_time;
00115 extern Timer t;
00116 float getTime();
00117 
00118 void initRobot();
00119 void moveMotors(int Lspeed, int Rspeed, int ms);
00120 
00121 #endif