Autoformatted
This commit is contained in:
parent
a9b18bc58a
commit
b1f2c54ad2
@ -35,9 +35,9 @@ public class OI {
|
||||
// Print log when button 1 pressed
|
||||
//joystickButtons[0][0].whenPressed(new LogEncoder());
|
||||
joystickButtons[0][0].whileHeld(new SetShooterState(true));
|
||||
joystickButtons[0][2].whileHeld(new SpinRollers(-0.5,false));
|
||||
joystickButtons[0][3].whileHeld(new SpinRollers(1,false));
|
||||
joystickButtons[0][6].whileHeld(new SpinRollers(1,true));
|
||||
joystickButtons[0][2].whileHeld(new SpinRollers(-0.5, false));
|
||||
joystickButtons[0][3].whileHeld(new SpinRollers(1, false));
|
||||
joystickButtons[0][6].whileHeld(new SpinRollers(1, true));
|
||||
// joystickButtons[0][2].whileHeld(new PIDDrive(400));
|
||||
joystickButtons[1][0].whileHeld(new MoveArm(1));
|
||||
joystickButtons[1][1].whileHeld(new MoveArm(-1));
|
||||
|
@ -31,7 +31,7 @@ public class Robot extends IterativeRobot {
|
||||
SmartDashboard.putData("MainArm", CommandBase.mainArm.getPIDController());
|
||||
SmartDashboard.putData("LeftEncoderController", CommandBase.driveBase.getLeftController());
|
||||
SmartDashboard.putData("gyroPID", CommandBase.driveBase.getGyroController());
|
||||
SmartDashboard.putNumber("GyroCorrection",0.13);
|
||||
SmartDashboard.putNumber("GyroCorrection", 0.13);
|
||||
SmartDashboard.putBoolean("CompressorEnabled", true);
|
||||
//Automatically determine if rolling in or rolling out
|
||||
SmartDashboard.putBoolean("SmartRollers", false);
|
||||
@ -67,7 +67,7 @@ public class Robot extends IterativeRobot {
|
||||
SmartDashboard.putNumber("ArmAngleRaw", CommandBase.mainArm.getRaw());
|
||||
SmartDashboard.putNumber("ArmAngleDegrees", CommandBase.mainArm.getDegrees());
|
||||
SmartDashboard.putNumber("tmpRotations", CommandBase.driveBase.getLeftRotations());
|
||||
if (Robot.oi.getJoysticks()[1].getRawButton(3)){
|
||||
if (Robot.oi.getJoysticks()[1].getRawButton(3)) {
|
||||
CommandBase.pneumatics.setArmStopState(true);
|
||||
} else {
|
||||
CommandBase.pneumatics.setArmStopState(false);
|
||||
|
@ -22,7 +22,7 @@ public class AutoDrive extends CommandBase {
|
||||
}
|
||||
protected void execute() {
|
||||
if (startDriving) {
|
||||
driveBase.pidDrive(distance,SmartDashboard.getNumber("GyroCorrection"));
|
||||
driveBase.pidDrive(distance, SmartDashboard.getNumber("GyroCorrection"));
|
||||
}
|
||||
startDriving = false;
|
||||
}
|
||||
|
@ -7,14 +7,14 @@ public class AutoDriveStraightDistance extends CommandBase {
|
||||
public AutoDriveStraightDistance(double distance, double timeout) {
|
||||
requires(driveBase);
|
||||
setTimeout(timeout);
|
||||
this.distance=distance;
|
||||
this.distance = distance;
|
||||
}
|
||||
protected void initialize() {
|
||||
driveBase.resetGyro();
|
||||
driveBase.getLeftEncoder().reset();
|
||||
driveBase.resetGyro();
|
||||
driveBase.getLeftEncoder().reset();
|
||||
}
|
||||
protected void execute() {
|
||||
driveBase.pidDrive(distance,SmartDashboard.getNumber("GyroCorrection"));
|
||||
driveBase.pidDrive(distance, SmartDashboard.getNumber("GyroCorrection"));
|
||||
}
|
||||
protected void end() {
|
||||
driveBase.getLeftController().disable();
|
||||
@ -24,7 +24,7 @@ public class AutoDriveStraightDistance extends CommandBase {
|
||||
end();
|
||||
}
|
||||
protected boolean isFinished() {
|
||||
return isTimedOut() || Math.abs(distance-driveBase.getLeftRotations()) <= 3;
|
||||
return isTimedOut() || Math.abs(distance - driveBase.getLeftRotations()) <= 3;
|
||||
}
|
||||
}
|
||||
// vim: sw=2:ts=2:sts=2
|
||||
|
@ -7,13 +7,13 @@ public class AutoDriveStraightTime extends CommandBase {
|
||||
public AutoDriveStraightTime(double speed, double time) {
|
||||
requires(driveBase);
|
||||
setTimeout(time);
|
||||
this.speed=speed;
|
||||
this.speed = speed;
|
||||
}
|
||||
protected void initialize() {
|
||||
driveBase.resetGyro();
|
||||
driveBase.resetGyro();
|
||||
}
|
||||
protected void execute() {
|
||||
driveBase.driveStraight(-speed,SmartDashboard.getNumber("GyroCorrection"));
|
||||
driveBase.driveStraight(-speed, SmartDashboard.getNumber("GyroCorrection"));
|
||||
}
|
||||
protected void end() {
|
||||
driveBase.stopDriving();
|
||||
|
@ -6,7 +6,7 @@ public class AutoRotate extends CommandBase {
|
||||
double degrees;
|
||||
public AutoRotate(double degrees) {
|
||||
requires(driveBase);
|
||||
this.degrees=degrees;
|
||||
this.degrees = degrees;
|
||||
setTimeout(2.5);
|
||||
}
|
||||
protected void initialize() {
|
||||
|
@ -6,6 +6,6 @@ public class RoutineDriveStraightDistance extends CommandGroup {
|
||||
public RoutineDriveStraightDistance() {
|
||||
addSequential(new AutoSetArmStopState(true));
|
||||
addSequential(new AutoResetLower(-1));
|
||||
addSequential(new AutoDriveStraightDistance(200,5));
|
||||
addSequential(new AutoDriveStraightDistance(200, 5));
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ public class RoutineDriveStraightTime extends CommandGroup {
|
||||
public RoutineDriveStraightTime() {
|
||||
addSequential(new AutoSetArmStopState(true));
|
||||
addSequential(new AutoResetLower(-1));
|
||||
addSequential(new AutoDriveStraightTime(0.5,1));
|
||||
addSequential(new AutoDriveStraightTime(0.5, 1));
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,10 @@ public class RoutineRaiseArmFire extends CommandGroup {
|
||||
public RoutineRaiseArmFire() {
|
||||
addSequential(new AutoSetArmPosition(90));
|
||||
//Raise the arm a little before spinning rollers
|
||||
try{ wait(2); }catch(Exception e){ }
|
||||
addParallel(new AutoSpinRollers(0.5,5));
|
||||
try {
|
||||
wait(2);
|
||||
} catch (Exception e) { }
|
||||
addParallel(new AutoSpinRollers(0.5, 5));
|
||||
addSequential(new AutoSetShooterState(true));
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ public class RoutineShoot extends CommandGroup {
|
||||
public RoutineShoot() {
|
||||
addSequential(new AutoSetArmStopState(true));
|
||||
addSequential(new AutoResetLower(-1));
|
||||
addSequential(new AutoDriveStraightTime(0.5,1));
|
||||
addSequential(new AutoDriveStraightTime(0.5, 1));
|
||||
addParallel(new AutoSetArmPosition(90));
|
||||
addSequential(new AutoRotate(45));
|
||||
addSequential(new AutoDriveStraightTime(0.4,1.5));
|
||||
addSequential(new AutoSpinRollers(1,2));
|
||||
addSequential(new AutoDriveStraightTime(0.4, 1.5));
|
||||
addSequential(new AutoSpinRollers(1, 2));
|
||||
addSequential(new AutoSetShooterState(true));
|
||||
addSequential(new AutoSetArmStopState(false));
|
||||
addParallel(new AutoSetArmPosition(10));
|
||||
|
@ -6,19 +6,19 @@ public class RoutineTwoBallDropOff extends CommandGroup {
|
||||
public RoutineTwoBallDropOff() {
|
||||
addSequential(new AutoSetArmStopState(true));
|
||||
addSequential(new AutoResetLower(-1));
|
||||
addSequential(new AutoDriveStraightTime(0.5,2));
|
||||
addSequential(new AutoMoveArm(0.5,1));
|
||||
addSequential(new AutoSpinRollers(1,2));
|
||||
addSequential(new AutoDriveStraightTime(0.5, 2));
|
||||
addSequential(new AutoMoveArm(0.5, 1));
|
||||
addSequential(new AutoSpinRollers(1, 2));
|
||||
addSequential(new AutoSetShooterState(true));
|
||||
addSequential(new AutoResetLower(-1));
|
||||
addSequential(new AutoRotate(180));
|
||||
addSequential(new AutoSetShooterState(false));
|
||||
addParallel(new AutoSpinRollers(-0.5,3));
|
||||
addSequential(new AutoDriveStraightTime(0.5,2));
|
||||
addParallel(new AutoSpinRollers(-0.5, 3));
|
||||
addSequential(new AutoDriveStraightTime(0.5, 2));
|
||||
addSequential(new AutoRotate(180));
|
||||
addSequential(new AutoDriveStraightTime(0.5,2));
|
||||
addSequential(new AutoMoveArm(0.5,1));
|
||||
addSequential(new AutoSpinRollers(1,2));
|
||||
addSequential(new AutoDriveStraightTime(0.5, 2));
|
||||
addSequential(new AutoMoveArm(0.5, 1));
|
||||
addSequential(new AutoSpinRollers(1, 2));
|
||||
addSequential(new AutoSetShooterState(true));
|
||||
addSequential(new AutoRotate(180));
|
||||
addSequential(new AutoSetShooterState(false));
|
||||
|
@ -16,7 +16,7 @@ public class PIDDrive extends CommandBase {
|
||||
}
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
protected void execute() {
|
||||
driveBase.pidDrive(count,SmartDashboard.getNumber("GyroCorrection"));
|
||||
driveBase.pidDrive(count, SmartDashboard.getNumber("GyroCorrection"));
|
||||
}
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
protected boolean isFinished() {
|
||||
|
@ -17,9 +17,9 @@ public class DriveBase extends Subsystem {
|
||||
CANTalon rightMotorTwo = new CANTalon(RobotMap.driveRightMotorTwo);
|
||||
Encoder leftEncoder = new Encoder(RobotMap.driveLeftEncoderA, RobotMap.driveLeftEncoderB, false, Encoder.EncodingType.k4X);
|
||||
AnalogGyro gyro = new AnalogGyro(RobotMap.gyro);
|
||||
PIDController gyroController = new PIDController(0.07,0.002,0.08, new GyroPIDSource(), new MotorsPIDOutputReversed());
|
||||
PIDController gyroController = new PIDController(0.07, 0.002, 0.08, new GyroPIDSource(), new MotorsPIDOutputReversed());
|
||||
PIDController leftEncoderController = new PIDController(0.02, 0.002, 0.017, leftEncoder, new MotorsPIDOutput());
|
||||
double encoderGyroCorrection=1;
|
||||
double encoderGyroCorrection = 1;
|
||||
public void initDefaultCommand() {
|
||||
setDefaultCommand(new Drive());
|
||||
}
|
||||
@ -35,40 +35,40 @@ public class DriveBase extends Subsystem {
|
||||
rightMotorOne.set((y + (x + z)) * sensitivity);
|
||||
rightMotorTwo.set((y + (x + z)) * sensitivity);
|
||||
}
|
||||
public void driveStraight(double y, double correction){
|
||||
SmartDashboard.putNumber("GyroAngle",gyro.getAngle());
|
||||
leftMotorOne.set((-y + -gyro.getAngle()*correction));
|
||||
leftMotorTwo.set((-y + -gyro.getAngle()*correction));
|
||||
rightMotorOne.set((y + -gyro.getAngle()*correction));
|
||||
rightMotorTwo.set((y + -gyro.getAngle()*correction));
|
||||
public void driveStraight(double y, double correction) {
|
||||
SmartDashboard.putNumber("GyroAngle", gyro.getAngle());
|
||||
leftMotorOne.set((-y + -gyro.getAngle() * correction));
|
||||
leftMotorTwo.set((-y + -gyro.getAngle() * correction));
|
||||
rightMotorOne.set((y + -gyro.getAngle() * correction));
|
||||
rightMotorTwo.set((y + -gyro.getAngle() * correction));
|
||||
}
|
||||
public void pidDrive(double setpoint, double correction) {
|
||||
leftEncoder.reset();
|
||||
leftEncoderController.enable();
|
||||
leftEncoderController.setSetpoint(setpoint);
|
||||
encoderGyroCorrection=-gyro.getAngle()*correction;
|
||||
encoderGyroCorrection = -gyro.getAngle() * correction;
|
||||
}
|
||||
public void rotateAngle(double angle){
|
||||
SmartDashboard.putNumber("GyroAngle",gyro.getAngle());
|
||||
public void rotateAngle(double angle) {
|
||||
SmartDashboard.putNumber("GyroAngle", gyro.getAngle());
|
||||
gyroController.enable();
|
||||
gyroController.setSetpoint(angle);
|
||||
}
|
||||
public PIDController getLeftController() {
|
||||
return leftEncoderController;
|
||||
}
|
||||
public PIDController getGyroController(){
|
||||
public PIDController getGyroController() {
|
||||
return gyroController;
|
||||
}
|
||||
public double getLeftRotations() {
|
||||
return leftEncoder.get();
|
||||
}
|
||||
public void resetGyro(){
|
||||
public void resetGyro() {
|
||||
gyro.reset();
|
||||
}
|
||||
public Encoder getLeftEncoder(){
|
||||
public Encoder getLeftEncoder() {
|
||||
return leftEncoder;
|
||||
}
|
||||
public AnalogGyro getGyro(){
|
||||
public AnalogGyro getGyro() {
|
||||
return gyro;
|
||||
}
|
||||
public class MotorsPIDOutput implements PIDOutput {
|
||||
@ -89,14 +89,14 @@ public class DriveBase extends Subsystem {
|
||||
rightMotorTwo.pidWrite(output);
|
||||
}
|
||||
}
|
||||
public class GyroPIDSource implements PIDSource{
|
||||
public double pidGet(){
|
||||
public class GyroPIDSource implements PIDSource {
|
||||
public double pidGet() {
|
||||
return gyro.getAngle();
|
||||
}
|
||||
public PIDSourceType getPIDSourceType(){
|
||||
public PIDSourceType getPIDSourceType() {
|
||||
return PIDSourceType.kDisplacement;
|
||||
}
|
||||
public void setPIDSourceType(PIDSourceType type){
|
||||
public void setPIDSourceType(PIDSourceType type) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user