X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fsubsystems%2FIntake.java;h=ed47fa702a80446343a32362991cb40fa3e8e41a;hb=ac77a7b890c794f807b764221ff72d9044791fab;hp=1c891d4837c2709b94335327784e0963cf51107b;hpb=0ceab9a4ab7dec9aa01508a922351456f17679c3;p=3501%2F2017steamworks diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Intake.java b/src/org/usfirst/frc/team3501/robot/subsystems/Intake.java index 1c891d4..ed47fa7 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Intake.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Intake.java @@ -1,47 +1,75 @@ package org.usfirst.frc.team3501.robot.subsystems; +import org.usfirst.frc.team3501.robot.Constants; +import org.usfirst.frc.team3501.robot.MathLib; + +import com.ctre.CANTalon; + import edu.wpi.first.wpilibj.command.Subsystem; -/*** - * - * +/** * @author Meeta - * */ public class Intake extends Subsystem { - public Intake() { + private static Intake intake = null; + private CANTalon intakeWheel; + public static final double INTAKE_SPEED = 1; + public static final double REVERSE_SPEED = -1; + public Intake() { + intakeWheel = new CANTalon(Constants.Intake.INTAKE_ROLLER_PORT); } - /** - * Runs the intake continuously + /*** + * It gets the intake instance, and if intake has not been initialized, then + * it will be initialized. + * + * @returns intake */ - public void RunContinous() { + public static Intake getIntake() { + if (intake == null) { + intake = new Intake(); + } + return intake; + } + + @Override + protected void initDefaultCommand() { } - /** - * Starts running the intake for a specific period of time that the user - * inputs. + /*** + * Sets speed of intake wheel to input speed * - * @param timeToMove - * in seconds + * @param speed + * from -1 to 1 */ - public void RunIntake(double timeToMove) { - + private void setSpeed(double speed) { + speed = MathLib.restrictToRange(speed, -1.0, 1.0); + intakeWheel.set(speed); } - /** - * Stops the intake + /*** + * Runs the intake wheel at the set intake speed. */ - public void StopIntake() { - + public void runIntake() { + setSpeed(INTAKE_SPEED); } - @Override - protected void initDefaultCommand() { - // TODO Auto-generated method stub + /*** + * Stops the intake wheel by setting intake wheel's speed to 0. + */ + public void stopIntake() { + setSpeed(0); + } + /*** + * Purpose is to release all balls from the ball container to the outside of + * the robot. Reverses intake wheel by setting wheel speed to reverse speed. + * + */ + public void runReverseIntake() { + setSpeed(REVERSE_SPEED); } }