X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fsubsystems%2FDriveTrain.java;h=cde94b8f6a103c2d1e8115ada1d10227e3f52410;hb=b3bdd589f32d9c152d05388ae3ad0d9e56ec833c;hp=96f1d1150fd5d87a2d5e5531f8515fcf10302e4f;hpb=7e360ef5fdf5bb9ae932367bbeb5a930f54ee732;p=3501%2Fstronghold-2016 diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java index 96f1d115..cde94b8f 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java @@ -28,7 +28,7 @@ public class DriveTrain extends PIDSubsystem { private RobotDrive robotDrive; private GyroLib gyro; - private DoubleSolenoid leftGearPiston, rightGearPiston; + public DoubleSolenoid leftGearPiston, rightGearPiston; // Drivetrain specific constants that relate to the inches per pulse value for // the encoders @@ -44,8 +44,7 @@ public class DriveTrain extends PIDSubsystem { robotDrive = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight); - lidar = new Lidar(I2C.Port.kOnboard); - + lidar = new Lidar(I2C.Port.kMXP); leftEncoder = new Encoder(Constants.DriveTrain.ENCODER_LEFT_A, Constants.DriveTrain.ENCODER_LEFT_B, false, EncodingType.k4X); rightEncoder = new Encoder(Constants.DriveTrain.ENCODER_RIGHT_A, @@ -63,9 +62,10 @@ public class DriveTrain extends PIDSubsystem { this.disable(); gyro.start(); - leftGearPiston = new DoubleSolenoid(Constants.DriveTrain.LEFT_FORWARD, + leftGearPiston = new DoubleSolenoid(10, Constants.DriveTrain.LEFT_FORWARD, Constants.DriveTrain.LEFT_REVERSE); - rightGearPiston = new DoubleSolenoid(Constants.DriveTrain.RIGHT_FORWARD, + rightGearPiston = new DoubleSolenoid(10, + Constants.DriveTrain.RIGHT_FORWARD, Constants.DriveTrain.RIGHT_REVERSE); Constants.DriveTrain.inverted = false; } @@ -197,10 +197,10 @@ public class DriveTrain extends PIDSubsystem { /* * Method is a required method that the PID Subsystem uses to return the * calculated PID value to the driver - * + * * @param Gives the user the output from the PID algorithm that is calculated * internally - * + * * Body: Uses the output, does some filtering and drives the robot */ @Override @@ -213,11 +213,12 @@ public class DriveTrain extends PIDSubsystem { output = Math.signum(output) * 0.3; left = output; right = output + drift * Constants.DriveTrain.kp / 10; + drive(left, right); } else if (DRIVE_MODE == Constants.DriveTrain.GYRO_MODE) { left = output; right = -output; + arcadeDrive(0, output); } - drive(left, right); pidOutput = output; } @@ -228,7 +229,7 @@ public class DriveTrain extends PIDSubsystem { /* * Checks the drive mode - * + * * @return the current state of the robot in each state Average distance from * both sides of tank drive for Encoder Mode Angle from the gyro in GYRO_MODE */ @@ -257,12 +258,16 @@ public class DriveTrain extends PIDSubsystem { robotDrive.tankDrive(right, left); } + public void arcadeDrive(double y, double twist) { + robotDrive.arcadeDrive(y, twist); + } + /* * constrains the distance to within -100 and 100 since we aren't going to * drive more than 100 inches - * + * * Configure Encoder PID - * + * * Sets the setpoint to the PID subsystem */ public void driveDistance(double dist, double maxTimeOut) { @@ -302,10 +307,10 @@ public class DriveTrain extends PIDSubsystem { /* * Turning method that should be used repeatedly in a command - * + * * First constrains the angle to within -360 and 360 since that is as much as * we need to turn - * + * * Configures Gyro PID and sets the setpoint as an angle */ public void turnAngle(double angle) { @@ -360,4 +365,5 @@ public class DriveTrain extends PIDSubsystem { leftGearPiston.set(gear); rightGearPiston.set(gear); } + }