Fertige Version mit geschwindigkeit 100
Dependencies: mbed
Fork of Micromouse_alpha_copy_copy by
Diff: Turn.cpp
- Revision:
- 7:5ff551b098f8
- Parent:
- 6:a09d2ee3b82e
diff -r a09d2ee3b82e -r 5ff551b098f8 Turn.cpp --- a/Turn.cpp Wed Apr 25 12:49:48 2018 +0000 +++ b/Turn.cpp Wed May 02 11:53:42 2018 +0000 @@ -4,7 +4,7 @@ using namespace std; const float Turn::TURNINGSPEED = 50.0f;//Drehgeschwindgkeit Drehzahl in [rpm] -const int Turn::TURNINGCOUNTS = 868; //Entspricht Drehung um 90Grad //DONT TOUCH +const int Turn::TURNINGCOUNTS = 910; //Entspricht Drehung um 90Grad //DONT TOUCH Turn::Turn(EncoderCounter& counterLeft, EncoderCounter& counterRight, Controller& controller, int& wallRight, int& wallFront, int& wallLeft): counterLeft(counterLeft), @@ -25,6 +25,13 @@ int countsLeft = counterLeft.read(); int countsLeft0 = countsLeft; + //vor dem abbiegen halten + controller.setDesiredSpeedRight(0.5f); + controller.setDesiredSpeedLeft(-0.5f); + //wait(0.1f); + + + //Entscheiden welche Richtung, Drehen und Stoppen wenn die gewuenschte Anzahl Counts erreicht sind if (wallLeft == 0){ //Nach Links Drehen @@ -40,7 +47,7 @@ //printf("%d\n\r", countsLeft); } controller.setDesiredSpeedRight(0.5f); - controller.setDesiredSpeedLeft(0.5f); + controller.setDesiredSpeedLeft(-0.5f); }else if (wallFront == 0){ //Nicht Drehen-> weiter Geradeaus @@ -59,14 +66,14 @@ //printf("%d\n", countsLeft); } controller.setDesiredSpeedRight(0.5f); - controller.setDesiredSpeedLeft(0.5f); + controller.setDesiredSpeedLeft(-0.5f); }else{ //Alle Wege versperrt-> Wenden //printf("Alles versperrt...zurueck\n"); - while((countsRight <= countsRight0 + 2*TURNINGCOUNTS) && (countsLeft <= countsLeft0 + 2*TURNINGCOUNTS)){ + while((countsRight <= countsRight0 + 2*TURNINGCOUNTS + 70) && (countsLeft <= countsLeft0 + 2*TURNINGCOUNTS + 70)){ controller.setDesiredSpeedRight(TURNINGSPEED); controller.setDesiredSpeedLeft(TURNINGSPEED); countsRight = counterRight.read(); @@ -75,6 +82,6 @@ //printf("%d\n", countsLeft); } controller.setDesiredSpeedRight(0.5f); //0.0f - controller.setDesiredSpeedLeft(0.5f); //0.0f + controller.setDesiredSpeedLeft(-0.5f); //0.0f } }