From c5bc7f7f706b2c68b7e1185a115179b35283ca6e Mon Sep 17 00:00:00 2001 From: Curtis Fowler Date: Sat, 2 Mar 2019 01:41:05 -0500 Subject: [PATCH] unstaged changes + pit mayhem --- build.gradle | 2 +- src/main/java/frc/robot/OI.java | 4 +- src/main/java/frc/robot/Robot.java | 3 -- .../frc/robot/commands/AutoDriveToTarget.java | 3 -- .../java/frc/robot/commands/ClimberDrive.java | 8 ++-- .../java/frc/robot/commands/CommandBase.java | 3 -- .../java/frc/robot/commands/MoveTo47.java | 3 +- ...iftToHeight.java => MoveToHighRocket.java} | 22 +++++---- .../robot/commands/RunVacuumBackwards.java | 46 ------------------ .../frc/robot/commands/RunVacuumForward.java | 48 ------------------- .../java/frc/robot/commands/VacuumDrive.java | 43 ----------------- .../java/frc/robot/subsystems/Climber.java | 2 + .../java/frc/robot/subsystems/Vacuum.java | 41 ---------------- 13 files changed, 24 insertions(+), 204 deletions(-) rename src/main/java/frc/robot/commands/{LiftToHeight.java => MoveToHighRocket.java} (65%) delete mode 100644 src/main/java/frc/robot/commands/RunVacuumBackwards.java delete mode 100644 src/main/java/frc/robot/commands/RunVacuumForward.java delete mode 100644 src/main/java/frc/robot/commands/VacuumDrive.java delete mode 100644 src/main/java/frc/robot/subsystems/Vacuum.java diff --git a/build.gradle b/build.gradle index 48cb272..5d0d2da 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2019.3.2" + id "edu.wpi.first.GradleRIO" version "2019.4.1" } def ROBOT_MAIN_CLASS = "frc.robot.Main" diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index c094f0a..de0c883 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -27,9 +27,9 @@ public static void init() { auxStick = new Joystick(RobotMap.auxillaryStick); Button moveArmToPos = new JoystickButton(leftDriveStick, 9); - Button movePivotDown = new JoystickButton(auxStick, 4); - Button movePivotUp = new JoystickButton(auxStick, 5); + Button moveArmToHighestRocket = new JoystickButton(leftDriveStick, 8); + moveArmToHighestRocket.whileHeld(new MoveToHighRocket()); moveArmToPos.whileHeld(new MoveTo47()); } diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 0e75a62..3de42e9 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -105,9 +105,6 @@ public void teleopInit() { // teleop starts running. If you want the autonomous to // continue until interrupted by another command, remove // this line or comment it out. - if (m_autonomousCommand != null) { - m_autonomousCommand.cancel(); - } //CommandBase.grabber.toggle(); } diff --git a/src/main/java/frc/robot/commands/AutoDriveToTarget.java b/src/main/java/frc/robot/commands/AutoDriveToTarget.java index 74c57db..9446716 100644 --- a/src/main/java/frc/robot/commands/AutoDriveToTarget.java +++ b/src/main/java/frc/robot/commands/AutoDriveToTarget.java @@ -18,12 +18,9 @@ public class AutoDriveToTarget extends CommandBase { public AutoDriveToTarget() { super("AutoDrive"); - System.out.println("wew"); - // Use requires() here to declare subsystem dependencies requires(driveTrain); requires(vision); requires(climber); - System.out.println("lad"); limelight = NetworkTableInstance.getDefault().getTable("limelight"); } diff --git a/src/main/java/frc/robot/commands/ClimberDrive.java b/src/main/java/frc/robot/commands/ClimberDrive.java index 4672e8a..f1ffd79 100644 --- a/src/main/java/frc/robot/commands/ClimberDrive.java +++ b/src/main/java/frc/robot/commands/ClimberDrive.java @@ -45,12 +45,12 @@ protected void execute() { System.out.println("Toggle grabber"); } - if (rightStick.getRawButtonPressed(9)) { - climber.driveBack(0.5); + if (auxJoystick.getRawButtonPressed(4)) { + climber.driveBack(0.25); } - if (auxJoystick.getRawButtonPressed(2)) { - climber.driveBack(1); + if (auxJoystick.getRawButtonPressed(5)) { + climber.driveBack(-0.25); } if (Math.abs(auxJoystick.getY()) <= 0.05) // Arm is disabled, just drives the climb motors here diff --git a/src/main/java/frc/robot/commands/CommandBase.java b/src/main/java/frc/robot/commands/CommandBase.java index eb159a9..eab8a92 100644 --- a/src/main/java/frc/robot/commands/CommandBase.java +++ b/src/main/java/frc/robot/commands/CommandBase.java @@ -11,7 +11,6 @@ import frc.robot.subsystems.Climber; import frc.robot.subsystems.DriveTrain; import frc.robot.subsystems.Grabber; -import frc.robot.subsystems.Vacuum; import frc.robot.subsystems.Vision; import frc.robot.OI; @@ -23,7 +22,6 @@ public class CommandBase extends Command { public static Vision vision; public static Climber climber; public static Grabber grabber; - public static Vacuum vacuum; // Init all subsystems public static void init() { @@ -33,7 +31,6 @@ public static void init() { driveTrain = new DriveTrain(); vision = new Vision(); grabber = new Grabber(); - vacuum = new Vacuum(); OI.init(); } diff --git a/src/main/java/frc/robot/commands/MoveTo47.java b/src/main/java/frc/robot/commands/MoveTo47.java index 99572a0..4585209 100644 --- a/src/main/java/frc/robot/commands/MoveTo47.java +++ b/src/main/java/frc/robot/commands/MoveTo47.java @@ -16,8 +16,6 @@ public class MoveTo47 extends CommandBase { public MoveTo47() { super("MoveTo47Inches"); requires(climber); - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); } // Called just before this Command runs the first time @@ -40,6 +38,7 @@ public boolean isFinished() { // Do not worry about this method. It will be inte // Called once after isFinished returns true @Override protected void end() { + climber.driveArm(0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/LiftToHeight.java b/src/main/java/frc/robot/commands/MoveToHighRocket.java similarity index 65% rename from src/main/java/frc/robot/commands/LiftToHeight.java rename to src/main/java/frc/robot/commands/MoveToHighRocket.java index 10a1731..6b910fe 100644 --- a/src/main/java/frc/robot/commands/LiftToHeight.java +++ b/src/main/java/frc/robot/commands/MoveToHighRocket.java @@ -7,38 +7,44 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj.command.Command; +import frc.robot.RobotMap; -public class LiftToHeight extends Command { - public LiftToHeight() { - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); +public class MoveToHighRocket extends CommandBase { + + boolean upThere = false; + + public MoveToHighRocket() { + super("MoveToHighRocket"); + requires(climber); } // Called just before this Command runs the first time @Override protected void initialize() { + System.out.println("Move to high rocket started"); + climber.setArmPos(-15); } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { + System.out.println("high rocket pid exec"); } - // Make this return true when this Command no longer needs to run execute() - @Override - protected boolean isFinished() { + public boolean isFinished() { // Do not worry about this method. It will be interrupted when the button is released (2) return false; } // Called once after isFinished returns true @Override protected void end() { + climber.driveArm(0); } // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { + System.out.println("Move to high rocket interrupted"); } } diff --git a/src/main/java/frc/robot/commands/RunVacuumBackwards.java b/src/main/java/frc/robot/commands/RunVacuumBackwards.java deleted file mode 100644 index 886bdc9..0000000 --- a/src/main/java/frc/robot/commands/RunVacuumBackwards.java +++ /dev/null @@ -1,46 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* 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 frc.robot.commands; - -public class RunVacuumBackwards extends CommandBase { - public RunVacuumBackwards() { - super("drivevacuumbackwards"); - // Use requires() here to declare subsystem dependencies - requires(vacuum); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - System.out.println("Starting to backdrive vacuum motor..."); - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - System.out.println("Backdriving vacuum"); - vacuum.setBackwards(); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - public boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - } - - @Override - protected void interrupted() { // Called when the button specified in the OI is released - System.out.println("Done backdriving the vacuum motor..."); - vacuum.setValue(0); - } -} diff --git a/src/main/java/frc/robot/commands/RunVacuumForward.java b/src/main/java/frc/robot/commands/RunVacuumForward.java deleted file mode 100644 index 476e2bc..0000000 --- a/src/main/java/frc/robot/commands/RunVacuumForward.java +++ /dev/null @@ -1,48 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* 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 frc.robot.commands; - -public class RunVacuumForward extends CommandBase { - public RunVacuumForward() { - super("drivevacuumcommand"); - // Use requires() here to declare subsystem dependencies - requires(vacuum); - } - - // Called just before this Command runs the first time - @Override - protected void initialize() { - System.out.println("Driving the vacuum motor to create suction..."); - } - - // Called repeatedly when this Command is scheduled to run - @Override - protected void execute() { - System.out.println("Suction in progress"); - vacuum.setForward(); - } - - // Make this return true when this Command no longer needs to run execute() - @Override - public boolean isFinished() { - return false; - } - - // Called once after isFinished returns true - @Override - protected void end() { - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - System.out.println("Done driving the vacuum motor forwards..."); - vacuum.setValue(0); - } -} diff --git a/src/main/java/frc/robot/commands/VacuumDrive.java b/src/main/java/frc/robot/commands/VacuumDrive.java deleted file mode 100644 index 6da4407..0000000 --- a/src/main/java/frc/robot/commands/VacuumDrive.java +++ /dev/null @@ -1,43 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* 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 frc.robot.commands; - -public class VacuumDrive extends CommandBase { // This is a dummy file - public VacuumDrive() { - super("dummyvacuumdrive"); - // Use requires() here to declare subsystem dependencies - requires(vacuum); - } - - // 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() { - } - - // Make this return true when this Command no longer needs to run execute() - @Override - public boolean isFinished() { - return true; - } - - // Called once after isFinished returns true - @Override - protected void end() { - } - - // Called when another command which requires one or more of the same - // subsystems is scheduled to run - @Override - protected void interrupted() { - } -} diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java index 09e7705..08baaeb 100644 --- a/src/main/java/frc/robot/subsystems/Climber.java +++ b/src/main/java/frc/robot/subsystems/Climber.java @@ -45,6 +45,8 @@ public Climber() { arm = new CANSparkMax(5, MotorType.kBrushless); armEncoder = new CANEncoder(arm); armPID = new CANPIDController(arm); + armEncoder.getVelocity(); + armEncoder.getPosition(); backDriveRight.setInverted(true); diff --git a/src/main/java/frc/robot/subsystems/Vacuum.java b/src/main/java/frc/robot/subsystems/Vacuum.java deleted file mode 100644 index 0384de1..0000000 --- a/src/main/java/frc/robot/subsystems/Vacuum.java +++ /dev/null @@ -1,41 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* 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 frc.robot.subsystems; - -import edu.wpi.first.wpilibj.PWMVictorSPX; -import edu.wpi.first.wpilibj.command.Subsystem; -import frc.robot.commands.VacuumDrive; - -/** - * Add your docs here. - */ -public class Vacuum extends Subsystem { - - PWMVictorSPX vacuum; - - public Vacuum() { - vacuum = new PWMVictorSPX(0); - } - - public void setForward() { - vacuum.set(1); - } - - public void setBackwards() { - vacuum.set(-1); - } - - public void setValue(double val) { - vacuum.set(val); - } - - @Override - public void initDefaultCommand() { - setDefaultCommand(new VacuumDrive()); - } -}