diff --git a/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/Constants.java b/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/Constants.java index bf8e542..a09e4c1 100644 --- a/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/Constants.java +++ b/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/Constants.java @@ -40,4 +40,7 @@ public class Constants { public static final int kBaseTrajPeriodMs = 0; public static final double kNeutralDeadband = 0.01; + + public static double kIntakeSpeed = 0.4; + public static double kOuttakeSpeed = -0.3; } diff --git a/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java b/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java new file mode 100644 index 0000000..75ac263 --- /dev/null +++ b/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java @@ -0,0 +1,58 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package org.usfirst.frc4079.RobotBuilderProject1.commands; + +import org.usfirst.frc4079.RobotBuilderProject1.Robot; + +import edu.wpi.first.wpilibj.command.Command; + +import org.usfirst.frc4079.RobotBuilderProject1.Constants; + +public class GamepadRunIntake extends Command { + public GamepadRunIntake() { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + requires(Robot.intake); + } + + // 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() { + if (Robot.oi.gamePad.getRightBumper()) { + Robot.intake.run(Constants.kIntakeSpeed); + } else if (Robot.oi.gamePad.getLeftBumper()) { + Robot.intake.run(Constants.kOuttakeSpeed); + } else { + Robot.intake.run(0); + } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.intake.stop(); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + end(); + } +} \ No newline at end of file