Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of FYDP_Final2 by
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 #include "Servo.h" 00018 00019 #include "reckon.h" 00020 #include "motors.h" 00021 00022 #define write_rate 100 //Maximum write rate (ms) of the motor 00023 00024 #define BT_BAUD_RATE 115200 //Baud rate of 9600 00025 #define TX_BT PTA2 //Bluetooth connection pins 00026 #define RX_BT PTA1 //Bluetooth connection pins 00027 #define EN_BT PTE30 //Bluetooth connection pins 00028 00029 #define MOSI_MOUSE PTB16 //Bluetooth connection pins 00030 #define MISO_MOUSE PTB17 //Bluetooth connection pins 00031 #define SCLK_MOUSE PTB11 //Bluetooth connection pins 00032 #define NCS_MOUSE_L PTB9 //Bluetooth connection pins 00033 #define NCS_MOUSE_R PTB8 //Bluetooth connection pins 00034 00035 //#define IMU_SDA_PIN PTE0 00036 //#define IMU_SCL_PIN PTE1 00037 #define IMU_POWER_PIN PTD6 00038 #define IMU2_POWER_PIN PTD4 //PTD4 00039 //#define IMU_NOTUSED_PIN PTE23 00040 00041 #define LED_PIN PTE3 //status LED pin 00042 #define LED_OFF led = 1; //status LED pin 00043 #define LED_ON led = 0; //status LED pin 00044 00045 //#define CURRENTSENSOR_PIN PTC2 00046 #define VOLTAGESENSOR_PIN PTB0 00047 //#define HIGH_CURRENT_SWITCH PTB18 //turn this to high to get high current flow 00048 00049 00050 //#define CURRENT_R1 180 //160.0 //values of the current sensor opamp resistors 00051 //#define CURRENT_R2 10 00052 //#define CURRENT_R3 80 00053 //#define CURRENT_R4 84.7 00054 //#define VREF3_3 3.3 //digital logic voltage 00055 //#define VREF5 5.0 //5v voltage //NOTE: 5v voltage is consistent when using new batts, but not using old blue batts 00056 00057 #define IR_L PTB1 00058 #define IR_C PTB2 00059 #define IR_R PTB3 00060 #define IR_B PTC6 //turn GPIO to high to multiplex L,C,R ADC to rear sensors 00061 00062 00063 #define MOT_AIN1_PIN PTA14 00064 #define MOT_AIN2_PIN PTA13 00065 #define MOT_PWMA_PIN PTA4 //Motor control pins 00066 00067 #define MOT_BIN1_PIN PTA16 00068 #define MOT_BIN2_PIN PTA17 00069 #define MOT_PWMB_PIN PTA5 00070 00071 #define MOT_STBY_PIN PTA15 00072 00073 //used for RF device 00074 #define TRANSFER_SIZE 4 00075 #define ROBOT1_ADDRESS ((unsigned long long) 0x17E7E7E7E7 ) 00076 #define ROBOT2_ADDRESS ((unsigned long long) 0xC2C2C2C2C2 ) 00077 #define ROBOT3_ADDRESS ((unsigned long long) 0x37E7E7E7E7 ) 00078 #define ALLROBOT_ADDRESS ((unsigned long long) 0xE7E7E7E7E7 ) 00079 #define ADDRESS_WIDTH 5 00080 const float M_PI = 3.14159265; 00081 00082 extern DigitalOut led; 00083 extern Servo myservo; 00084 00085 extern HC05 bt; 00086 00087 extern bool send_flag; 00088 extern bool obstacle_flag; //this alerts the robot if there is an obstacle somewhere. 00089 extern bool fwd_flag; //indicates that the robot is trying to move forward 00090 extern bool calibrate_flag; 00091 extern bool calibrate_optFlow_flag; 00092 00093 extern AnalogIn irL; 00094 extern AnalogIn irC; 00095 extern AnalogIn irR; 00096 extern DigitalOut irBack; 00097 extern AnalogIn voltage_sensor; 00098 00099 extern ACS712 current_sensor; 00100 extern ADNS5090 opt_flow_L; 00101 extern ADNS5090 opt_flow_R; 00102 00103 extern MPU6050 mpu; 00104 extern MPU6051 mpu2; 00105 00106 extern DigitalOut imuSwitch; 00107 extern DigitalOut imu2Switch; 00108 extern IMU_DATA imu_data; 00109 extern IMU_DATA imu2_data; 00110 00111 extern Reckon reckon; 00112 00113 extern Motors motors; 00114 extern RtosTimer *MotorStopTimer; 00115 00116 extern nRF24L01P rf; // RF communication device 00117 00118 extern unsigned long long long_time; 00119 extern Timer t; 00120 //extern Timer t_m; //Timer used for the motor thread 00121 extern time_t prev; //previous time for motor 00122 float getTime(); 00123 00124 void initRobot(); 00125 00126 #endif
Generated on Tue Jul 12 2022 16:56:36 by
1.7.2
