Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Uberbots2017/build/org/usfirst/frc/team1124/robot/Robot.class
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

public class DriveForward extends Command {

Drive drive = Robot.drive;

private double distanceInTicks;

private boolean done = false;
Expand All @@ -19,8 +21,18 @@ public class DriveForward extends Command {
private static final int TICKS_TIL_FULL = 16000;

private static final double QUIT_SPEED = 0.1;


public static final int DRIVE_MODE_NONE = 0;

public static final int DRIVE_MODE_ARCADE = 1;

public static final int DRIVE_MODE_MECANUM = 2;
private int sign;

int totalEncPosition = -drive.frontLeft.getEncPosition() + drive.frontRight.getEncPosition()
- drive.rearLeft.getEncPosition() + drive.rearRight.getEncPosition();


public DriveForward(double distance) {
sign = (int) (distance / Math.abs(distance));
Expand All @@ -36,14 +48,13 @@ protected void initialize() {
done = false;
}

protected void execute() {
Drive drive = Robot.drive;
int average = sign * (-drive.frontLeft.getEncPosition() + drive.frontRight.getEncPosition() - drive.rearLeft.getEncPosition() + drive.rearRight.getEncPosition()) / 4;
protected void execute() {
int average = sign * (totalEncPosition) / 4;
double speed = sign * getSpeed(average);
if (Math.abs(speed) <= QUIT_SPEED)
quit();
else {
Robot.drive.mode = 2;
Robot.drive.mode = DRIVE_MODE_MECANUM;
Robot.drive.run(0, speed);
}

Expand Down Expand Up @@ -81,7 +92,6 @@ private double getSpeed(int ticksSoFar) {
}
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return done;
}
Expand All @@ -90,10 +100,7 @@ public boolean done() {
return done;
}

// Called once after isFinished returns true
protected void end() {}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {}
protected void interrupted() { this.cancel(); }
}