From: Arunima DIvya Date: Sat, 21 Jan 2017 05:10:31 +0000 (-0800) Subject: Add Intake subsystem, filled in methods for Intake commands X-Git-Url: http://challenge-bot.com/repos/?p=3501%2F2017steamworks;a=commitdiff_plain;h=dab6e7d6950660c8a3f295b6e9c1fe5aff7b07b0 Add Intake subsystem, filled in methods for Intake commands --- diff --git a/src/org/usfirst/frc/team3501/robot/commands/intake/RunContinuous.java b/src/org/usfirst/frc/team3501/robot/commands/intake/RunContinuous.java index 632c543..d6a4bd0 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/intake/RunContinuous.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intake/RunContinuous.java @@ -1,5 +1,7 @@ package org.usfirst.frc.team3501.robot.commands.intake; +import org.usfirst.frc.team3501.robot.subsystems.Intake; + import edu.wpi.first.wpilibj.command.Command; /*** @@ -10,6 +12,8 @@ import edu.wpi.first.wpilibj.command.Command; * */ public class RunContinuous extends Command { + // create setter method for speed, use setSpeed method to do end() by setting + // speed to 0 public RunContinuous() { @@ -18,28 +22,32 @@ public class RunContinuous extends Command { @Override protected boolean isFinished() { // TODO Auto-generated method stub - return false; + return true; } // Called just before this Command runs the first time @Override protected void initialize() { + } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { + } // Called once after isFinished returns true @Override protected void end() { + Intake.intake.setSpeed(0); } // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { + end(); } } diff --git a/src/org/usfirst/frc/team3501/robot/commands/intake/RunIntake.java b/src/org/usfirst/frc/team3501/robot/commands/intake/RunIntake.java index ca74e1c..82bb550 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/intake/RunIntake.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intake/RunIntake.java @@ -1,5 +1,8 @@ package org.usfirst.frc.team3501.robot.commands.intake; +import org.usfirst.frc.team3501.robot.subsystems.Intake; + +import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.command.Command; /** @@ -10,15 +13,16 @@ import edu.wpi.first.wpilibj.command.Command; */ public class RunIntake extends Command { private double timeToMove; + public Timer timer; public RunIntake(double timeToMove) { + timer = new Timer(); this.timeToMove = timeToMove; } @Override protected boolean isFinished() { - // TODO Auto-generated method stub - return false; + return timer.get() >= timeToMove; } // Called just before this Command runs the first time @@ -34,11 +38,13 @@ public class RunIntake extends Command { // Called once after isFinished returns true @Override protected void end() { + Intake.intake.setSpeed(0); } // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { + end(); } } diff --git a/src/org/usfirst/frc/team3501/robot/commands/intake/StopIntake.java b/src/org/usfirst/frc/team3501/robot/commands/intake/StopIntake.java index 6a2cc26..54e8a60 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/intake/StopIntake.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intake/StopIntake.java @@ -1,5 +1,7 @@ package org.usfirst.frc.team3501.robot.commands.intake; +import org.usfirst.frc.team3501.robot.subsystems.Intake; + import edu.wpi.first.wpilibj.command.Command; /** @@ -26,12 +28,14 @@ public class StopIntake extends Command { // Called once after isFinished returns true @Override protected void end() { + Intake.intake.setSpeed(0); } // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { + end(); } @Override diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Intake.java b/src/org/usfirst/frc/team3501/robot/subsystems/Intake.java index 1c891d4..f849203 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Intake.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Intake.java @@ -1,47 +1,36 @@ package org.usfirst.frc.team3501.robot.subsystems; +import com.ctre.CANTalon; + import edu.wpi.first.wpilibj.command.Subsystem; -/*** - * - * +/** * @author Meeta - * */ public class Intake extends Subsystem { - public Intake() { - - } - - /** - * Runs the intake continuously - */ - public void RunContinous() { + public static Intake intake = null; + protected double speed = 0; + private CANTalon intakeWheel; - } - - /** - * Starts running the intake for a specific period of time that the user - * inputs. - * - * @param timeToMove - * in seconds - */ - public void RunIntake(double timeToMove) { + // create speed of intake whee + public Intake() { } - /** - * Stops the intake - */ - public void StopIntake() { - + public static Intake getIntake() { + if (intake == null) { + intake = new Intake(); + } + return intake; } @Override protected void initDefaultCommand() { - // TODO Auto-generated method stub } + public void setSpeed(double speed) { + this.speed = speed; + } + }