ECE4180 Final Project
Dependencies: LSM9DS1_Library Motor mbed-rtos mbed HC_SR04_Ultrasonic_Library
Fork of IMURoomba4_ThrowSumMo by
Revision 2:8887d13f967a, committed 2017-05-03
- Comitter:
- jplager3
- Date:
- Wed May 03 02:19:12 2017 +0000
- Parent:
- 1:6b8a201f4f90
- Child:
- 3:17113c72186e
- Commit message:
- debugging
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 03 01:53:52 2017 +0000
+++ b/main.cpp Wed May 03 02:19:12 2017 +0000
@@ -155,9 +155,9 @@
printAttitude(IMU.calcAccel(IMU.ax), IMU.calcAccel(IMU.ay), IMU.calcAccel(IMU.az), IMU.calcMag(IMU.mx),
IMU.calcMag(IMU.my), IMU.calcMag(IMU.mz));
BTmutex.unlock();
- myled = 1;
+ //myled = 1;
wait(0.5);
- myled = 0;
+ //myled = 0;
wait(0.5);
}
}
@@ -182,9 +182,9 @@
stop();
Thread::wait(1000);
// turn should be complete. Drive until obstacle passed on right, then turn right again
- BTmutex.lock();
+ //BTmutex.lock();
//dev.printf("Driving past obstacle.\n\r");
- BTmutex.unlock();
+ //BTmutex.unlock();
forward(throttle);
bool objOnRight = true;
while(objOnRight){
@@ -229,13 +229,13 @@
}
Thread::wait(400); // for debug. IR polling too quick and floods output terminal
}
-
}
void manualMode(){
bool on = true;
+ char temp;
while(on){
- char temp = dev.getc();
+ temp = dev.getc();
if(temp == 'A'){ // reset command
on = false;
}
@@ -270,6 +270,10 @@
else if(temp=='X'){ // halt/brake command
stop();
}
+ //myled=1;
+ //wait(0.5);
+ //myled=0;
+ //wait(0.5);
}
}
@@ -279,16 +283,16 @@
pc.baud(9600);
dev.baud(9600);
//wait to recv start command
- /*
+
for(int i=0; i<3;i++){ //temp delay for a few sec
myled=led2=led3=led4=1;
wait(0.5);
myled=led2=led3=led4=0;
wait(0.5);
- } */
+ }
thread1.start(IMU); // start the IMU thread
char temp;
-
+ /*
while(1){ //robot will receive a char from GUI signalling time to start
temp = dev.getc();
led3=1;
@@ -301,12 +305,14 @@
else {led2 = 0;}
wait(0.25);
}
+ */
led3=0;
thread2.start(defaultDrive);
while(1){
temp = dev.getc();
if(temp == 'M'){
led4=1;
+ stop();
thread2.terminate(); //stop default drive
manualMode(); //switch to manual control
//once manualMode is exited, return to default

