Helvijs Kiselis
/
Micromouse
Algorithmus
Diff: main.cpp
- Revision:
- 19:6cd6cc5c8b4c
- Parent:
- 18:3309329d5f42
- Child:
- 20:20573f55a5fd
--- a/main.cpp Mon May 07 19:52:54 2018 +0000 +++ b/main.cpp Thu May 10 18:10:15 2018 +0000 @@ -7,13 +7,6 @@ /* todo: - - Beschleunigung: Wann & Wo? - - Zentrieren - - Optimieren: - - Beschleunigung - - Zentrieren - - über längere Strecke schneller fahren - Abbiegen */ @@ -28,16 +21,14 @@ //Sensors: - AnalogIn lineSensor(PA_4); + AnalogIn lineSensor(PC_5); AnalogIn distance2(PC_3); AnalogIn distance4(PB_1); AnalogIn distance1(PC_2); - AnalogIn distance3(PC_5); IRSensor irSensorL (distance2); IRSensor irSensorC (distance4); IRSensor irSensorR (distance1); - IRSensor irSensorB (distance3); Timer t1; @@ -98,7 +89,7 @@ } //motion.runTask(route,r,true); - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); route[r] = 0; r--; } while (junc < r ); @@ -163,7 +154,7 @@ } } - printf("Kreuzung: %d Schritt: %d\n", j, r); + //printf("Kreuzung: %d Schritt: %d\n", j, r); } //No wall left if (lWall == 0) { @@ -171,7 +162,7 @@ if (route[r] == LEFT) { route[r] = MOVE; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; motion.rotateL(); @@ -181,10 +172,10 @@ }else if (route[r] == MOVE) { route[r] = RIGHT; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; route[r] = MOVE; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; motion.rotateL(); @@ -195,7 +186,7 @@ // Kreuzung führt zu Sackgassen -> löschen junction[j] = 0; /*Änderung alex*/ //if (j > 0) {j--;} - printf("Kreuzung %d Schritt %d geloscht\n", j, r); + //printf("Kreuzung %d Schritt %d geloscht\n", j, r); j -= 1; //reverseToJunction(junction[j], r, route); @@ -212,7 +203,7 @@ } motion.runTask(route[r]); - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); route[r] = 0; if ( r == junction[j] + 1) { @@ -224,9 +215,9 @@ } motion.stop(); - printf("Loop fertig\n"); + //printf("Loop fertig\n"); r--; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); */ do { @@ -242,21 +233,21 @@ } motion.runTask(route,r,true,junction[j]); - printf("Schritt: %d, Befehl: %d\n", r, route[r]); //At work!!!!! + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); //At work!!!!! route[r] = 0; r--; } while (junction[j] < r ) ; motion.stop(); - printf("Loop stop\n"); + //printf("Loop stop\n"); }else{ route[r] = LEFT; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; route[r] = MOVE; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; @@ -270,10 +261,10 @@ if (route[r] == LEFT) { route[r] = RIGHT; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; route[r] = MOVE; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; motion.scanMove(); @@ -283,7 +274,7 @@ junction[j] = 0; /*Änderung alex*/ //if (j > 0) {j--;} - printf("Kreuzung %d Schritt %d geloscht\n", j, r); + //printf("Kreuzung %d Schritt %d geloscht\n", j, r); j -= 1; //reverseToJunction(junction[j], r, route); @@ -300,7 +291,7 @@ } motion.runTask(route[r]); - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); route[r] = 0; if ( r == junction[j] + 1) { @@ -311,9 +302,9 @@ } motion.stop(); - printf("Loop fertig\n"); + //printf("Loop fertig\n"); r--; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); */ do { @@ -329,18 +320,18 @@ } motion.runTask(route,r,true,junction[j]); - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); route[r] = 0; r--; } while (junction[j] < r ); motion.stop(); - printf("Loop stop\n"); + //printf("Loop stop\n"); }else{ route[r] = MOVE; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; motion.scanMove(); @@ -349,10 +340,10 @@ }else if (rWall == 0) { route[r] = RIGHT; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; route[r] = MOVE; - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; motion.rotateR(); @@ -363,7 +354,7 @@ }else if ((lWall + cWall + rWall) == 3) { motion.rotate180(); - printf("Sackgasse Schritt: %d\n", r); + //printf("Sackgasse Schritt: %d\n", r); r--; t1.reset(); t1.start(); @@ -378,7 +369,7 @@ switch (route[r]) { case MOVE: motion.runTask(route,r,true, junction[j]); - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); r--; break; case LEFT: @@ -391,7 +382,7 @@ motion.stop(); t1.reset(); t1.start(); - while (t1 < 1.0f) {} + while (t1 < 0.5f) {} t1.stop(); }else{ @@ -406,7 +397,7 @@ } //Run tasks in declining order motion.runTask(route,r,true, junction[j]); - printf("Schritt: %d, Befehl: %d\n", r, route[r]); + //printf("Schritt: %d, Befehl: %d\n", r, route[r]); route[r] = 0; r--; }