Quote:
Originally Posted by curtis0gj
lol I did a very lousy job of naming things, sorry for that and I will change the names to be more descriptive and properly cased. Anyway how can I get the waits to work again? This is the function,
I'm not sure how to program it, sorry I'm still fairly new to programming.
|
here's what I'd do
Code:
public static void turn(Robot r, double deg) {
if(deg < gyro.getAngle()){ //this is not right, need to have a function to handle rollovers
//example for such a function: if Math.abs(deg-gyro.getAngle()) < 90 || Math.abs(deg-gyro.getAngle()) > 270
//i dont know, just thinking to myself. see here for further instructions -> http://stackoverflow.com/questions/1878907/the-smallest-difference-between-2-angles
turnLeft(r,deg);
}else{
turnRight(r,deg);
}
}
public static void turnRight(Robot r, double deg){
while(true){
//turn right
if(distanceBetweenAngles(getGyro(),deg) <= MAX_ROTATE_ERROR){
return; //or break; whatever
}
Timer.delay(0.02);
}
}
except without the broken formatting since I made that in this text editor and not a code editor
E/ misunderstood the point of the code, fixed.