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: Regler.cpp
- Revision:
- 8:a7f1ee7840d0
- Parent:
- 7:862d80e0ea2d
- Child:
- 9:bdbf4447b55e
--- a/Regler.cpp Fri May 04 16:26:59 2018 +0000 +++ b/Regler.cpp Sun May 06 14:17:07 2018 +0000 @@ -13,9 +13,9 @@ using namespace std; -const float Regler :: PERIOD = 0.2f; +const float Regler :: PERIOD = 0.5f; const int Regler :: FIXSPEED = 50; -float faktor = 0.1; +float faktor = 0.1f; @@ -33,11 +33,23 @@ void Regler::setSpeed (){ measR2 = iRSensor.readR(); // Converts and read the analog input value (value from 0.0 to 1.0) - measL2 = iRSensor.readL(); + measL2 = iRSensor.readL(); + if(measR2 == measL2){ //DAS ISCH MIN GAGAREGLER zum Pröble gsi + SpeedR = FIXSPEED; + SpeedL = FIXSPEED; + }else if(measR2 < measL2 && measR2 < 300 && measL2 < 300){ //float style implementiert + SpeedR = FIXSPEED; + SpeedL = FIXSPEED*1.04; + }else if(measR2 > measL2 && measR2 < 300 && measL2 < 300){ + SpeedR = FIXSPEED*1.06; + SpeedL = FIXSPEED; + } + + /* if((measR2 > 100) && (measL2 < 100)) { //keine Wnad rechts - if(measL2 > 47){ - div3 = measL2 - 47; + if(measL2 > 40){ + div3 = measL2 - 40; kor3 = faktor*div3; div2 = 0; div1 = 0; @@ -46,8 +58,8 @@ div6 = 0; SpeedR = FIXSPEED; SpeedL = FIXSPEED + kor3; - } else if (measL2 < 52){ - div4 = 52 - measR2; + } else if (measL2 < 45){ + div4 = 45 - measR2; kor4 = faktor*div4; div2 = 0; div1 = 0; @@ -114,14 +126,17 @@ //printf("Div1 = %f\n",div1); //printf("Div2 = %f\n",div2); //printf("SpeedR1 = %f\n",SpeedR); -//printf("SpeedL1 = %f\n",SpeedL); +//printf("SpeedL1 = %f\n",SpeedL); + +*/ + } - float Regler :: getSpeedR (){ + float Regler :: getSpeedR(){ SpeedR = SpeedR; //printf("SpeedR2 = %f\n",SpeedR); return SpeedR; } - float Regler :: getSpeedL (){ + float Regler :: getSpeedL(){ SpeedL = SpeedL; //printf("SpeedL2 = %f\n",SpeedL); return SpeedL;