From bd2b9f8834b6f232fcc9151996c240ce64ab6b15 Mon Sep 17 00:00:00 2001 From: Imeanbusiness Date: Mon, 5 Feb 2024 21:44:45 -0800 Subject: [PATCH 1/4] Chained some commands Chained some commands --- .../java/frc/autocommands/FeedAmpScore.java | 34 +++++++++++++++++++ .../java/frc/autocommands/ShootNoteFeed.java | 29 ++++++++++++++++ src/main/java/frc/robot/RobotContainer.java | 3 ++ 3 files changed, 66 insertions(+) create mode 100644 src/main/java/frc/autocommands/FeedAmpScore.java create mode 100644 src/main/java/frc/autocommands/ShootNoteFeed.java diff --git a/src/main/java/frc/autocommands/FeedAmpScore.java b/src/main/java/frc/autocommands/FeedAmpScore.java new file mode 100644 index 0000000..2ed7600 --- /dev/null +++ b/src/main/java/frc/autocommands/FeedAmpScore.java @@ -0,0 +1,34 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.autocommands; + +import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; +import frc.robot.elevator.Elevator; +import frc.robot.elevator.commands.ElevatorDown; +import frc.robot.elevator.commands.ElevatorUp; +import frc.robot.intake.Intake; +import frc.robot.intake.commands.IntakeAmpScore; + +// NOTE: Consider using this command inline, rather than writing a subclass. For more +// information, see: +// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html +public class FeedAmpScore extends SequentialCommandGroup { + /** Creates a new FeedAmpScore. */ + public FeedAmpScore(Elevator elevator, Intake intake) { + // Add your commands in the addCommands() call, e.g. + // addCommands(new FooCommand(), new BarCommand()); + addCommands( + + new ElevatorUp(elevator), + + new IntakeAmpScore(intake), + + new ElevatorDown(elevator) + + + + ); + } +} diff --git a/src/main/java/frc/autocommands/ShootNoteFeed.java b/src/main/java/frc/autocommands/ShootNoteFeed.java new file mode 100644 index 0000000..6a55e01 --- /dev/null +++ b/src/main/java/frc/autocommands/ShootNoteFeed.java @@ -0,0 +1,29 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.autocommands; + +import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; +import frc.robot.intake.Intake; + +import frc.robot.intake.commands.IntakeShooterFeed; +import frc.robot.shooter.Shooter; +import frc.robot.shooter.commands.ActivateShooter; + +// NOTE: Consider using this command inline, rather than writing a subclass. For more +// information, see: +// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html +public class ShootNoteFeed extends ParallelCommandGroup { + /** Creates a new ShootNoteFeed. */ + public ShootNoteFeed(Shooter shooter, Intake intake) { + // Add your commands in the addCommands() call, e.g. + // addCommands(new FooCommand(), new BarCommand()); + addCommands( + new ActivateShooter(shooter), + + new IntakeShooterFeed(intake) + + ); + } +} diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 10f49b4..59f2419 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -41,6 +41,9 @@ public RobotContainer() { autoSelector.addOption("Right Auto", new PathPlannerAuto("Right Auto")); autoSelector.setDefaultOption("Middle Auto", new PathPlannerAuto("Middle Auto")); + NamedCommands.registerCommand("Amp Score", FeedAmpScore); + NamedCommands.registerCommand("Shoot Note", ShootNoteFeed) + Shuffleboard.getTab("auto").add(autoSelector); swerveDrive.setDefaultCommand( From 25e0ba6f872b90d30f61dad326da2ee64873b003 Mon Sep 17 00:00:00 2001 From: Imeanbusiness Date: Mon, 5 Feb 2024 22:20:52 -0800 Subject: [PATCH 2/4] Fixed up some errors, move autocommands Fixed some errors and moved autocommands folder into robot. --- src/main/java/frc/robot/RobotContainer.java | 15 +++++++++++++-- src/main/java/frc/robot/ShootNotefeed.java | 5 +++++ .../{ => robot}/autocommands/FeedAmpScore.java | 0 .../{ => robot}/autocommands/ShootNoteFeed.java | 0 .../{ShooterCommand.java => ActivateShooter.java} | 4 ++-- 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/main/java/frc/robot/ShootNotefeed.java rename src/main/java/frc/{ => robot}/autocommands/FeedAmpScore.java (100%) rename src/main/java/frc/{ => robot}/autocommands/ShootNoteFeed.java (100%) rename src/main/java/frc/robot/shooter/commands/{ShooterCommand.java => ActivateShooter.java} (85%) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 59f2419..d408874 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -1,10 +1,13 @@ package frc.robot; +import com.pathplanner.lib.auto.NamedCommands; import com.pathplanner.lib.commands.PathPlannerAuto; import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import frc.lib.zylve.Controller; +import frc.robot.autocommands.FeedAmpScore; +import frc.robot.autocommands.ShootNoteFeed; import frc.robot.constants.OperatorConstants; import frc.robot.elevator.Elevator; import frc.robot.intake.Intake; @@ -16,6 +19,9 @@ import frc.robot.swerve.commands.SnapRotation; public class RobotContainer { + + + private final SwerveDrive swerveDrive = new SwerveDrive(); private final SnapRotation snap90 = new SnapRotation(90, swerveDrive); private final FlipRotation flip180 = new FlipRotation(swerveDrive); @@ -23,12 +29,17 @@ public class RobotContainer { @SuppressWarnings("unused") private final Elevator elevator = new Elevator(); + @SuppressWarnings("unused") private final Intake intake = new Intake(); @SuppressWarnings("unused") private final Shooter shooter = new Shooter(); + private final FeedAmpScore AmpScore = new FeedAmpScore(elevator, intake); + private final ShootNoteFeed shootnotefeed = new ShootNoteFeed(shooter, intake); + + Controller controller = new Controller(OperatorConstants.CONTROLLER_PORT); SendableChooser autoSelector = new SendableChooser<>(); @@ -41,8 +52,8 @@ public RobotContainer() { autoSelector.addOption("Right Auto", new PathPlannerAuto("Right Auto")); autoSelector.setDefaultOption("Middle Auto", new PathPlannerAuto("Middle Auto")); - NamedCommands.registerCommand("Amp Score", FeedAmpScore); - NamedCommands.registerCommand("Shoot Note", ShootNoteFeed) + NamedCommands.registerCommand("Amp Score", AmpScore); + NamedCommands.registerCommand("Shoot Note", shootnotefeed); Shuffleboard.getTab("auto").add(autoSelector); diff --git a/src/main/java/frc/robot/ShootNotefeed.java b/src/main/java/frc/robot/ShootNotefeed.java new file mode 100644 index 0000000..c278a15 --- /dev/null +++ b/src/main/java/frc/robot/ShootNotefeed.java @@ -0,0 +1,5 @@ +package frc.robot; + +public class ShootNotefeed { + +} diff --git a/src/main/java/frc/autocommands/FeedAmpScore.java b/src/main/java/frc/robot/autocommands/FeedAmpScore.java similarity index 100% rename from src/main/java/frc/autocommands/FeedAmpScore.java rename to src/main/java/frc/robot/autocommands/FeedAmpScore.java diff --git a/src/main/java/frc/autocommands/ShootNoteFeed.java b/src/main/java/frc/robot/autocommands/ShootNoteFeed.java similarity index 100% rename from src/main/java/frc/autocommands/ShootNoteFeed.java rename to src/main/java/frc/robot/autocommands/ShootNoteFeed.java diff --git a/src/main/java/frc/robot/shooter/commands/ShooterCommand.java b/src/main/java/frc/robot/shooter/commands/ActivateShooter.java similarity index 85% rename from src/main/java/frc/robot/shooter/commands/ShooterCommand.java rename to src/main/java/frc/robot/shooter/commands/ActivateShooter.java index b31b600..fa62f31 100644 --- a/src/main/java/frc/robot/shooter/commands/ShooterCommand.java +++ b/src/main/java/frc/robot/shooter/commands/ActivateShooter.java @@ -5,11 +5,11 @@ import frc.robot.constants.ShooterConstants; import frc.robot.shooter.Shooter; -public class ShooterCommand extends Command { //similar to making your own scratch block +public class ActivateShooter extends Command { //similar to making your own scratch block private final Shooter shooterSubsystem; //declares and makes the "shooterSubsystem" variable with the class (items) of "Shooter" - public ShooterCommand(Shooter shooter) { //makes it so we can shoot multiple motors + public ActivateShooter(Shooter shooter) { //makes it so we can shoot multiple motors shooterSubsystem = shooter; //sets id for this certain command addRequirements(shooterSubsystem); //makes it so that you cant have two commands using the same shooters } From 5331e175bbe6e5419bfdccae446b24b9837a8955 Mon Sep 17 00:00:00 2001 From: Imeanbusiness Date: Mon, 5 Feb 2024 22:27:10 -0800 Subject: [PATCH 3/4] Deleted file Deleted useless file that was made by accident --- src/main/java/frc/robot/RobotContainer.java | 1 + src/main/java/frc/robot/ShootNotefeed.java | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 src/main/java/frc/robot/ShootNotefeed.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index d408874..09a34ec 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -54,6 +54,7 @@ public RobotContainer() { NamedCommands.registerCommand("Amp Score", AmpScore); NamedCommands.registerCommand("Shoot Note", shootnotefeed); + Shuffleboard.getTab("auto").add(autoSelector); diff --git a/src/main/java/frc/robot/ShootNotefeed.java b/src/main/java/frc/robot/ShootNotefeed.java deleted file mode 100644 index c278a15..0000000 --- a/src/main/java/frc/robot/ShootNotefeed.java +++ /dev/null @@ -1,5 +0,0 @@ -package frc.robot; - -public class ShootNotefeed { - -} From 9ad6276785cc93a24a36052d66200b0340f6cc56 Mon Sep 17 00:00:00 2001 From: Imeanbusiness Date: Tue, 6 Feb 2024 17:32:18 -0800 Subject: [PATCH 4/4] Did some renaming, added delay to IntakeShooterFeed. --- src/main/java/frc/robot/RobotContainer.java | 8 ++++---- .../autocommands/{FeedAmpScore.java => AmpScore.java} | 4 ++-- .../autocommands/{ShootNoteFeed.java => ShootNote.java} | 4 ++-- src/main/java/frc/robot/constants/IntakeConstants.java | 1 + .../java/frc/robot/intake/commands/IntakeShooterFeed.java | 1 + 5 files changed, 10 insertions(+), 8 deletions(-) rename src/main/java/frc/robot/autocommands/{FeedAmpScore.java => AmpScore.java} (89%) rename src/main/java/frc/robot/autocommands/{ShootNoteFeed.java => ShootNote.java} (88%) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 09a34ec..63d7e1b 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -6,8 +6,8 @@ import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import frc.lib.zylve.Controller; -import frc.robot.autocommands.FeedAmpScore; -import frc.robot.autocommands.ShootNoteFeed; +import frc.robot.autocommands.AmpScore; +import frc.robot.autocommands.ShootNote; import frc.robot.constants.OperatorConstants; import frc.robot.elevator.Elevator; import frc.robot.intake.Intake; @@ -36,8 +36,8 @@ public class RobotContainer { @SuppressWarnings("unused") private final Shooter shooter = new Shooter(); - private final FeedAmpScore AmpScore = new FeedAmpScore(elevator, intake); - private final ShootNoteFeed shootnotefeed = new ShootNoteFeed(shooter, intake); + private final AmpScore AmpScore = new AmpScore(elevator, intake); + private final ShootNote shootnotefeed = new ShootNote(shooter, intake); Controller controller = new Controller(OperatorConstants.CONTROLLER_PORT); diff --git a/src/main/java/frc/robot/autocommands/FeedAmpScore.java b/src/main/java/frc/robot/autocommands/AmpScore.java similarity index 89% rename from src/main/java/frc/robot/autocommands/FeedAmpScore.java rename to src/main/java/frc/robot/autocommands/AmpScore.java index 2ed7600..3cdf682 100644 --- a/src/main/java/frc/robot/autocommands/FeedAmpScore.java +++ b/src/main/java/frc/robot/autocommands/AmpScore.java @@ -14,9 +14,9 @@ // NOTE: Consider using this command inline, rather than writing a subclass. For more // information, see: // https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html -public class FeedAmpScore extends SequentialCommandGroup { +public class AmpScore extends SequentialCommandGroup { /** Creates a new FeedAmpScore. */ - public FeedAmpScore(Elevator elevator, Intake intake) { + public AmpScore(Elevator elevator, Intake intake) { // Add your commands in the addCommands() call, e.g. // addCommands(new FooCommand(), new BarCommand()); addCommands( diff --git a/src/main/java/frc/robot/autocommands/ShootNoteFeed.java b/src/main/java/frc/robot/autocommands/ShootNote.java similarity index 88% rename from src/main/java/frc/robot/autocommands/ShootNoteFeed.java rename to src/main/java/frc/robot/autocommands/ShootNote.java index 6a55e01..44bf46c 100644 --- a/src/main/java/frc/robot/autocommands/ShootNoteFeed.java +++ b/src/main/java/frc/robot/autocommands/ShootNote.java @@ -14,9 +14,9 @@ // NOTE: Consider using this command inline, rather than writing a subclass. For more // information, see: // https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html -public class ShootNoteFeed extends ParallelCommandGroup { +public class ShootNote extends ParallelCommandGroup { /** Creates a new ShootNoteFeed. */ - public ShootNoteFeed(Shooter shooter, Intake intake) { + public ShootNote(Shooter shooter, Intake intake) { // Add your commands in the addCommands() call, e.g. // addCommands(new FooCommand(), new BarCommand()); addCommands( diff --git a/src/main/java/frc/robot/constants/IntakeConstants.java b/src/main/java/frc/robot/constants/IntakeConstants.java index 34bd340..1e680f4 100644 --- a/src/main/java/frc/robot/constants/IntakeConstants.java +++ b/src/main/java/frc/robot/constants/IntakeConstants.java @@ -13,6 +13,7 @@ public class IntakeConstants { public static final double SHOOTER_SPEED = 1; public static final double SHOOTER_FEED_DURATION = 0.25; + public static final double SHOOTER_FEED_DELAY = 2; public static final double P = 0.1; } diff --git a/src/main/java/frc/robot/intake/commands/IntakeShooterFeed.java b/src/main/java/frc/robot/intake/commands/IntakeShooterFeed.java index 6ad98c4..782de1f 100644 --- a/src/main/java/frc/robot/intake/commands/IntakeShooterFeed.java +++ b/src/main/java/frc/robot/intake/commands/IntakeShooterFeed.java @@ -16,6 +16,7 @@ public IntakeShooterFeed(Intake intake) { @Override public void initialize() { + Timer.delay(IntakeConstants.SHOOTER_FEED_DELAY); startTime = Timer.getFPGATimestamp(); intake.run(IntakeConstants.SHOOTER_SPEED); }