Quote:
Originally Posted by Arhowk
yeah thats fine. If you don't want to put r in front of everything, you can either
1) rename r to robot (atleast it looks more professional...)
2)
Code:
public class Auto {
static Robot r
static RobotDrive drive
static DigitalInput upperLimitSwitch
//and so on for other stuff
public static void setRobot(Robot rob) {
r = rob;
drive = r.drive;
upperLimitSwitch = r.limit4;
}
|
Also I was wondering how I can call the new turn function you showed me do I just call turn(r, deg that I want to turn???); And you also said there was an ugly block in robot will it be an issue?
Code:
public void autonomous() {
autoMethod = (Defines.Autos) autoChooser.getSelected();
Auto.run(this, autoMethod);
if (autoMethod == Defines.Autos.AUTO_GRAB_ONE_BIN_BLUE_SIDE) {
return;
} else if (autoMethod == Defines.Autos.AUTO_GRAB_ONE_BIN_RED_SIDE) {
return;
} else if (autoMethod == Defines.Autos.AUTO_MOVE_TO_ZONE) {
return;
} else if (autoMethod == Defines.Autos.AUTO_GRAB_TWO_BINS_RED_SIDE) {
return;
} else if (autoMethod == Defines.Autos.AUTO_GRAB_TWO_BINS_BLUE_SIDE) {
return;
}
}
Code:
public static void angleError(double setpointDegressZeroToThreeSixty, double experimentalDegrees) {
double err = setpointDegressZeroToThreeSixty - experimentalDegrees; // 0 TO 360!
if(err < -180) {
err += 360;
} else if(err > 180) {
err -= 360;
}
return err;
}
double kp_rotate = 0.01;
double MAX_ERROR = 5;
public static void turn(Robot r, double deg) {
while(true) {
double deltaAngle = angleError(deg, gyro.getAngle());
if(Math.abs(deg - deltaAngle) < MAX_ERROR) {
break;
} else {
r.robot.drive(0, deltaAngle * kp_rotate);
}
Timer.delay(0.02);
}
}
https://github.com/curtis0gj/5033-2014-15