/** * Gets the registered shooters present in the database, along with the name of the club they * belong to. */ public List<Shooter> getShooters() { String selectSql = "SELECT shooters.id, shooters.name, clubs.club FROM shooters JOIN clubs ON shooters.club = clubs.id"; List<Shooter> shooters = new ArrayList<Shooter>(); try (Connection conn = connector.getConnection(); ) { ResultSet dbResult = null; PreparedStatement ps = null; try { ps = DBUtils.makePreparedStatement(conn, selectSql, new Object[0]); dbResult = ps.executeQuery(); while (dbResult.next()) { Shooter shooter = new Shooter(); shooter.setId(dbResult.getInt(1)); shooter.setShooterName(dbResult.getString(2)); shooter.setClubName(dbResult.getString(3)); shooters.add(shooter); } } finally { if (dbResult != null) { dbResult.close(); } if (ps != null) { ps.close(); } } } catch (SQLException e) { throw new IllegalStateException( "Could not retrieve the clubs for with the SQL '" + selectSql + "'.", e); } return shooters; }
public KajDrive() { shooter = Shooter.getInstance(); driveTrain = DriveTrain.getInstance(); oi = OI.getInstance(); driver = oi.getDriver(); operator = oi.getOperator(); DriverControls.setDriveMode(0); shooter = Shooter.getInstance(); pneumatics = Pneumatics.getInstance(); System.out.println("KajDrive"); requires(driveTrain); }
/** This function is called periodically during operator control */ public void teleopPeriodic() { // Class teleop functions tankDrive.teleopPeriodic(); driveShift.teleopPeriodic(); arm.teleopPeriod(); // Shooter functions shooter.intake(); shooter.armPivot(); shooter.armPistons(); // Runs duel cameras cameraFeeds.run(); }
/** Runs shooter code */ private void joyShooter() { shooter.update(); if (robotCore.joy.getButton(JoyConfig.shootButton) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { shooter.shoot(); } if (robotCore.joy.getButton(JoyConfig.cancelShotButton) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { shooter.cancelShot(); } if (robotCore.joy.getButton(JoyConfig.shooterConstantSpeedButton) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { shooter.setSpeed(ShooterConfig.constantSpeed); } if (robotCore.joy.getButton(JoyConfig.setShooterSpeedButton) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { shooter.setSpeed(); } if (robotCore.joy.getButton(JoyConfig.shooterStopButton) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { shooter.stopShooter(); } if (robotCore.joy.getButton(JoyConfig.shooterLaunchButton) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { shooter.launchBall(); } if (robotCore.joy.getButton(9) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { shooter.changeShooterSpeed(-0.01); } if (robotCore.joy.getButton(10) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { shooter.changeShooterSpeed(0.01); } // if(robotCore.joy.getButton(JoyConfig.climbButton)) { // shooter.setVisionUse(false); // } }
public Competition getCompetition(int competitionID) { String selectSql = "SELECT competitions.id, shooters.name, clubs.club FROM competitions" + " JOIN shooters ON competitions.shooter = shooters.id" + " JOIN clubs ON shooters.club = clubs.id" + " WHERE competitions.id = ?"; Competition competition = null; try (Connection conn = connector.getConnection(); ) { ResultSet dbResult = null; PreparedStatement ps = null; try { ps = DBUtils.makePreparedStatement(conn, selectSql, competitionID); dbResult = ps.executeQuery(); while (dbResult.next()) { competition = new Competition(); competition.setCompetitionID(dbResult.getInt(1)); Shooter shooter = new Shooter(); shooter.setShooterName(dbResult.getString(2)); shooter.setClubName(dbResult.getString(3)); competition.setShooter(shooter); } } finally { if (dbResult != null) { dbResult.close(); } if (ps != null) { ps.close(); } } } catch (SQLException e) { throw new IllegalStateException( "Could not retrieve the clubs for with the SQL '" + selectSql + "'.", e); } return competition; }
// Called repeatedly when this Command is scheduled to run protected void execute() { OurTimer time = OurTimer.getTimer("KajDrive"); shooter.setLight(false); double rightSpeed, leftSpeed, x, y; if (!InputConstants.competitionCode) { if (operator.getRawButton(InputConstants.r1Button)) { halfSpeed = !halfSpeed; } if (!driveTrain.locked && operator.getRawAxis(InputConstants.leftXAxis) > 0.2 || operator.getRawAxis(InputConstants.leftXAxis) < -0.2 || operator.getRawAxis(InputConstants.leftYAxis) > 0.2 || operator.getRawAxis(InputConstants.leftYAxis) < -0.2 || operator.getRawAxis(InputConstants.rightXAxis) > 0.2 || operator.getRawAxis(InputConstants.rightXAxis) < -0.2 || operator.getRawAxis(InputConstants.rightYAxis) > 0.2 || operator.getRawAxis(InputConstants.rightYAxis) < -0.2) { driveTrain.locked = true; } if (driveTrain.locked) { x = operator.getRawAxis(InputConstants.rightXAxis); y = operator.getRawAxis(InputConstants.leftYAxis); } else { x = driver.getRawAxis(InputConstants.rightXAxis); y = driver.getRawAxis(InputConstants.leftYAxis); } if (operator.getRawButton(InputConstants.triangleButton)) { driveTrain.locked = false; } x = x * x * x; y = y * y * y; if (halfSpeed) { leftSpeed = (x - y) / 2; rightSpeed = (-x - y) / 2; } else { leftSpeed = x - y; rightSpeed = -x - y; } } else { x = driver.getRawAxis(InputConstants.rightXAxis); y = driver.getRawAxis(InputConstants.leftYAxis); x = x * x * x; y = y * y * y; leftSpeed = x - y; rightSpeed = -x - y; } // System.out.println("Operator axis: " + operator.getRawAxis(InputConstants.rightXAxis) + " " + // operator.getRawAxis(InputConstants.leftYAxis)); // System.out.println("Driver axis: " + driver.getRawAxis(InputConstants.rightXAxis) + " " + // driver.getRawAxis(InputConstants.leftYAxis)); System.out.println("Locked: " + driveTrain.locked); if (driver.getRawButton(InputConstants.l1Button)) { driveTrain.setLeftVBus(leftSpeed / 2.0); driveTrain.setRightVBus(rightSpeed / 2.0); } else { driveTrain.setLeftVBus(leftSpeed); driveTrain.setRightVBus(rightSpeed); } time.stop(); }
// Called just before this Command runs the first time protected void initialize() { shooter.setLight(false); }
/** Runs intake code */ private void joyIntake() { intake.update(); // System.out.println("hello"); if (robotCore.joy.getButton(JoyConfig.intakeButton) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.pickupBall(); shooter.releaseBall(); } if (robotCore.joy.getButton(JoyConfig.cancelIntakeButton) && !robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.roller.setSpeed(0); } if (robotCore.joy.getRawButton(JoyConfig.armUpButton) && robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.arm.setArmSpeed(-1); } if (robotCore.joy.getRawButton(JoyConfig.armDownButton) && robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.arm.setArmSpeed(1); } if (robotCore.joy.getButton(JoyConfig.armStopButton) && robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.arm.setArmSpeed(0); } if (robotCore.joy.getButton(JoyConfig.rollerInButton) && robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.roller.setSpeed(1); } if (robotCore.joy.getButton(JoyConfig.rollerOutButton) && robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.roller.setSpeed(-1); } if (robotCore.joy.getButton(JoyConfig.rollerStopButton) && robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.roller.setSpeed(0); } if (robotCore.joy.getButton(JoyConfig.rollerIntakeButton) && robotCore.joy.getRawButton(JoyConfig.manualModeButton)) { intake.roller.runIntakeRoller(); } if (robotCore.joy.getButton(JoyConfig.toggleArmPosButton)) { intake.arm.togglePos(); } if (robotCore.joy.getDpadLeft()) { shooter.releaseBall(); } if (robotCore.joy.getDpadRight()) { shooter.clampBall(); } if (robotCore.joy.getButton(9)) { intake.arm.setPos(2); } if (robotCore.joy.getButton(10)) { intake.arm.resetArmEnc(); } }