Evan Brown
/
MM_rat_Assignment4-newwest
p
Fork of MM_rat_Assignment4 by
Diff: main.cpp
- Revision:
- 4:c545d63ee454
- Parent:
- 3:4e34437daef4
- Child:
- 5:bfabc00a73e8
diff -r 4e34437daef4 -r c545d63ee454 main.cpp --- a/main.cpp Mon Nov 27 17:33:34 2017 +0000 +++ b/main.cpp Mon Nov 27 17:41:36 2017 +0000 @@ -37,7 +37,7 @@ float leftFrontIRBase; float rightFrontIRBase; float p =0.5f; -float i; +float i =0.05f; float d=0.1f; LeftIR = 1; RightIR = 1; @@ -98,11 +98,11 @@ FrontRightIR = 0; // pc.printf( "%f \n" , leftValue); //pc.printf("%f \n", rightValue); - if(leftValue> 0.4f && leftFrontValue > 0.24f) + if(leftValue> 0.38f && leftFrontValue > 0.22f) { turn_right(); } - else if(rightFrontValue > 0.22f && rightValue > 0.4f) + else if(rightFrontValue > 0.21f && rightValue > 0.4f) { turn_left(); } @@ -117,8 +117,8 @@ leftFrontError = leftFrontIRBase - leftFrontValue; rightFrontError = rightFrontIRBase - rightFrontValue; - adjust_l = p*leftError-d*prevleftError ; - adjust_r = p*rightError-d*prevrightError ; + adjust_l = p*leftError-d*prevleftError-i*totalLeftError ; + adjust_r = p*rightError-d*prevrightError-i*totalRightError ; prevleftError = leftError; prevrightError = rightError;