From: Rohan Rodrigues Date: Thu, 9 Mar 2017 00:49:44 +0000 (-0800) Subject: Merged with master X-Git-Url: http://challenge-bot.com/repos/?p=3501%2F2017steamworks;a=commitdiff_plain;h=6bc81b557f637fa81f73c33161e82cba049235f3 Merged with master --- 6bc81b557f637fa81f73c33161e82cba049235f3 diff --cc src/org/usfirst/frc/team3501/robot/Constants.java index 91a5cc7,d51dfe7..312e0c3 --- a/src/org/usfirst/frc/team3501/robot/Constants.java +++ b/src/org/usfirst/frc/team3501/robot/Constants.java @@@ -25,7 -24,8 +24,12 @@@ public class Constants public final static int REVERSE_INTAKE_PORT = 4; public static final int INCREASE_SHOOTER_SPEED_PORT = 6; public static final int DECREASE_SHOOTER_SPEED_PORT = 2; ++ + public static final int CHANGE_CAMERA_VIEW = 6; ++ + public static final int BRAKE_CANTALONS_PORT = 5; + public static final int COAST_CANTALONS_PORT = 3; ++ } public static class Shooter { @@@ -36,10 -36,8 +40,11 @@@ public final static int HALL_EFFECT_PORT = 9; + public final static int TOGGLE_INDEXER = 8; + - public static final int PISTON_MODULE = 10, PISTON_FORWARD = 4, + public static final int MODULE_NUMBER = 10, PISTON_FORWARD = 4, PISTON_REVERSE = 5; ++ public static final Value HIGH_GEAR = DoubleSolenoid.Value.kForward; public static final Value LOW_GEAR = DoubleSolenoid.Value.kReverse; } diff --cc src/org/usfirst/frc/team3501/robot/OI.java index 07ad53c,a1abe0a..880894f --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@@ -1,6 -1,7 +1,5 @@@ package org.usfirst.frc.team3501.robot; - import org.usfirst.frc.team3501.robot.commands.climber.ToggleWinch; -import org.usfirst.frc.team3501.robot.commands.driving.BrakeCANTalons; -import org.usfirst.frc.team3501.robot.commands.driving.CoastCANTalons; import org.usfirst.frc.team3501.robot.commands.driving.ToggleGear; import org.usfirst.frc.team3501.robot.commands.intake.ReverseIntakeContinuous; import org.usfirst.frc.team3501.robot.commands.intake.RunIntakeContinuous; @@@ -34,13 -32,10 +32,16 @@@ public class OI /* implements KeyListen public static Button increaseShooterSpeed; public static Button decreaseShooterSpeed; + private static Button changeCam; + + private static Button togglePiston; + private static Button toggleDriveTrainPiston; + + public static Button brakeCANTalons; + public static Button coastCANTalons; + public OI() { + leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT); rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT); @@@ -79,17 -70,13 +76,25 @@@ Constants.OI.DECREASE_SHOOTER_SPEED_PORT); decreaseShooterSpeed.whenPressed(new DecreaseShootingSpeed()); + changeCam = new JoystickButton(rightJoystick, + Constants.OI.CHANGE_CAMERA_VIEW); + changeCam.toggleWhenPressed(new ChangeCameraView()); + + togglePiston = new JoystickButton(rightJoystick, + Constants.Shooter.TOGGLE_INDEXER); + togglePiston.whenPressed(new ToggleIndexerPiston()); + + toggleDriveTrainPiston = new JoystickButton(rightJoystick, + Constants.DriveTrain.TOGGLE_DRIVE_PISTON); + toggleDriveTrainPiston.whenPressed(new ToggleGear()); ++ + brakeCANTalons = new JoystickButton(rightJoystick, + Constants.OI.BRAKE_CANTALONS_PORT); + brakeCANTalons.whenPressed(new BrakeCANTalons()); + + coastCANTalons = new JoystickButton(rightJoystick, + Constants.OI.COAST_CANTALONS_PORT); + coastCANTalons.whenPressed(new CoastCANTalons()); } public static OI getOI() { diff --cc src/org/usfirst/frc/team3501/robot/Robot.java index e72f07e,a8c4864..5e9bd3c --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@@ -24,9 -23,12 +24,12 @@@ public class Robot extends IterativeRob oi = OI.getOI(); shooter = Shooter.getShooter(); intake = Intake.getIntake(); + - CameraServer server = CameraServer.getInstance(); + server = CameraServer.getInstance(); UsbCamera climberCam = server.startAutomaticCapture("climbercam", 0); UsbCamera intakeCam = server.startAutomaticCapture("intakecam", 1); + + driveTrain.setCANTalonsBrakeMode(driveTrain.DRIVE_COAST_MODE); } public static DriveTrain getDriveTrain() { diff --cc src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java index 2004c1d,9594013..ccc0e43 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/RunIndexWheelContinuous.java @@@ -32,30 -28,27 +29,27 @@@ public class RunIndexWheelContinuous ex requires(shooter); } - // Called just before this Command runs the first time @Override protected void initialize() { + t.start(); } - // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - - if (timeSinceInitialized() % 0.5 <= 0.02) { + if (t.get() >= 1) { if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) { Shooter.getShooter().setHighGear(); } else { Shooter.getShooter().setLowGear(); } + t.reset(); } - double shooterSpeed = shooter.getShooterRPM(); - double targetShooterSpeed = shooter.getTargetShootingSpeed(); - double threshold = shooter.getRPMThreshold(); - if (Math.abs(shooterSpeed - targetShooterSpeed) <= threshold) + if (shooter.isShooterRPMWithinRangeOfTargetSpeed(25)) shooter.runIndexWheel(); ++ } - // Called once after isFinished returns true @Override protected void end() { shooter.stopIndexWheel(); diff --cc src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 75737a6,faca5dd..820bc6a --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@@ -16,12 -17,15 +17,16 @@@ public class Shooter extends Subsystem private static HallEffectSensor hallEffect; private final CANTalon flyWheel1, flyWheel2, indexWheel; - private static final double DEFAULT_INDEXING_SPEED = -0.75; - private static final double DEFAULT_SHOOTING_SPEED = 2800; // rpm - private static final double SHOOTING_SPEED_INCREMENT = 25; + private PIDController wheelController; + + private static final double RPM_THRESHOLD = 10; + private static final double DEFAULT_INDEXING_MOTOR_VALUE = -0.75; + private static final double DEFAULT_SHOOTING_SPEED = 3100; // rpm + private static final double SHOOTING_SPEED_INCREMENT = 50; + private static final int ACCEPTABLE_SHOOTING_DEVIATION = 300; - private double currentShootingSpeed = DEFAULT_SHOOTING_SPEED; + private double targetShootingSpeed = DEFAULT_SHOOTING_SPEED; + private double currentShooterMotorValue = 0; private final DoubleSolenoid piston;