SHARE
TWEET
Shooter.java
a guest
Feb 16th, 2013
5
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- package org.homestead.robotics.robot;
- import edu.wpi.first.wpilibj.DriverStation;
- import edu.wpi.first.wpilibj.Jaguar;
- import edu.wpi.first.wpilibj.Relay;
- /**
- *
- * @author Driver
- */
- public class Shooter
- {
- private static final double SHOOTER_SPEED = 1.0;
- private static final double OPTIMAL_VOLTAGE = 12;
- private static final double THROTTLE_STEP = 0.1;
- private static final double DEFAULT_THROTTLE = 1;
- private Jaguar shooterMotor1;
- private Jaguar shooterMotor2;
- private Relay pneuRelay;
- private double throttle = 1;
- public Shooter()
- {
- shooterMotor1 = new Jaguar(6);
- shooterMotor2 = new Jaguar(7);
- pneuRelay = new Relay(2);
- }
- public void shoot()
- {
- setMotorSpeed(throttle * SHOOTER_SPEED);
- }
- public void stopShooter()
- {
- setMotorSpeed(0);
- }
- public void setMotorSpeed(double speed)
- {
- shooterMotor1.set(speed);
- shooterMotor2.set(speed);
- }
- public void throttleDown()
- {
- throttle = Math.max(throttle - THROTTLE_STEP, 0);
- }
- public void throttleUp()
- {
- throttle += THROTTLE_STEP;
- }
- public double getThrottle()
- {
- return throttle;
- }
- public void voltageCompensation()
- {
- throttle = DEFAULT_THROTTLE * OPTIMAL_VOLTAGE / DriverStation.getInstance().getBatteryVoltage();
- }
- public void setForward()
- {
- pneuRelay.set(Relay.Value.kForward);
- }
- public void setOff()
- {
- pneuRelay.set(Relay.Value.kOff);
- }
- public void setReverse()
- {
- pneuRelay.set(Relay.Value.kReverse);
- }
- }
RAW Paste Data
