From 5841085c4b9105a404c79752051671b7a4cdec48 Mon Sep 17 00:00:00 2001 From: Arvind Vivekanandan Date: Mon, 31 Dec 2018 16:25:15 -0800 Subject: [PATCH 1/3] GamepadRunIntake This GamepadRunIntake command operates the intake mechanism by checking the status of the right bumper and left bumper of the gamepad and intakes and outakes a cube respectively. --- .../commands/GamepadRunIntake.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java 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..9b6b481 --- /dev/null +++ b/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java @@ -0,0 +1,54 @@ +/*----------------------------------------------------------------------------*/ +/* 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; + +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(0.4); + } else if(Robot.oi.gamePad.getLeftBumper()) { + Robot.intake.run(-0.3); + } + } + + // 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 From 3cb583b31b26709a24542f2901e037ccaf733bf4 Mon Sep 17 00:00:00 2001 From: Arvind Vivekanandan Date: Wed, 2 Jan 2019 17:49:31 -0800 Subject: [PATCH 2/3] Update GamepadRunIntake.java --- .../RobotBuilderProject1/commands/GamepadRunIntake.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java b/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java index 9b6b481..29556f5 100644 --- a/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java +++ b/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java @@ -30,7 +30,9 @@ protected void execute() { Robot.intake.run(0.4); } else if(Robot.oi.gamePad.getLeftBumper()) { Robot.intake.run(-0.3); - } + } else { + Robot.intake.run(0); + } } // Make this return true when this Command no longer needs to run execute() From 364151c860eddf07edfc2cfe327574a2e07ea154 Mon Sep 17 00:00:00 2001 From: Arvind Vivekanandan Date: Fri, 4 Jan 2019 18:14:30 -0800 Subject: [PATCH 3/3] Constants and Formatting Added changes regarding constants and formatting. --- .../frc4079/RobotBuilderProject1/Constants.java | 3 +++ .../commands/GamepadRunIntake.java | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) 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 index 29556f5..75ac263 100644 --- a/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java +++ b/src/main/java/org/usfirst/frc4079/RobotBuilderProject1/commands/GamepadRunIntake.java @@ -11,6 +11,8 @@ 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 @@ -26,13 +28,13 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if(Robot.oi.gamePad.getRightBumper()) { - Robot.intake.run(0.4); - } else if(Robot.oi.gamePad.getLeftBumper()) { - Robot.intake.run(-0.3); + 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() @@ -51,6 +53,6 @@ protected void end() { // subsystems is scheduled to run @Override protected void interrupted() { - end(); + end(); } } \ No newline at end of file