Quote:
Originally Posted by notmattlythgoe
I think I can give you a hand Curtis. Could you please list step by step what it is you want your autonomous mode to do?
|
Hi, thanks for the reply so basically what I am looking to do is make a 180 degree turn stop and drive straight forward for a set distance via encoder. However our team only has one encoder currently I don't know if this will be a problem. Today I figured out the turn finally and I added in the straight away however I am stuck in a loop I believe here's my current program
Code:
public void autonomous() {
gyro1.reset();
while(isAutonomous() && isEnabled()) {
double angle = gyro1.getAngle();
SmartDashboard.putNumber("angle", gyro1.getAngle());
robot.drive(-0.15, 1);
Timer.delay(0.1);
if(angle > 160) {
robot.drive(0,0);
gyro1.reset();
Timer.delay(1.00);
turnComplete = false;
break;
}
}
turnComplete = true;
gyro1.reset();
while (turnComplete == true) {
double angle2 = gyro1.getAngle(); // i think for driving i need a constant update of my angle
//so i will place this inside my if loop and i name it angle2 so it's a different variable.
robot.drive(-0.15, -angle2 * Kp); // driving straight in a line.
Timer.delay(0.004);
if(isAutonomous() && isDisabled()) {
robot.drive(0,0);
turnComplete = false;
break;
}
}
}