Spring 2014, ECE 4180 project, Georgia Institute of Technolgoy. This is the human driver (RF controller) program for the Robotics Cat and Mouse program.
Dependencies: ADXL345_I2C_NEST HMC6352 IMUfilter ITG3200_NEST USBHost mbed-rtos mbed
Fork of Project by
main.cpp@3:6a7620e9abd9, 2014-04-25 (annotated)
- Committer:
- ganeshsubram1
- Date:
- Fri Apr 25 23:06:47 2014 +0000
- Revision:
- 3:6a7620e9abd9
- Parent:
- 2:56eb726bdb0d
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Strikewolf | 0:b6fd1c37944a | 1 | #include "mbed.h" |
Strikewolf | 0:b6fd1c37944a | 2 | #include "RobotControl.h" |
Strikewolf | 2:56eb726bdb0d | 3 | #include "rtos.h" |
ganeshsubram1 | 3:6a7620e9abd9 | 4 | |
Strikewolf | 2:56eb726bdb0d | 5 | #define ENTERCALIB 0x43 |
Strikewolf | 2:56eb726bdb0d | 6 | #define EXITCALIB 0x45 |
Strikewolf | 2:56eb726bdb0d | 7 | |
ganeshsubram1 | 3:6a7620e9abd9 | 8 | DigitalOut led3(LED3); |
ganeshsubram1 | 3:6a7620e9abd9 | 9 | DigitalOut led4(LED4); |
ganeshsubram1 | 3:6a7620e9abd9 | 10 | DigitalOut rst1(p12); |
ganeshsubram1 | 3:6a7620e9abd9 | 11 | |
ganeshsubram1 | 3:6a7620e9abd9 | 12 | Serial xbee1(p13, p14); |
ganeshsubram1 | 3:6a7620e9abd9 | 13 | |
Strikewolf | 2:56eb726bdb0d | 14 | InterruptIn sw(p30); |
ganeshsubram1 | 3:6a7620e9abd9 | 15 | |
Strikewolf | 2:56eb726bdb0d | 16 | void StopISR() |
Strikewolf | 2:56eb726bdb0d | 17 | { |
Strikewolf | 2:56eb726bdb0d | 18 | rightMotorPWM = 0; |
Strikewolf | 2:56eb726bdb0d | 19 | leftMotorPWM = 0; |
Strikewolf | 2:56eb726bdb0d | 20 | exit(1); |
Strikewolf | 2:56eb726bdb0d | 21 | } |
ganeshsubram1 | 3:6a7620e9abd9 | 22 | |
ganeshsubram1 | 3:6a7620e9abd9 | 23 | int main() { |
Strikewolf | 2:56eb726bdb0d | 24 | |
Strikewolf | 2:56eb726bdb0d | 25 | //Emergency stop mechanism |
Strikewolf | 2:56eb726bdb0d | 26 | sw.rise(&StopISR); |
Strikewolf | 2:56eb726bdb0d | 27 | |
ganeshsubram1 | 3:6a7620e9abd9 | 28 | // start positioning system |
ganeshsubram1 | 3:6a7620e9abd9 | 29 | Thread position(PositionSystemMain, NULL, osPriorityNormal, 256 * 4); |
ganeshsubram1 | 3:6a7620e9abd9 | 30 | wait(3); // wait for the mouse sensor to boot up |
ganeshsubram1 | 3:6a7620e9abd9 | 31 | |
ganeshsubram1 | 3:6a7620e9abd9 | 32 | // calibrate 90 degree turns |
ganeshsubram1 | 3:6a7620e9abd9 | 33 | turnCalibrate(); |
Strikewolf | 0:b6fd1c37944a | 34 | |
ganeshsubram1 | 3:6a7620e9abd9 | 35 | // PTURN_RIGHT is the measured x value for a 90 degree turn |
ganeshsubram1 | 3:6a7620e9abd9 | 36 | pc.printf("PTURN_RIGHT: %f\n\r", PTURN_RIGHT); |
ganeshsubram1 | 3:6a7620e9abd9 | 37 | wait(1); |
ganeshsubram1 | 3:6a7620e9abd9 | 38 | |
ganeshsubram1 | 3:6a7620e9abd9 | 39 | // try a 90 degree turn with the measured PTURN_RIGHT value |
ganeshsubram1 | 3:6a7620e9abd9 | 40 | turnRight(90); |
ganeshsubram1 | 3:6a7620e9abd9 | 41 | } |