Gruppe 3
/
PES
Roboter
Diff: Roboter.cpp
- Revision:
- 6:4af735d26b7a
- Parent:
- 4:fdcf3b5009c6
- Child:
- 8:6d9cd5ad332d
diff -r f48b2609c328 -r 4af735d26b7a Roboter.cpp --- a/Roboter.cpp Tue Apr 11 14:43:29 2017 +0000 +++ b/Roboter.cpp Tue Apr 11 14:53:18 2017 +0000 @@ -20,9 +20,6 @@ this->switch2 = switch2; - pwmL->period(0.00005f); // Setzt die Periode auf 50 μs - pwmR->period(0.00005f); - } float Roboter::readSensor1() @@ -39,19 +36,23 @@ float x=0.13f; // Distanz ab welcher sensoren reagieren sollen + offsetDir = 0; + offsetLin = 0; - offsetDir = 0; - offsetLin = 0.1; - + if(sensors[0] < x && sensors[1] < x && sensors[5] < x) { // alle sensoren aktiv, roboter fährt nach hinten + offsetLin = -0.1f; + } if(sensors[0].read() < x && sensors[5] > x) { // sensor vorne, roboter dreht nach links offsetDir = -0.05; offsetLin = 0; } + if(sensors[1] < x) { // sensor rechts, roboter dreht nach links offsetDir = -0.05; offsetLin = 0; } + if(sensors[5] < x && sensors[1]>(x+0.02f)) { // sensor links, roboter dreht nach rechts offsetDir = 0.05; offsetLin = 0; @@ -71,23 +72,3 @@ } - -void Roboter::findBlock() //im Kreis drehen -{ - static int count =0; - count++; - - if(count <= 10); //1s lang (10*0.1s) im Kreis drehen - *pwmL = 0.55f; - *pwmR = 0.55f; - - if(count > 10 && count <= 20); //zwischen Sekunde 1 und 2 geradeaus fahren - *pwmL = 0.6f; - *pwmR = 0.4f; - - if(count > 20 && count <=30); //zwischen Sekunde 2 und 3 im Kreis drehen - *pwmL = 0.55f; - *pwmR = 0.55f; - -} -