From 4ccc80ed94a7192896716ff0477cbb81c398ec8b Mon Sep 17 00:00:00 2001 From: Peter Labadorf Date: Mon, 18 Mar 2019 18:53:51 -0400 Subject: [PATCH 1/2] got stuff done --- .../java/frc/robot/OperatorInterface.java | 3 +- .../frc/robot/commands/LoosenAndDeploy.java | 25 +++++++++ .../frc/robot/commands/LoosenFlipRope.java | 54 +++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/main/java/frc/robot/commands/LoosenAndDeploy.java create mode 100644 src/main/java/frc/robot/commands/LoosenFlipRope.java diff --git a/src/main/java/frc/robot/OperatorInterface.java b/src/main/java/frc/robot/OperatorInterface.java index 5a923dc..4ac2f1c 100644 --- a/src/main/java/frc/robot/OperatorInterface.java +++ b/src/main/java/frc/robot/OperatorInterface.java @@ -25,6 +25,7 @@ import frc.robot.commands.FlipStop; import frc.robot.commands.HatchExtend; import frc.robot.commands.HatchRetract; +import frc.robot.commands.LoosenAndDeploy; import frc.robot.commands.NudgeLeft; import frc.robot.commands.NudgeRight; import frc.robot.commands.SquareUpCommand; @@ -187,7 +188,7 @@ protected void createCommands() { povButtonDown.whenReleased(new CancelSquareUpCommand(this.robot.getDriveSubsystem()) ); // Arms Subsystem - armsDeployButton.whenPressed(new ArmsDeploy(this.robot.getArmsSubsystem())); + armsDeployButton.whenPressed(new LoosenAndDeploy(robot.getFlipSubsystem(), robot.getArmsSubsystem())); armsSqueezeButton.whenPressed(new ArmsSqueeze(this.robot.getArmsSubsystem())); armsReleaseButton.whenPressed(new ArmsRelease(this.robot.getArmsSubsystem())); armsReverseButton.whenPressed(new ReverseDeploy(this.robot.getArmsSubsystem())); diff --git a/src/main/java/frc/robot/commands/LoosenAndDeploy.java b/src/main/java/frc/robot/commands/LoosenAndDeploy.java new file mode 100644 index 0000000..56c1ea5 --- /dev/null +++ b/src/main/java/frc/robot/commands/LoosenAndDeploy.java @@ -0,0 +1,25 @@ +/*----------------------------------------------------------------------------*/ +/* 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; +import edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.commands.LoosenFlipRope; +import frc.robot.commands.ArmsDeploy; +import frc.robot.subsystems.ArmsSubsystem; +import frc.robot.subsystems.FlipSubsystem;; + +public class LoosenAndDeploy extends CommandGroup { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + + + + public LoosenAndDeploy(FlipSubsystem flip, ArmsSubsystem arms) { + addSequential(new LoosenFlipRope(flip)); + addSequential(new ArmsDeploy(arms)); + } +} diff --git a/src/main/java/frc/robot/commands/LoosenFlipRope.java b/src/main/java/frc/robot/commands/LoosenFlipRope.java new file mode 100644 index 0000000..ed69e91 --- /dev/null +++ b/src/main/java/frc/robot/commands/LoosenFlipRope.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 frc.robot.commands; + +import edu.wpi.first.wpilibj.command.Command; +import frc.robot.subsystems.FlipSubsystem;; + +public class LoosenFlipRope extends Command { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + private FlipSubsystem flip; + private static double LOOSEN_SECONDS = 2; + + public LoosenFlipRope(FlipSubsystem flip) { + this.flip=flip; + requires(flip); + setTimeout(LOOSEN_SECONDS); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + flip.backward(); + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + flip.backward(); + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return isTimedOut(); + } + + // 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() { + end(); + } +} From 4b92a4f9c6c245b2c6c20936fc10ea11f39fe6f3 Mon Sep 17 00:00:00 2001 From: Naveen Date: Mon, 18 Mar 2019 19:19:16 -0400 Subject: [PATCH 2/2] fixed bugs and adjusted values --- src/main/java/frc/robot/OperatorInterface.java | 2 +- src/main/java/frc/robot/commands/LoosenFlipRope.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/OperatorInterface.java b/src/main/java/frc/robot/OperatorInterface.java index 4ac2f1c..53c86b6 100644 --- a/src/main/java/frc/robot/OperatorInterface.java +++ b/src/main/java/frc/robot/OperatorInterface.java @@ -192,7 +192,7 @@ protected void createCommands() { armsSqueezeButton.whenPressed(new ArmsSqueeze(this.robot.getArmsSubsystem())); armsReleaseButton.whenPressed(new ArmsRelease(this.robot.getArmsSubsystem())); armsReverseButton.whenPressed(new ReverseDeploy(this.robot.getArmsSubsystem())); - panelArmsDeployButton.whenPressed(new ArmsDeploy(this.robot.getArmsSubsystem())); + panelArmsDeployButton.whenPressed(new LoosenAndDeploy(robot.getFlipSubsystem(), robot.getArmsSubsystem())); panelArmsSqueezeButton.whenPressed(new ArmsSqueeze(this.robot.getArmsSubsystem())); panelArmsReleaseButton.whenPressed(new ArmsRelease(this.robot.getArmsSubsystem())); diff --git a/src/main/java/frc/robot/commands/LoosenFlipRope.java b/src/main/java/frc/robot/commands/LoosenFlipRope.java index ed69e91..b419e67 100644 --- a/src/main/java/frc/robot/commands/LoosenFlipRope.java +++ b/src/main/java/frc/robot/commands/LoosenFlipRope.java @@ -14,7 +14,7 @@ public class LoosenFlipRope extends Command { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); private FlipSubsystem flip; - private static double LOOSEN_SECONDS = 2; + private static double LOOSEN_SECONDS = 3; public LoosenFlipRope(FlipSubsystem flip) { this.flip=flip; @@ -43,6 +43,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { + flip.stop(); } // Called when another command which requires one or more of the same