From 6cab957e6b9f4c558fad24def50385c0e57f1bb8 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:13:38 -0600 Subject: [PATCH 01/24] Added Intake.java --- src/main/java/frc/robot/subsystems/Intake.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/Intake.java diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java new file mode 100644 index 00000000..1a90fcc3 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -0,0 +1,17 @@ +// 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.subsystems; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Intake extends SubsystemBase { + /** Creates a new Intake. */ + public Intake() {} + + @Override + public void periodic() { + // This method will be called once per scheduler run + } +} From d0f8315a49268712b1419d5689d38a67627cb860 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:10:17 -0600 Subject: [PATCH 02/24] Added intake motor object --- src/main/java/frc/robot/subsystems/Intake.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index 1a90fcc3..a96b7c6a 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -5,10 +5,16 @@ package frc.robot.subsystems; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import edu.wpi.first.wpilibj.motorcontrol.Spark; public class Intake extends SubsystemBase { + + private Spark intake; + /** Creates a new Intake. */ - public Intake() {} + public Intake() { + + } @Override public void periodic() { From aa5e4189ddca8f038bbae1d7585006c8ba9b118f Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:18:47 -0600 Subject: [PATCH 03/24] Added intake motor id constant Added INTAKE_MOTOR_ID with a temp value of 0. --- src/main/java/frc/robot/Constants.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 2337681c..d00bb93b 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -23,4 +23,8 @@ public final class Constants { public static class Controllers { public static final int DRIVER_CONTROLLER_PORT = 0; } + + public static class Intake { + public static final int INTAKE_MOTOR_ID = 0; + } } From 2db315e6047b8be59af9a22ae0a672ba9a1bd7cf Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:21:23 -0600 Subject: [PATCH 04/24] Assigned intake object motor id Assigned intake object motor id from constants --- src/main/java/frc/robot/subsystems/Intake.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index a96b7c6a..7b1caba1 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -6,6 +6,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj.motorcontrol.Spark; +import frc.robot.Constants; public class Intake extends SubsystemBase { @@ -13,7 +14,7 @@ public class Intake extends SubsystemBase { /** Creates a new Intake. */ public Intake() { - + this.intake = new Spark(Constants.Intake.INTAKE_MOTOR_ID); } @Override From 88698a04bf0d3674649befeb16e4144012744fb6 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:22:26 -0600 Subject: [PATCH 05/24] Added intake motor speed constant Added INTAKE_MOTOR_SPEED with a temp value of 0.5 --- src/main/java/frc/robot/Constants.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index d00bb93b..1effbd94 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -26,5 +26,6 @@ public static class Controllers { public static class Intake { public static final int INTAKE_MOTOR_ID = 0; + public static final double INTAKE_MOTOR_SPEED = 0.5; } } From c8dd94a544380e442616469ddac522d9c38444a6 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:25:19 -0600 Subject: [PATCH 06/24] Added method to run intake Added RunIntake() method and its contents run the motor --- src/main/java/frc/robot/subsystems/Intake.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index 7b1caba1..c6cdf9c5 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -17,6 +17,10 @@ public Intake() { this.intake = new Spark(Constants.Intake.INTAKE_MOTOR_ID); } + public void RunIntake() { + intake.set(Constants.Intake.INTAKE_MOTOR_SPEED); + } + @Override public void periodic() { // This method will be called once per scheduler run From 9042d15267399fba7c47e3cfb93dfacc4bcd2eae Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:27:14 -0600 Subject: [PATCH 07/24] Added intake stop method --- src/main/java/frc/robot/subsystems/Intake.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index c6cdf9c5..1bdd51da 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -17,10 +17,14 @@ public Intake() { this.intake = new Spark(Constants.Intake.INTAKE_MOTOR_ID); } - public void RunIntake() { + public void runIntake() { intake.set(Constants.Intake.INTAKE_MOTOR_SPEED); } + public void stop() { + intake.set(0); + } + @Override public void periodic() { // This method will be called once per scheduler run From 6e197856f3189131228814bb50bf4a0b54a226ad Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:28:42 -0600 Subject: [PATCH 08/24] Added javadoc --- src/main/java/frc/robot/Constants.java | 2 ++ src/main/java/frc/robot/subsystems/Intake.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 1effbd94..e8acc84b 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -25,7 +25,9 @@ public static class Controllers { } public static class Intake { + /** Motor id of the Intake motor. */ public static final int INTAKE_MOTOR_ID = 0; + /** Speed we want to run the Intake at. */ public static final double INTAKE_MOTOR_SPEED = 0.5; } } diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index 1bdd51da..1fdabf36 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -8,6 +8,9 @@ import edu.wpi.first.wpilibj.motorcontrol.Spark; import frc.robot.Constants; +/** + * The intake of the robot. + */ public class Intake extends SubsystemBase { private Spark intake; @@ -17,10 +20,12 @@ public Intake() { this.intake = new Spark(Constants.Intake.INTAKE_MOTOR_ID); } + /** Runs the intake motors. */ public void runIntake() { intake.set(Constants.Intake.INTAKE_MOTOR_SPEED); } + /** Stops the intake motors. */ public void stop() { intake.set(0); } From 7ce11ec35949ccb57e393c4c8d65e5406946b852 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:30:32 -0600 Subject: [PATCH 09/24] Added RunIntake command --- .../java/frc/robot/commands/RunIntake.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/frc/robot/commands/RunIntake.java diff --git a/src/main/java/frc/robot/commands/RunIntake.java b/src/main/java/frc/robot/commands/RunIntake.java new file mode 100644 index 00000000..7263290c --- /dev/null +++ b/src/main/java/frc/robot/commands/RunIntake.java @@ -0,0 +1,33 @@ +// 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.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Intake; + +public class RunIntake extends Command { + /** Creates a new RunIntake. */ + public RunIntake() { + // Use addRequirements() here to declare subsystem dependencies. + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() {} + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) {} + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} From 74ae6de95b6dfb5514a009805b86e2309cd0274e Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:33:06 -0600 Subject: [PATCH 10/24] Added Intake to RobotContainer --- src/main/java/frc/robot/RobotContainer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index a8c689dc..aecb3159 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -19,6 +19,7 @@ import frc.robot.commands.DriveRobotOriented; import frc.robot.commands.EnterXMode; import frc.robot.subsystems.Drive; +import frc.robot.subsystems.Intake; public class RobotContainer { @@ -33,6 +34,7 @@ public class RobotContainer { * awful. */ public static Drive drive = new Drive(); + public static Intake intake = new Intake(); /* * ************ From dab2a864a48dfea65162f84b51e5f6b29c450970 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:34:20 -0600 Subject: [PATCH 11/24] Defined intake object --- src/main/java/frc/robot/commands/RunIntake.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/commands/RunIntake.java b/src/main/java/frc/robot/commands/RunIntake.java index 7263290c..aae8927b 100644 --- a/src/main/java/frc/robot/commands/RunIntake.java +++ b/src/main/java/frc/robot/commands/RunIntake.java @@ -6,11 +6,15 @@ import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Intake; +import frc.robot.RobotContainer; public class RunIntake extends Command { + + private Intake intake; + /** Creates a new RunIntake. */ public RunIntake() { - // Use addRequirements() here to declare subsystem dependencies. + this.intake = RobotContainer.intake; } // Called when the command is initially scheduled. From ff2e12c078c2abd06e948523c3168162d06c28f7 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:36:05 -0600 Subject: [PATCH 12/24] Intake command stops and starts Added intake.runIntake() and intake.stop() to their respective methods. --- src/main/java/frc/robot/commands/RunIntake.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/commands/RunIntake.java b/src/main/java/frc/robot/commands/RunIntake.java index aae8927b..bb322f8b 100644 --- a/src/main/java/frc/robot/commands/RunIntake.java +++ b/src/main/java/frc/robot/commands/RunIntake.java @@ -19,7 +19,9 @@ public RunIntake() { // Called when the command is initially scheduled. @Override - public void initialize() {} + public void initialize() { + intake.runIntake(); + } // Called every time the scheduler runs while the command is scheduled. @Override @@ -27,7 +29,9 @@ public void execute() {} // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + intake.stop(); + } // Returns true when the command should end. @Override From 0d6e9cdeda424a4cc097332f86aa4cd44cdf86ee Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:38:21 -0600 Subject: [PATCH 13/24] Bound button A to runIntake(). --- src/main/java/frc/robot/RobotContainer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index aecb3159..95fae90a 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -18,6 +18,7 @@ import frc.robot.commands.DriveFieldOriented; import frc.robot.commands.DriveRobotOriented; import frc.robot.commands.EnterXMode; +import frc.robot.commands.RunIntake; import frc.robot.subsystems.Drive; import frc.robot.subsystems.Intake; @@ -46,6 +47,7 @@ public class RobotContainer { private final DriveRobotOriented driveRobotOriented = new DriveRobotOriented(); private final DriveFieldOriented driveFieldOriented = new DriveFieldOriented(); private final EnterXMode enterXMode = new EnterXMode(); + private final RunIntake runIntake = new RunIntake(); /* * *********************** @@ -69,6 +71,7 @@ private void configureBindings() { driverController.leftStick().toggleOnTrue(driveFieldOriented); driverController.x().onTrue(enterXMode); + driverController.a().onTrue(runIntake); } public Command getAutonomousCommand() { From a5442a3279c28335fe1e75dc086eb87d83331107 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:45:40 -0600 Subject: [PATCH 14/24] Applied spotless --- src/main/java/frc/robot/Constants.java | 1 + src/main/java/frc/robot/commands/RunIntake.java | 9 ++++++++- src/main/java/frc/robot/subsystems/Intake.java | 13 +++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index e8acc84b..f82d44f6 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -27,6 +27,7 @@ public static class Controllers { public static class Intake { /** Motor id of the Intake motor. */ public static final int INTAKE_MOTOR_ID = 0; + /** Speed we want to run the Intake at. */ public static final double INTAKE_MOTOR_SPEED = 0.5; } diff --git a/src/main/java/frc/robot/commands/RunIntake.java b/src/main/java/frc/robot/commands/RunIntake.java index bb322f8b..435e4190 100644 --- a/src/main/java/frc/robot/commands/RunIntake.java +++ b/src/main/java/frc/robot/commands/RunIntake.java @@ -2,11 +2,18 @@ // 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. +/* + * Asimov's Laws: + * The First Law: A robot may not injure a human being or, through inaction, allow a human being to come to harm. + * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. + * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. + */ + package frc.robot.commands; import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.subsystems.Intake; import frc.robot.RobotContainer; +import frc.robot.subsystems.Intake; public class RunIntake extends Command { diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index 1fdabf36..b1f219ed 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -2,15 +2,20 @@ // 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. +/* + * Asimov's Laws: + * The First Law: A robot may not injure a human being or, through inaction, allow a human being to come to harm. + * The Second Law: A robot must obey the orders given it by human beings except where such orders would conflict with the First Law. + * The Third Law: A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. + */ + package frc.robot.subsystems; -import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj.motorcontrol.Spark; +import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; -/** - * The intake of the robot. - */ +/** The intake of the robot. */ public class Intake extends SubsystemBase { private Spark intake; From 02e9acd67f7fbafedb48c676d6ff276b7f9c08c8 Mon Sep 17 00:00:00 2001 From: QuackitsQuinn Date: Tue, 23 Jan 2024 17:06:21 -0600 Subject: [PATCH 15/24] fix missing curly bracket --- src/main/java/frc/robot/Constants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 38e23153..fa184e9b 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -35,6 +35,7 @@ public static class Drive { /** The max speed the robot can rotate */ public static double MAX_ANGULAR_SPEED = Math.PI / 2; + } public static class Intake { /** Motor id of the Intake motor. */ @@ -42,6 +43,5 @@ public static class Intake { /** Speed we want to run the Intake at. */ public static final double INTAKE_MOTOR_SPEED = 0.5; - } } From b3be0dcc19f049f6924abe7548e378d7c0b4a4d9 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:54:48 -0600 Subject: [PATCH 16/24] Added Intake Limit Switch Port Constant Added INTAKE_LIMIT_SWITCH_DIO_PORT to constants. --- src/main/java/frc/robot/Constants.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index fa184e9b..bceeaf2f 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -40,6 +40,9 @@ public static class Drive { public static class Intake { /** Motor id of the Intake motor. */ public static final int INTAKE_MOTOR_ID = 0; + // It was me, DIO! + /** DIO Port ID for the Intake limit switch. */ + public static final int INTAKE_LIMIT_SWITCH_DIO_PORT = 0; /** Speed we want to run the Intake at. */ public static final double INTAKE_MOTOR_SPEED = 0.5; From 29331a96891f3ae54a49789552e789aff6143fdd Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:04:48 -0600 Subject: [PATCH 17/24] Added limitSwitch object Added limitSwitch object to Intake --- src/main/java/frc/robot/subsystems/Intake.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index b1f219ed..3326bf3e 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -11,6 +11,7 @@ package frc.robot.subsystems; +import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.motorcontrol.Spark; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; @@ -19,10 +20,12 @@ public class Intake extends SubsystemBase { private Spark intake; + private DigitalInput limitSwitch; /** Creates a new Intake. */ public Intake() { this.intake = new Spark(Constants.Intake.INTAKE_MOTOR_ID); + this.limitSwitch = new DigitalInput(Constants.Intake.INTAKE_LIMIT_SWITCH_DIO_PORT); } /** Runs the intake motors. */ From ed2105c2b95e09f69ffafe01e915eee4d305d76c Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:17:22 -0600 Subject: [PATCH 18/24] Added a getter method for the Intake Limit Switch Added getIntakeLimitSwitch() which returns the value of the limit switch for intake. --- src/main/java/frc/robot/subsystems/Intake.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index 3326bf3e..a3657d25 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -33,6 +33,11 @@ public void runIntake() { intake.set(Constants.Intake.INTAKE_MOTOR_SPEED); } + /** Returns a boolean value on whether or not the Limit Switch has been activated. */ + public boolean getIntakeLimitSwitch() { + return limitSwitch.get(); + } + /** Stops the intake motors. */ public void stop() { intake.set(0); From a3393ff8177145b885eb6293e7b2ab94e1b64bae Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:19:10 -0600 Subject: [PATCH 19/24] Renamed method From getIntakeLimitSwitch() to getLimitSwitch() --- src/main/java/frc/robot/subsystems/Intake.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index a3657d25..1ab0bcdb 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -33,8 +33,8 @@ public void runIntake() { intake.set(Constants.Intake.INTAKE_MOTOR_SPEED); } - /** Returns a boolean value on whether or not the Limit Switch has been activated. */ - public boolean getIntakeLimitSwitch() { + /** Returns a boolean value on whether or not the Limit Switch (for the intake) has been activated. */ + public boolean getLimitSwitch() { return limitSwitch.get(); } From 329f0fb4e665e3a5aac0dfd6e5862d702c65ff12 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:20:21 -0600 Subject: [PATCH 20/24] RunIntake finishes via limit switch RunIntake isFinished() returns the value of the intake's limit switch --- src/main/java/frc/robot/commands/RunIntake.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/commands/RunIntake.java b/src/main/java/frc/robot/commands/RunIntake.java index 435e4190..e0159571 100644 --- a/src/main/java/frc/robot/commands/RunIntake.java +++ b/src/main/java/frc/robot/commands/RunIntake.java @@ -43,6 +43,6 @@ public void end(boolean interrupted) { // Returns true when the command should end. @Override public boolean isFinished() { - return false; + return intake.getLimitSwitch(); } } From 165e832086054bdb205c7db972c264692619e3f8 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:26:55 -0600 Subject: [PATCH 21/24] Made the motor brushless in code Changed it from a Spark object to a CANSparkMax object. --- src/main/java/frc/robot/subsystems/Intake.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index 1ab0bcdb..84be2a31 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -11,6 +11,9 @@ package frc.robot.subsystems; +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkLowLevel.MotorType; + import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.motorcontrol.Spark; import edu.wpi.first.wpilibj2.command.SubsystemBase; @@ -19,12 +22,12 @@ /** The intake of the robot. */ public class Intake extends SubsystemBase { - private Spark intake; + private CANSparkMax intake; private DigitalInput limitSwitch; /** Creates a new Intake. */ public Intake() { - this.intake = new Spark(Constants.Intake.INTAKE_MOTOR_ID); + this.intake = new CANSparkMax(Constants.Intake.INTAKE_MOTOR_ID, MotorType.kBrushless); this.limitSwitch = new DigitalInput(Constants.Intake.INTAKE_LIMIT_SWITCH_DIO_PORT); } From 65962b762ec9a2f75c0e44ceb3f4ed946dcac119 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:29:13 -0600 Subject: [PATCH 22/24] Applied spotless :'( --- src/main/java/frc/robot/Constants.java | 1 + src/main/java/frc/robot/subsystems/Intake.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index bceeaf2f..16ceaf49 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -40,6 +40,7 @@ public static class Drive { public static class Intake { /** Motor id of the Intake motor. */ public static final int INTAKE_MOTOR_ID = 0; + // It was me, DIO! /** DIO Port ID for the Intake limit switch. */ public static final int INTAKE_LIMIT_SWITCH_DIO_PORT = 0; diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index 84be2a31..e4117bc7 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -11,11 +11,9 @@ package frc.robot.subsystems; -import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkLowLevel.MotorType; - +import com.revrobotics.CANSparkMax; import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.motorcontrol.Spark; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; @@ -36,7 +34,9 @@ public void runIntake() { intake.set(Constants.Intake.INTAKE_MOTOR_SPEED); } - /** Returns a boolean value on whether or not the Limit Switch (for the intake) has been activated. */ + /** + * Returns a boolean value on whether or not the Limit Switch (for the intake) has been activated. + */ public boolean getLimitSwitch() { return limitSwitch.get(); } From 1f9b633cb9a07c4496f854ebce8b6f9ceeae859f Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:46:07 -0600 Subject: [PATCH 23/24] Applied Spotless 2: Electric Boogaloo --- src/main/java/frc/robot/RobotContainer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 089db391..eb12d7b3 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -37,6 +37,7 @@ public class RobotContainer { */ /** Singleton instance of {@link Drive} */ public static Drive drive = new Drive(); + public static Intake intake = new Intake(); /* From ed9cf41afa497078b3c10944070ea5bda96a5c17 Mon Sep 17 00:00:00 2001 From: Berdenson <91093973+Berdenson@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:13:52 -0600 Subject: [PATCH 24/24] Implemented addRequirements() --- src/main/java/frc/robot/commands/RunIntake.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/commands/RunIntake.java b/src/main/java/frc/robot/commands/RunIntake.java index e0159571..0f816c01 100644 --- a/src/main/java/frc/robot/commands/RunIntake.java +++ b/src/main/java/frc/robot/commands/RunIntake.java @@ -22,6 +22,7 @@ public class RunIntake extends Command { /** Creates a new RunIntake. */ public RunIntake() { this.intake = RobotContainer.intake; + addRequirements(intake); } // Called when the command is initially scheduled.