zhaw_st16b_pes2_10
/
PES-Yanick2
ahah
Fork of PES_Official by
Revision 6:9627ef490cd5, committed 2017-05-02
- Comitter:
- EpicG10
- Date:
- Tue May 02 10:35:15 2017 +0000
- Parent:
- 5:1aaf5de776ff
- Commit message:
- ok;
Changed in this revision
diff -r 1aaf5de776ff -r 9627ef490cd5 Headers/Declarations.h --- a/Headers/Declarations.h Wed Apr 26 08:05:25 2017 +0000 +++ b/Headers/Declarations.h Tue May 02 10:35:15 2017 +0000 @@ -3,7 +3,7 @@ //DistanceSensors: #define NEAR 0.18f //Used for distance Sensors. If they're to near to a wall -> turn -#define NEAR_LEGO 0.20f //If the DistanceSensors are near to a Lego... +#define NEAR_LEGO 0.15f //If the DistanceSensors are near to a Lego... #define LEFT_L 5 //Arrayindex of the left LEGO Sensor & left LED #define FWD_L 0 //Arrayindex of the front LEGO Sensor & front LED
diff -r 1aaf5de776ff -r 9627ef490cd5 Sources/Robot.cpp --- a/Sources/Robot.cpp Wed Apr 26 08:05:25 2017 +0000 +++ b/Sources/Robot.cpp Tue May 02 10:35:15 2017 +0000 @@ -162,11 +162,48 @@ *counter = MAX; //setting counter to MAX will couse sam to turnAround } - if (this->sensors[FWD_L] > 0.16f){ + if (this->sensors[FWD_L] > 0.20f){ this->drive(); } else{ *found = 1; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } } @@ -179,7 +216,7 @@ *lastAct = 5; } - if (this->sensors[FWD_L] > 0.22f){ + if (this->sensors[FWD_L] > 0.15f){ this->turnRight(); } else{ @@ -236,11 +273,11 @@ counterMax(counter, timer, &lastAct, &rando); } - /*//Wall actions: + //Wall actions: else if (this->sensors[RIGHT] < NEAR && legoFound == -1){ //Robot has spotted an obstacle on the right. wallRight(counter, timer, &lastAct); } - */ + else if (this->sensors[LEFT] < NEAR && legoFound == -1) { //Robot has spotted an obstacle on the left. wallLeft(counter, timer, &lastAct); } @@ -285,54 +322,10 @@ nothingFound(counter, timer, &lastAct); } } +//OLD funktion -void Robot::lego(int* counter, Timer* t){ - - if (this->sensors[RIGHT_L] < NEAR_LEGO){ - t->reset(); - - *counter += 1; - while (this->sensors[FWD] > NEAR_LEGO){ - if ( t->read() > TIMEOUT ){ - break; - } - - this->turnRight(); - } - this->stop(); - } - - else if (this->sensors[LEFT] < NEAR_LEGO){ - t-> reset(); - - *counter += 1; - while (this->sensors[FWD] > NEAR_LEGO){ - if ( t->read() > TIMEOUT ){ - break; - } - - this->turnLeft(); - } - this->stop(); - } - - else if (this->sensors[FWD] < 0.12f){ - while (this->sensors[FWD] < 0.12f){ - this->driveB(); - } - while (this->sensors[FWD] < NEAR_LEGO){ - this->turnRight(); - } - while(1){ - this->stop(); - } - } - - else { - *counter = 0; - this->drive(); - } -} + + //void Robot::init(){ // Robot.DistanceSensors.init(&sensorVoltage, &bit0, &bit1, &bit2, ii); @@ -345,4 +338,4 @@ //reset //} -//Add management for Overpower!! Pin PB_15 \ No newline at end of file +//Add management for Overpower!! Pin PB_15 \ No newline at end of file
diff -r 1aaf5de776ff -r 9627ef490cd5 Sources/main.cpp --- a/Sources/main.cpp Wed Apr 26 08:05:25 2017 +0000 +++ b/Sources/main.cpp Tue May 02 10:35:15 2017 +0000 @@ -54,6 +54,12 @@ int found = 0; //0:= no block available, 1 := a lego is ready to be picked up while( 1 ){ + if(sam.sensors[FWD_L]<0.14) leds[2]=1; + else leds[2]=0; + if(sam.sensors[RIGHT_L]<0.14) leds[1]=1; + else leds[1]=0; + if(sam.sensors[LEFT_L]<0.14) leds[5]=1; + else leds[5]=0; if ( timer > TIMEOUT ){ NVIC_SystemReset(); //Resets Sam. } @@ -68,7 +74,7 @@ wait( 0.1f ); } - return 0; + // return 0; } /* * /