Helvijs Kiselis
/
Micromouse
Algorithmus
Diff: main.cpp
- Revision:
- 6:4868f789c223
- Parent:
- 5:e2c0a4388d85
- Child:
- 7:22392ed60534
--- a/main.cpp Mon Apr 23 17:59:13 2018 +0000 +++ b/main.cpp Tue Apr 24 15:35:24 2018 +0000 @@ -108,10 +108,10 @@ int main() { //Init - int route[50] = {0}; + int route[200] = {0}; int r = 0; - int junction[10] = {0}; + int junction[20] = {0}; int j = 0; short lWall; @@ -213,12 +213,12 @@ route[r] = RIGHT; printf("Schritt: %d, Befehl: %d\n", r, route[r]); r++; - route[r] = MOVE; + /*route[r] = MOVE; printf("Schritt: %d, Befehl: %d\n", r, route[r]); - r++; + r++;*/ motion.scanMove(); - stop(); + motion.stop(); }else if (route[r] == MOVE) { @@ -260,9 +260,19 @@ while (junction[j] <= r ) { if (junction[j] == r && (route[r] == LEFT || route[r] == RIGHT)) { - - //route[r] = 0; - r--; + + switch (route[r]) { + case MOVE: + motion.runTask(route[r]); + printf("Schritt: %d, Befehl: %d\n", r, route[r]); + r--; + case LEFT: + r--; + break; + case RIGHT: + r--; + break; + } }else{ //invert rotation @@ -273,12 +283,12 @@ }else if (route[r] == RIGHT) { route[r] = LEFT; - } - //Run tasks in declining order - motion.runTask(route[r]); - printf("Schritt: %d, Befehl: %d\n", r, route[r]); - route[r] = 0; - r--; + } + //Run tasks in declining order + motion.runTask(route[r]); + printf("Schritt: %d, Befehl: %d\n", r, route[r]); + route[r] = 0; + r--; } } r++;