Added base auto code (untested)

This commit is contained in:
Austen Adler 2016-09-19 12:43:22 -04:00
parent ca5b340a1a
commit 5199055203
No known key found for this signature in database
GPG Key ID: 7ECEE590CCDFE3F1
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package org.usfirst.frc.team2059.robot.commands.autonomous;
import org.usfirst.frc.team2059.robot.commands.CommandBase;
import org.usfirst.frc.team2059.robot.Robot;
public class AutoDrive extends CommandBase {
private double distance;
// Determines if we should start driving
// Will be false if we already started driving
private boolean startDriving = true;
public AutoDrive(double distance, double timeout) {
requires(driveBase);
this.distance = distance;
setTimeout(timeout);
}
public AutoDrive(double distance) {
requires(driveBase);
this.distance = distance;
// Make the default timeout 2s
setTimeout(2.0d);
}
protected void initialize() {
}
protected void execute() {
if (startDriving) {
driveBase.pidDrive(distance);
}
startDriving = false;
}
protected void end() {
startDriving = true;
driveBase.stopDriving();
}
protected void interrupted() {
end();
}
protected boolean isFinished() {
return isTimedOut();
}
}
// vim: sw=2:ts=2:sts=2

View File

@ -16,6 +16,12 @@ public class DriveBase extends Subsystem {
public void initDefaultCommand() {
setDefaultCommand(new Drive());
}
public void stopDriving() {
leftMotorOne.set(0);
leftMotorTwo.set(0);
rightMotorOne.set(0);
rightMotorTwo.set(0);
}
public void driveArcade(double x, double y, double z, double sensitivity) {
leftMotorOne.set(-y + (x + z));
leftMotorTwo.set(-y + (x + z));