Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Roboshark_V6 by
Diff: Fahren.cpp
- Revision:
- 9:bdbf4447b55e
- Parent:
- 8:a7f1ee7840d0
diff -r a7f1ee7840d0 -r bdbf4447b55e Fahren.cpp --- a/Fahren.cpp Sun May 06 14:17:07 2018 +0000 +++ b/Fahren.cpp Sun May 06 15:18:14 2018 +0000 @@ -15,11 +15,12 @@ const float Fahren :: PERIOD = 0.8f; //Konstruktor -Fahren::Fahren(Controller& controller, EncoderCounter& counterLeft, EncoderCounter& counterRight, Regler& regler, int reglerEin): - controller(controller), counterLeft(counterLeft), counterRight(counterRight), regler(regler), reglerEin(reglerEin) { //IRSENSOR IETAH +Fahren::Fahren(Controller& controller, EncoderCounter& counterLeft, EncoderCounter& counterRight, Regler& regler, int reglerEin, IRSensor& iRSensor): + controller(controller), counterLeft(counterLeft), counterRight(counterRight), regler(regler), reglerEin(reglerEin), iRSensor (iRSensor) { //IRSENSOR IETAH SpeedR = 50; SpeedL = 50; + disF = 0; ticker.attach(callback(this, &Fahren::getSpeed), PERIOD); } @@ -37,7 +38,7 @@ }else {SpeedR = regler.getSpeedR(); SpeedL = regler.getSpeedL(); } - + disF = iRSensor.readF(); //printf("SpeedR in F = %f\n",SpeedR); //printf("SpeedL in F = %f\n",SpeedL); } @@ -124,13 +125,13 @@ // printf("Encoderlinks %d \n\r", counterLeft.read()); //Debugging Zweck (Putty benutzen!) //If Schleife, wenn Clicks erreicht sind, muss der Motor stoppen - if(counterRight.read() - initialClicksRight >= wegRechts || counterRight.read() - initialClicksRight <= -wegRechts){ + if(counterRight.read() - initialClicksRight >= wegRechts || counterRight.read() - initialClicksRight <= -wegRechts || disF <= 50){ controller.setDesiredSpeedRight(0); stopRight = true; } //If Schleife, wenn Clicks erreicht sind, muss der Motor stoppen - if(counterLeft.read() - initialClicksLeft >= wegLinks || counterLeft.read() - initialClicksLeft <= -wegLinks){ + if(counterLeft.read() - initialClicksLeft >= wegLinks || counterLeft.read() - initialClicksLeft <= -wegLinks || disF <= 50){ controller.setDesiredSpeedLeft(0); stopLeft = true; }