diff --git a/.vscode/launch.json b/.vscode/launch.json
index 5b804e8..322274b 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -4,18 +4,24 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
-
+ {
+ "type": "java",
+ "name": "Main",
+ "request": "launch",
+ "mainClass": "frc.robot.Main",
+ "projectName": "Robot-Code-2024"
+ },
{
"type": "wpilib",
"name": "WPILib Desktop Debug",
"request": "launch",
- "desktop": true,
+ "desktop": true
},
{
"type": "wpilib",
"name": "WPILib roboRIO Debug",
"request": "launch",
- "desktop": false,
+ "desktop": false
}
]
}
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 8be11f2..f9d11ed 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -25,5 +25,10 @@
}
},
],
- "java.test.defaultConfig": "WPIlibUnitTests"
+ "java.test.defaultConfig": "WPIlibUnitTests",
+ "java.format.settings.url": ".vscode/eclipse-java-google-style.xml",
+ "[java]": {
+ "editor.detectIndentation": false
+ },
+ "java.checkstyle.configuration": "${workspaceFolder}/.vscode/eclipse-java-google-style.xml"
}
diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java
index f315188..bab4dd6 100644
--- a/src/main/java/frc/robot/Constants.java
+++ b/src/main/java/frc/robot/Constants.java
@@ -1,98 +1,94 @@
-// 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;
// ***NEED TO BE UPDATED FOR 2024 SEASON***
/**
- * The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
- * constants. This class should not be used for any other purpose. All constants should be declared
- * globally (i.e. public static). Do not put anything functional in this class.
+ * The Constants class provides a convenient place for teams to hold robot-wide numerical or
+ * boolean constants. This class should not be used for any other purpose. All constants should be
+ * declared globally (i.e. public static). Do not put anything functional in this class.
*
- *
It is advised to statically import this class (or one of its inner classes) wherever the
+ * It is advised to statically import this class (or one of its inner classes) wherever the
* constants are needed, to reduce verbosity.
*/
public final class Constants {
- public static class OperatorConstants {
- public static final int DRIVER_XBOX_PORT = 0;
- public static final int COPILOT_XBOX_PORT = 1;
+ public static class OperatorConstants {
+ public static final int DRIVER_XBOX_PORT = 0;
+ public static final int COPILOT_XBOX_PORT = 1;
- public static final double DRIVER_JOYSTICK_DEADBAND = 0.1;
- public static final double DRIVE_SPEED_ADJUSTMENT = 0.8;
- }
+ public static final double DRIVER_JOYSTICK_DEADBAND = 0.1;
+ public static final double DRIVE_SPEED_ADJUSTMENT = 0.8;
+ }
- public static class DrivetrainConstants {
- public static final int LEFT_MOTOR_1_PORT = 1;
- public static final int LEFT_MOTOR_2_PORT = 2;
- public static final int RIGHT_MOTOR_1_PORT = 3;
- public static final int RIGHT_MOTOR_2_PORT = 4;
+ public static class DrivetrainConstants {
+ public static final int LEFT_MOTOR_1_PORT = 1;
+ public static final int LEFT_MOTOR_2_PORT = 2;
+ public static final int RIGHT_MOTOR_1_PORT = 3;
+ public static final int RIGHT_MOTOR_2_PORT = 4;
- public static final int COUNTS_PER_REV = 42;
+ public static final int COUNTS_PER_REV = 42;
- // 1 meter = 39.37 inches = 2.088 wheel rotations = 17.664 motor rotations (assuming gear ratio = 8.46)
- public static final double METERS_TO_ROTATIONS = 17.664;
- public static final double DEGREES_TO_ROTATIONS = 0.1; // value accurate as of 2/13/24
- }
+ // 1 meter = 39.37 inches = 2.088 wheel rotations = 17.664 motor rotations (assuming gear ratio = 8.46)
+ public static final double METERS_TO_ROTATIONS = 17.664;
+ public static final double DEGREES_TO_ROTATIONS = 0.1; // value accurate as of 2/13/24
+ }
- public static class IntakeConstants {
- public static final int INTAKE_MOTOR_PORT = 5;
+ public static class IntakeConstants {
+ public static final int INTAKE_MOTOR_PORT = 5;
- public static final double INTAKE_MOTOR_SPEED_IN = 0.4;
- public static final double INTAKE_MOTOR_SPEED_OUT = -0.4;
+ public static final double INTAKE_MOTOR_SPEED_IN = 0.4;
+ public static final double INTAKE_MOTOR_SPEED_OUT = -0.4;
- public static final int COUNTS_PER_REV = 42;
- }
+ public static final int COUNTS_PER_REV = 42;
+ }
- public static class IndexerConstants {
- public static final int INDEXER_MOTOR_PORT = 6;
+ public static class IndexerConstants {
+ public static final int INDEXER_MOTOR_PORT = 6;
- public static final double INDEXER_MOTOR_SPEED_DOWN = 0.4; // TODO: replace with values from beam break branch
- public static final double INDEXER_MOTOR_SPEED_UP = -0.4; // TODO: replace with values from beam break branch
+ public static final double INDEXER_MOTOR_SPEED_DOWN = 0.4; // TO DO: replace with values from beam break branch
+ public static final double INDEXER_MOTOR_SPEED_UP = -0.4; // TO DO: replace with values from beam break branch
- public static final double INDEXER_MOTOR_SPEED_DOWN_BACKUP = 0.2; // for testing/backup, finalized 02/23/2024
- public static final double INDEXER_MOTOR_SPEED_UP_BACKUP = -0.2; // for testing/backup, finalized 02/23/2024
+ public static final double INDEXER_MOTOR_SPEED_DOWN_BACKUP = 0.2; // for testing/backup, finalized 02/23/2024
+ public static final double INDEXER_MOTOR_SPEED_UP_BACKUP = -0.2; // for testing/backup, finalized 02/23/2024
- public static final int COUNTS_PER_REV = 42;
- }
+ public static final int COUNTS_PER_REV = 42;
+ }
- public static class ShooterConstants {
- public static final int SHOOTER_MOTOR_PORT = 7;
+ public static class ShooterConstants {
+ public static final int SHOOTER_MOTOR_PORT = 7;
- public static final double SHOOTER_MOTOR_SPEED_AMP = HoodConstants.HOOD_MOTOR_SPEED / -2.0; // should be half of HOOD_MOTOR_SPEED, finalized 02/23/2024
- public static final double SHOOTER_MOTOR_SPEED_SPEAKER = -0.5; // correct as of 2/25/24
- public static final double SHOOTER_MOTOR_SPEED_OUT = -0.5; // constant for testing
+ public static final double SHOOTER_MOTOR_SPEED_AMP = HoodConstants.HOOD_MOTOR_SPEED / -2.0; // should be half of HOOD_MOTOR_SPEED, finalized 02/23/2024
+ public static final double SHOOTER_MOTOR_SPEED_SPEAKER = -0.5; // correct as of 2/25/24
+ public static final double SHOOTER_MOTOR_SPEED_OUT = -0.5; // constant for testing
- public static final int COUNTS_PER_REV = 42;
- }
+ public static final int COUNTS_PER_REV = 42;
+ }
- public static class HoodConstants {
- public static final int HOOD_MOTOR_PORT = 9; // correct as of 2/20/24
- public static final int PIVOT_MOTOR_PORT = 8; // correct as of 2/20/24
+ public static class HoodConstants {
+ public static final int HOOD_MOTOR_PORT = 9; // correct as of 2/20/24
+ public static final int PIVOT_MOTOR_PORT = 8; // correct as of 2/20/24
- public static final double HOOD_MOTOR_SPEED = 0.4; // should be double of SHOOTER_MOTOR_SPEED_AMP, finalized 02/23/2024
+ public static final double HOOD_MOTOR_SPEED = 0.4; // should be double of SHOOTER_MOTOR_SPEED_AMP, finalized 02/23/2024
- public static final double PIVOT_MOTOR_SPEED = 0.5; // finalized 02/23/2024
- public static final double SLOW_PIVOT_MOTOR_SPEED = 0.2; // finalized 02/23/2024
+ public static final double PIVOT_MOTOR_SPEED = 0.5; // finalized 02/23/2024
+ public static final double SLOW_PIVOT_MOTOR_SPEED = 0.2; // finalized 02/23/2024
- // assuming hood back is at encoder position 0, PIVOT_DISTANCE is the required encoder position for the hood to be forward
- public static final double PIVOT_DISTANCE = -48.20; // correct as of 2/20/24
+ // assuming hood back is at encoder position 0, PIVOT_DISTANCE is the required encoder position for the hood to be forward
+ public static final double PIVOT_DISTANCE = -48.20; // correct as of 2/20/24
- public static final int COUNTS_PER_REV = 42;
- }
+ public static final int COUNTS_PER_REV = 42;
+ }
- public static class ClimberConstants {
- public static final int CLIMBER_MOTOR_PORT = 100; // TO DO: set ID val
+ public static class ClimberConstants {
+ public static final int CLIMBER_MOTOR_PORT = 100; // TO DO: set ID val
- public static final int COUNTS_PER_REV = 42;
- }
+ public static final int COUNTS_PER_REV = 42;
+ }
- public static class AutoConstants {
- public static final double TAXI_AUTO_TARGET_DISTANCE = 25; // distance in meters to taxi (unset for 2024)
- public static final double TAXI_AUTO_SPEED = 0.4; // (temp) speed of robot during taxi auto
- public static final double ROTATION_SPEED = 0.5;
- }
+ public static class AutoConstants {
+ public static final double TAXI_AUTO_TARGET_DISTANCE = 25; // distance in meters to taxi (unset for 2024)
+ public static final double TAXI_AUTO_SPEED = 0.4; // (temp) speed of robot during taxi auto
+ public static final double ROTATION_SPEED = 0.5;
+ }
}
diff --git a/src/main/java/frc/robot/Main.java b/src/main/java/frc/robot/Main.java
index 8776e5d..028613e 100644
--- a/src/main/java/frc/robot/Main.java
+++ b/src/main/java/frc/robot/Main.java
@@ -1,25 +1,24 @@
-// 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;
import edu.wpi.first.wpilibj.RobotBase;
/**
- * Do NOT add any static variables to this class, or any initialization at all. Unless you know what
- * you are doing, do not modify this file except to change the parameter class to the startRobot
- * call.
+ * Do not add any static variables to this class, or any initialization at all. Unless you know
+ * what you are doing, do not modify this file except to change the parameter class to the
+ * startRobot call.
*/
public final class Main {
- private Main() {}
+ /**
+ * Constructs Main object.
+ */
+ public Main() {}
- /**
- * Main initialization function. Do not perform any initialization here.
- *
- *
If you change your main robot class, change the parameter type.
- */
- public static void main(String... args) {
- RobotBase.startRobot(Robot::new);
- }
+ /**
+ * Main initialization function. Do not perform any initialization here.
+ *
+ * If you change your main robot class, change the parameter type.
+ */
+ public static void main(String... args) {
+ RobotBase.startRobot(Robot::new);
+ }
}
diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java
index 475cc6c..6298913 100644
--- a/src/main/java/frc/robot/OI.java
+++ b/src/main/java/frc/robot/OI.java
@@ -48,4 +48,4 @@ public double getCoXBoxRightJoyX() {
return m_coPilotXbox.getRightX();
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java
index ccdab80..e1383af 100644
--- a/src/main/java/frc/robot/Robot.java
+++ b/src/main/java/frc/robot/Robot.java
@@ -1,14 +1,9 @@
-// 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;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
-
/**
* The VM is configured to automatically run this class, and to call the functions corresponding to
* each mode, as described in the TimedRobot documentation. If you change the name of this class or
@@ -16,90 +11,116 @@
* project.
*/
public class Robot extends TimedRobot {
- private Command m_autonomousCommand;
-
- private RobotContainer m_robotContainer;
-
- /**
- * This function is run when the robot is first started up and should be used for any
- * initialization code.
- */
- @Override
- public void robotInit() {
- // Instantiate our RobotContainer. This will perform all our button bindings, and put our
- // autonomous chooser on the dashboard.
-
- m_robotContainer = new RobotContainer();
- }
-
- /**
- * This function is called every 20 ms, no matter the mode. Use this for items like diagnostics
- * that you want ran during disabled, autonomous, teleoperated and test.
- *
- *
This runs after the mode specific periodic functions, but before LiveWindow and
- * SmartDashboard integrated updating.
- */
- @Override
- public void robotPeriodic() {
- // Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled
- // commands, running already-scheduled commands, removing finished or interrupted commands,
- // and running subsystem periodic() methods. This must be called from the robot's periodic
- // block in order for anything in the Command-based framework to work.
- CommandScheduler.getInstance().run();
- }
-
- /** This function is called once each time the robot enters Disabled mode. */
- @Override
- public void disabledInit() {}
-
- @Override
- public void disabledPeriodic() {}
-
- /** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */
- @Override
- public void autonomousInit() {
- m_autonomousCommand = m_robotContainer.getAutonomousCommand();
-
- // schedule the autonomous command (example)
- if (m_autonomousCommand != null) {
- m_autonomousCommand.schedule();
+ // Instance variables
+ private Command m_autonomousCommand;
+ private RobotContainer m_robotContainer;
+
+ /**
+ * Constructs Robot object.
+ */
+ public Robot() {}
+
+ /**
+ * This function is run when the robot is first started up and should be used for any
+ * robot-wide initialization code.
+ */
+ @Override
+ public void robotInit() {
+ // Instantiate our RobotContainer. This will perform all our button bindings, and put our
+ // autonomous chooser on the dashboard.
+ m_robotContainer = new RobotContainer();
}
- }
- /** This function is called periodically during autonomous. */
- @Override
- public void autonomousPeriodic() {}
-
- @Override
- public void teleopInit() {
- // This makes sure that the autonomous stops running when
- // 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();
+ /**
+ * This function is called every 20 ms, no matter the mode. Use this for items like diagnostics
+ * that you want ran during disabled, autonomous, teleoperated and test.
+ *
+ * This runs after the mode specific periodic functions, but before LiveWindow and
+ * SmartDashboard integrated updating.
+ */
+ @Override
+ public void robotPeriodic() {
+ // Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled
+ // commands, running already-scheduled commands, removing finished or interrupted commands,
+ // and running subsystem periodic() methods. This must be called from the robot's periodic
+ // block in order for anything in the Command-based framework to work.
+ CommandScheduler.getInstance().run();
}
- }
-
- /** This function is called periodically during operator control. */
- @Override
- public void teleopPeriodic() {}
- @Override
- public void testInit() {
- // Cancels all running commands at the start of test mode.
- CommandScheduler.getInstance().cancelAll();
- }
+ /**
+ * This function is called once each time the robot enters disabled mode.
+ */
+ @Override
+ public void disabledInit() {}
+
+ /**
+ * This function is called periodically while the robot is in disabled mode.
+ */
+ @Override
+ public void disabledPeriodic() {}
+
+ /**
+ * This function is called once each time the robot enters autonomous mode.
+ */
+ @Override
+ public void autonomousInit() {
+ m_autonomousCommand = m_robotContainer.getAutonomousCommand();
+
+ // schedule the autonomous command (example)
+ if (m_autonomousCommand != null) {
+ m_autonomousCommand.schedule();
+ }
+ }
- /** This function is called periodically during test mode. */
- @Override
- public void testPeriodic() {}
+ /**
+ * This function is called periodically while the robot is in autonomous mode.
+ */
+ @Override
+ public void autonomousPeriodic() {}
+
+ /**
+ * This function is called once each time the robot enters teleop mode.
+ */
+ @Override
+ public void teleopInit() {
+ // This makes sure that the autonomous stops running when 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();
+ }
+ }
- /** This function is called once when the robot is first started up. */
- @Override
- public void simulationInit() {}
+ /**
+ * This function is called periodically while the robot is in teleop mode.
+ */
+ @Override
+ public void teleopPeriodic() {}
+
+ /**
+ * This function is called once each time the robot enters test mode.
+ */
+ @Override
+ public void testInit() {
+ // Cancels all running commands at the start of test mode.
+ CommandScheduler.getInstance().cancelAll();
+ }
- /** This function is called periodically whilst in simulation. */
- @Override
- public void simulationPeriodic() {}
+ /**
+ * This function is called periodically while the robot is in test mode.
+ */
+ @Override
+ public void testPeriodic() {}
+
+ /**
+ * This function is called once when the robot is first started up.
+ */
+ @Override
+ public void simulationInit() {}
+
+ /**
+ * This function is called periodically while the robot is in simulation.
+ */
+ @Override
+ public void simulationPeriodic() {}
}
diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java
index c042894..dc765f5 100644
--- a/src/main/java/frc/robot/RobotContainer.java
+++ b/src/main/java/frc/robot/RobotContainer.java
@@ -1,10 +1,7 @@
-// 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;
-// import frc.robot.Constants.OperatorConstants;
+import edu.wpi.first.wpilibj2.command.Command;
+// import edu.wpi.first.wpilibj2.command.button.Trigger;
// import frc.robot.commands.ExampleCommand;
import frc.robot.commands.Autos;
@@ -57,85 +54,76 @@
/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
- * "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot}
- * periodic methods (other than the scheduler calls). Instead, the structure of the robot (including
+ * "declarative" paradigm, very little robot logic should actually be handled in the Robot periodic
+ * methods (other than the scheduler calls). Instead, the structure of the robot (including
* subsystems, commands, and trigger mappings) should be declared here.
*/
public class RobotContainer {
- // The robot's subsystems and commands are defined here...
- private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem();
- private static final OI m_humanControl = new OI();
- public static final Drivetrain m_drivetrain = new Drivetrain(m_humanControl);
- private static final Indexer m_indexer = new Indexer();
- private static final Intake m_intake = new Intake();
- private static final Shooter m_shooter = new Shooter();
- private static final Hood m_hood = new Hood();
-
- public SendableChooser m_chooser = new SendableChooser<>();
- // public static SequentialCommandGroup m_driveTwice = new SequentialCommandGroup(
- // // new SuctionOnCommand(m_gripper),
- // // new ArmPlaceHighCommand(m_arm),
- // // new SuctionOffCommand(m_gripper),
- // new DistanceDriveCommand(m_drivetrain, 1),
- // new DistanceDriveCommand(m_drivetrain, 2)
- // );
-
- /** The container for the robot. Contains subsystems, OI devices, and commands. */
- public RobotContainer() {
- // Configure the trigger bindings
- configureBindings();
-
- // set default commands
- m_drivetrain.setDefaultCommand(new ArcadeDriveCommand(m_drivetrain, m_humanControl));
- // m_hood.setDefaultCommand(new PrintHoodEncoder(m_hood));
-
- // auto routines
- m_chooser.addOption("Drive 2 meters", new DistanceDriveCommand(m_drivetrain, 2));
- m_chooser.addOption("Rotate 90 degrees", new RotationCommand(m_drivetrain, 90));
- // m_chooser.addOption("Double drive", m_driveTwice);
-
- ShuffleboardTab compTab = Shuffleboard.getTab("Comp HUD");
- compTab.add("Auto Chooser", m_chooser).withSize(3, 2);
- }
-
- /**
- * Use this method to define your trigger->command mappings. Triggers can be created via the
- * {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary
- * predicate, or via the named factories in {@link
- * edu.wpi.first.wpilibj2.command.button.CommandGenericHID}'s subclasses for {@link
- * CommandXboxController Xbox}/{@link edu.wpi.first.wpilibj2.command.button.CommandPS4Controller
- * PS4} controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight
- * joysticks}.
- */
- private void configureBindings() { // temp for testing
-
- OI.m_coPilotXbox.a().whileTrue(new ShooterHoodBackward(m_shooter, m_hood)); // emergency use button that should not be pressed in normal circumstances
- OI.m_coPilotXbox.b().whileTrue(new OuttakeIndexCommand(m_indexer, m_intake)); // outtaking should not normally be necessary
- OI.m_coPilotXbox.x().whileTrue(new IntakeIndexCommand(m_indexer, m_intake));
- OI.m_coPilotXbox.y().whileTrue(new IndexerUpCommand(m_indexer));
-
- OI.m_coPilotXbox.leftTrigger().whileTrue(new ShooterSpeakerCommand(m_shooter));
- OI.m_coPilotXbox.rightTrigger().whileTrue(new ShooterAmpCommand(m_shooter, m_hood));
-
- OI.m_coPilotXbox.leftBumper().whileTrue(new HoodPivotForwardCommand(m_hood));
- OI.m_coPilotXbox.rightBumper().whileTrue(new HoodPivotBackwardCommand(m_hood));
-
- // back and start buttons are backup commands for if the hood encoders mess up
- OI.m_coPilotXbox.back().whileTrue(new HoodPivotForwardBackup(m_hood));
- OI.m_coPilotXbox.start().whileTrue(new HoodPivotBackwardBackup(m_hood));
-
- OI.m_coPilotXbox.leftStick().whileTrue(new IntakeIndexCommandBackup(m_indexer, m_intake)); // backup intakeindex command in case beam break has issues
- // OI.m_coPilotXbox.leftStick().whileTrue(new HoodRollerCommand(m_hood)); // for testing only!
+ // The robot's subsystems and commands are defined here...
+ private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem();
+ private static final OI m_humanControl = new OI();
+ public static final Drivetrain m_drivetrain = new Drivetrain(m_humanControl);
+ private static final Indexer m_indexer = new Indexer();
+ private static final Intake m_intake = new Intake();
+ private static final Shooter m_shooter = new Shooter();
+ private static final Hood m_hood = new Hood();
+
+ public SendableChooser m_chooser = new SendableChooser<>();
+
+ /** The container for the robot. Contains subsystems, OI devices, and commands. */
+ public RobotContainer() {
+ // Configure the trigger bindings
+ configureBindings();
+
+ // set default commands
+ m_drivetrain.setDefaultCommand(new ArcadeDriveCommand(m_drivetrain, m_humanControl));
+ // m_hood.setDefaultCommand(new PrintHoodEncoder(m_hood));
+
+ // auto routines
+ m_chooser.addOption("Drive 2 meters", new DistanceDriveCommand(m_drivetrain, 2));
+ m_chooser.addOption("Rotate 90 degrees", new RotationCommand(m_drivetrain, 90));
+ // m_chooser.addOption("Double drive", m_driveTwice);
+
+ ShuffleboardTab compTab = Shuffleboard.getTab("Comp HUD");
+ compTab.add("Auto Chooser", m_chooser).withSize(3, 2);
+ }
+
+ /**
+ * Use this method to define your trigger->command mappings. Triggers can be created via the
+ * {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary
+ * predicate, or via the named factories in {@link
+ * edu.wpi.first.wpilibj2.command.button.CommandGenericHID}'s subclasses for {@link
+ * CommandXboxController Xbox}/{@link edu.wpi.first.wpilibj2.command.button.CommandPS4Controller
+ * PS4} controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight
+ * joysticks}.
+ */
+ private void configureBindings() { // temp for testing
+ OI.m_coPilotXbox.a().whileTrue(new ShooterHoodBackward(m_shooter, m_hood)); // emergency use button that should not be pressed in normal circumstances
+ OI.m_coPilotXbox.b().whileTrue(new OuttakeIndexCommand(m_indexer, m_intake)); // outtaking should not normally be necessary
+ OI.m_coPilotXbox.x().whileTrue(new IntakeIndexCommand(m_indexer, m_intake));
+ OI.m_coPilotXbox.y().whileTrue(new IndexerUpCommand(m_indexer));
+
+ OI.m_coPilotXbox.leftTrigger().whileTrue(new ShooterSpeakerCommand(m_shooter));
+ OI.m_coPilotXbox.rightTrigger().whileTrue(new ShooterAmpCommand(m_shooter, m_hood));
+
+ OI.m_coPilotXbox.leftBumper().whileTrue(new HoodPivotForwardCommand(m_hood));
+ OI.m_coPilotXbox.rightBumper().whileTrue(new HoodPivotBackwardCommand(m_hood));
+
+ // back and start buttons are backup commands for if the hood encoders mess up
+ OI.m_coPilotXbox.back().whileTrue(new HoodPivotForwardBackup(m_hood));
+ OI.m_coPilotXbox.start().whileTrue(new HoodPivotBackwardBackup(m_hood));
- }
-
- /**
- * Use this to pass the autonomous command to the main {@link Robot} class.
- *
- * @return the command to run in autonomous
- */
- public Command getAutonomousCommand() {
- // the selected command from shuffleboard that will be run in autonomous
- return m_chooser.getSelected();
- }
+ OI.m_coPilotXbox.leftStick().whileTrue(new IntakeIndexCommandBackup(m_indexer, m_intake)); // backup intakeindex command in case beam break has issues
+ // OI.m_coPilotXbox.leftStick().whileTrue(new HoodRollerCommand(m_hood)); // for testing only!
+ }
+
+ /**
+ * Use this to pass the autonomous command to the main {@link Robot} class.
+ *
+ * @return the command to run in autonomous
+ */
+ public Command getAutonomousCommand() {
+ // the selected command from shuffleboard that will be run in autonomous
+ return m_chooser.getSelected();
+ }
}
\ No newline at end of file
diff --git a/src/main/java/frc/robot/commands/ArcadeDriveCommand.java b/src/main/java/frc/robot/commands/ArcadeDriveCommand.java
index 08ac909..4502c90 100644
--- a/src/main/java/frc/robot/commands/ArcadeDriveCommand.java
+++ b/src/main/java/frc/robot/commands/ArcadeDriveCommand.java
@@ -6,22 +6,32 @@
import frc.robot.OI;
import frc.robot.Constants.OperatorConstants;
-// import java.lang.Math.*;
-
+/**
+ * Command to arcade drive. Uses Drivetrain and OI subsystems.
+ */
public class ArcadeDriveCommand extends Command {
+ // Instance variables
private final Drivetrain m_drivetrain;
private final OI m_humanControl;
+ /**
+ * Constructs an ArcadeDriveCommand command.
+ */
public ArcadeDriveCommand(Drivetrain drivetrain, OI humanControl) {
m_drivetrain = drivetrain;
m_humanControl = humanControl;
addRequirements(drivetrain);
}
+ /**
+ * Method called once per time the command is scheduled.
+ */
@Override
- public void initialize() { }
+ public void initialize() {}
- // Called every time the scheduler runs while the command is scheduled.
+ /**
+ * Method called repeatedly while the command is scheduled (every time the scheduler runs).
+ */
@Override
public void execute() {
double xJoy = m_humanControl.getDriverXBoxLeftJoyY();
@@ -29,14 +39,22 @@ public void execute() {
double x_val = Math.abs(xJoy) > OperatorConstants.DRIVER_JOYSTICK_DEADBAND ? xJoy : 0.0;
double y_val = Math.abs(yJoy) > OperatorConstants.DRIVER_JOYSTICK_DEADBAND ? yJoy : 0.0;
- m_drivetrain.arcadeDrive(OperatorConstants.DRIVE_SPEED_ADJUSTMENT * x_val, OperatorConstants.DRIVE_SPEED_ADJUSTMENT * y_val);
+ m_drivetrain.arcadeDrive(OperatorConstants.DRIVE_SPEED_ADJUSTMENT * x_val,
+ OperatorConstants.DRIVE_SPEED_ADJUSTMENT * y_val);
}
- // Called once the command ends or is interrupted.
+ /**
+ * Method called once when the command ends (whether it finishes normally or is interrupted).
+ */
@Override
public void end(boolean interrupted) {}
- // Returns true when the command should end.
+ /**
+ * Method called repeatedly while the command is scheduled (returns false while the command is
+ * scheduled, true when the command should end).
+ *
+ * @return whether command is finished
+ */
@Override
public boolean isFinished() {
return false;
diff --git a/src/main/java/frc/robot/commands/Autos.java b/src/main/java/frc/robot/commands/Autos.java
index dacf47c..f471390 100644
--- a/src/main/java/frc/robot/commands/Autos.java
+++ b/src/main/java/frc/robot/commands/Autos.java
@@ -1,26 +1,38 @@
-// 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 frc.robot.subsystems.*;
-import frc.robot.Constants.AutoConstants;
-
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
+import frc.robot.subsystems.ExampleSubsystem;
+import frc.robot.subsystems.Drivetrain;
+import frc.robot.Constants.AutoConstants;
+
+/**
+ * Class to hold all auto commands.
+ */
public final class Autos {
- /** Example static factory for an autonomous command. */
- public static Command exampleAuto(ExampleSubsystem subsystem) {
- return Commands.sequence(subsystem.exampleMethodCommand(), new ExampleCommand(subsystem));
- }
+ /**
+ * Example static factory method to create autonomous command.
+ *
+ * @return sequence of example commands to run in series, one after another
+ */
+ public static Command exampleAuto(ExampleSubsystem subsystem) {
+ return Commands.sequence(subsystem.exampleMethodCommand(), new ExampleCommand(subsystem));
+ }
- public static Command taxiAuto(Drivetrain drivetrain) {
- return new DistanceDriveCommand(drivetrain, AutoConstants.TAXI_AUTO_TARGET_DISTANCE);
- }
+ /**
+ * Command to drive straight.
+ *
+ * @return DistanceDriveCommand to drive straight
+ */
+ public static Command taxiAuto(Drivetrain drivetrain) {
+ return new DistanceDriveCommand(drivetrain, AutoConstants.TAXI_AUTO_TARGET_DISTANCE);
+ }
- private Autos() {
- throw new UnsupportedOperationException("This is a utility class!");
- }
+ /**
+ * Throws an error if Autos object is constructed.
+ */
+ private Autos() {
+ throw new UnsupportedOperationException("This is a utility class!");
+ }
}
diff --git a/src/main/java/frc/robot/commands/DistanceDriveCommand.java b/src/main/java/frc/robot/commands/DistanceDriveCommand.java
index 7a78d7f..90ceb56 100644
--- a/src/main/java/frc/robot/commands/DistanceDriveCommand.java
+++ b/src/main/java/frc/robot/commands/DistanceDriveCommand.java
@@ -1,8 +1,7 @@
-// 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.Drivetrain;
import frc.robot.Constants.AutoConstants;
import frc.robot.Constants.DrivetrainConstants;
@@ -11,50 +10,51 @@
import edu.wpi.first.wpilibj2.command.Command;
-
-/** A dead reckoning taxi command that uses the drivetrain subsystem. */
+/**
+ * Command to drive a set distance. Uses Drivetrain subsystem.
+ */
public class DistanceDriveCommand extends Command {
- @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"})
- private final Drivetrain m_drivetrain;
- private double m_targetDistance;
-
- /**
- * A dead reckoning drive command.
- * Takes in target distance in meters and drives straight that amount.
- */
- public DistanceDriveCommand(Drivetrain drivetrain, double targetDistance) {
- m_drivetrain = drivetrain;
- m_targetDistance = targetDistance * DrivetrainConstants.METERS_TO_ROTATIONS; // convert meters to motor rotations
- // System.out.println("Target meters: " + targetDistance + ", target rotations: " + m_targetDistance);
-
- addRequirements(drivetrain);
- }
-
- @Override
- public void initialize() {
- // resets positions of encoders
- m_drivetrain.setRightEncoder(0);
- m_drivetrain.setleftEncoder(0);
- }
-
- @Override
- public void execute() {
- double thrust = AutoConstants.TAXI_AUTO_SPEED*Math.signum(m_targetDistance); // drives in the direction of targetDistance
- m_drivetrain.tankDrive(-thrust, -thrust);
- // System.out.println("Left encoder position: " + m_drivetrain.getLeftEncoderPosition() + ", Right encoder position: " + m_drivetrain.getRightEncoderPosition());
- }
-
- @Override
- public void end(boolean interrupted) {
- m_drivetrain.stopMotors();
- m_drivetrain.setRightEncoder(0);
- m_drivetrain.setleftEncoder(0);
- }
-
- @Override
- public boolean isFinished() {
- // calculates if either encoder has moved enough to reach the target distance
- return (Math.abs(m_drivetrain.getRightEncoderPosition()) > Math.abs(m_targetDistance)
- || Math.abs(m_drivetrain.getLeftEncoderPosition()) > Math.abs(m_targetDistance));
- }
+ @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"})
+ private final Drivetrain m_drivetrain;
+ private double m_targetDistance;
+
+ /**
+ * A dead reckoning drive command.
+ * Takes in target distance in meters and drives straight that amount.
+ */
+ public DistanceDriveCommand(Drivetrain drivetrain, double targetDistance) {
+ m_drivetrain = drivetrain;
+ m_targetDistance = targetDistance * DrivetrainConstants.METERS_TO_ROTATIONS; // convert meters to motor rotations
+ // System.out.println("Target meters: " + targetDistance + ", target rotations: " + m_targetDistance);
+
+ addRequirements(drivetrain);
+ }
+
+ @Override
+ public void initialize() {
+ // resets positions of encoders
+ m_drivetrain.setRightEncoder(0);
+ m_drivetrain.setleftEncoder(0);
+ }
+
+ @Override
+ public void execute() {
+ double thrust = AutoConstants.TAXI_AUTO_SPEED*Math.signum(m_targetDistance); // drives in the direction of targetDistance
+ m_drivetrain.tankDrive(-thrust, -thrust);
+ // System.out.println("Left encoder position: " + m_drivetrain.getLeftEncoderPosition() + ", Right encoder position: " + m_drivetrain.getRightEncoderPosition());
+ }
+
+ @Override
+ public void end(boolean interrupted) {
+ m_drivetrain.stopMotors();
+ m_drivetrain.setRightEncoder(0);
+ m_drivetrain.setleftEncoder(0);
+ }
+
+ @Override
+ public boolean isFinished() {
+ // calculates if either encoder has moved enough to reach the target distance
+ return (Math.abs(m_drivetrain.getRightEncoderPosition()) > Math.abs(m_targetDistance)
+ || Math.abs(m_drivetrain.getLeftEncoderPosition()) > Math.abs(m_targetDistance));
+ }
}
diff --git a/src/main/java/frc/robot/commands/ExampleCommand.java b/src/main/java/frc/robot/commands/ExampleCommand.java
index 6161529..de60a6c 100644
--- a/src/main/java/frc/robot/commands/ExampleCommand.java
+++ b/src/main/java/frc/robot/commands/ExampleCommand.java
@@ -1,34 +1,50 @@
-// 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.ExampleSubsystem;
-/** An example command that uses an example subsystem. */
+/**
+ * Command example. Uses ExampleSubsystem subsystem.
+ */
public class ExampleCommand extends Command {
- @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"})
- private final ExampleSubsystem m_subsystem;
-
-
- public ExampleCommand(ExampleSubsystem subsystem) {
- m_subsystem = subsystem;
- addRequirements(subsystem);
- }
-
- @Override
- public void initialize() {}
-
- @Override
- public void execute() {}
-
- @Override
- public void end(boolean interrupted) {}
-
- @Override
- public boolean isFinished() {
- return false;
- }
+ // Instance variables
+ private final ExampleSubsystem m_subsystem;
+
+ /**
+ * Constructs an ExampleCommand command.
+ */
+ public ExampleCommand(ExampleSubsystem subsystem) {
+ m_subsystem = subsystem;
+ addRequirements(subsystem);
+ }
+
+ /**
+ * Method called once per time the command is scheduled.
+ */
+ @Override
+ public void initialize() {}
+
+ /**
+ * Method called repeatedly while the command is scheduled (every time the scheduler runs).
+ */
+ @Override
+ public void execute() {}
+
+ /**
+ * Method called once when the command ends (whether it finishes normally or is interrupted).
+ */
+ @Override
+ public void end(boolean interrupted) {}
+
+ /**
+ * Method called repeatedly while the command is scheduled (returns false while the command is
+ * scheduled, true when the command should end).
+ *
+ * @return whether command is finished
+ */
+ @Override
+ public boolean isFinished() {
+ return false;
+ }
}
diff --git a/src/main/java/frc/robot/commands/HoodPivotForwardCommand.java b/src/main/java/frc/robot/commands/HoodPivotForwardCommand.java
index 6d5049f..acfc45e 100644
--- a/src/main/java/frc/robot/commands/HoodPivotForwardCommand.java
+++ b/src/main/java/frc/robot/commands/HoodPivotForwardCommand.java
@@ -26,9 +26,9 @@ public void initialize() {
@Override
public void execute() {
// If hood pass 80% of pivot distance, it slows
- if(Math.abs(m_hood.getPivotEncoderPosition()) > 0.8*Math.abs(HoodConstants.PIVOT_DISTANCE)){
+ if (Math.abs(m_hood.getPivotEncoderPosition()) > (0.8 * Math.abs(HoodConstants.PIVOT_DISTANCE))) {
m_hood.runPivotHoodMotor(-HoodConstants.SLOW_PIVOT_MOTOR_SPEED);
- }else{
+ } else {
m_hood.runPivotHoodMotor(-HoodConstants.PIVOT_MOTOR_SPEED);
}
System.out.println(m_hood.getPivotEncoderPosition());
diff --git a/src/main/java/frc/robot/commands/IntakeIndexCommand.java b/src/main/java/frc/robot/commands/IntakeIndexCommand.java
index 7e04b2e..42337a3 100644
--- a/src/main/java/frc/robot/commands/IntakeIndexCommand.java
+++ b/src/main/java/frc/robot/commands/IntakeIndexCommand.java
@@ -31,14 +31,12 @@ public void initialize() {
public void execute() {
m_indexer.runIndexerMotor(IndexerConstants.INDEXER_MOTOR_SPEED_UP);
m_intake.runIntakeMotor(IntakeConstants.INTAKE_MOTOR_SPEED_IN);
-
}
@Override
public void end(boolean interrupted) {
m_indexer.indexerOff();
m_intake.intakeOff();
-
}
@Override
diff --git a/src/main/java/frc/robot/commands/IntakeIndexCommandBackup.java b/src/main/java/frc/robot/commands/IntakeIndexCommandBackup.java
index deb54db..ce47c7e 100644
--- a/src/main/java/frc/robot/commands/IntakeIndexCommandBackup.java
+++ b/src/main/java/frc/robot/commands/IntakeIndexCommandBackup.java
@@ -29,14 +29,12 @@ public void initialize() {
public void execute() {
m_indexer.runIndexerMotor(IndexerConstants.INDEXER_MOTOR_SPEED_UP_BACKUP);
m_intake.runIntakeMotor(IntakeConstants.INTAKE_MOTOR_SPEED_IN);
-
}
@Override
public void end(boolean interrupted) {
m_indexer.indexerOff();
m_intake.intakeOff();
-
}
@Override
diff --git a/src/main/java/frc/robot/commands/IntakeOutCommand.java b/src/main/java/frc/robot/commands/IntakeOutCommand.java
index 29e73a9..eb4935f 100644
--- a/src/main/java/frc/robot/commands/IntakeOutCommand.java
+++ b/src/main/java/frc/robot/commands/IntakeOutCommand.java
@@ -1,6 +1,7 @@
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command;
+
import frc.robot.subsystems.Intake;
import frc.robot.Constants.IntakeConstants;
@@ -16,21 +17,36 @@ public IntakeOutCommand(Intake intake){
addRequirements(intake);
}
+ /**
+ * Method called once per time the command is scheduled.
+ */
@Override
public void initialize() {
// System.out.println("INTAKE SUCK COMMAND STARTED");
}
+ /**
+ * Method called repeatedly while the command is scheduled (every time the scheduler runs).
+ */
@Override
public void execute() {
m_intake.runIntakeMotor(IntakeConstants.INTAKE_MOTOR_SPEED_OUT);
}
+ /**
+ * Method called once when the command ends (whether it finishes normally or is interrupted).
+ */
@Override
public void end(boolean interrupted) {
m_intake.intakeOff();
}
+ /**
+ * Method called repeatedly while the command is scheduled (returns false while the command is
+ * scheduled, true when the command should end).
+ *
+ * @return whether command is finished
+ */
@Override
public boolean isFinished() {
return false;
diff --git a/src/main/java/frc/robot/commands/OuttakeIndexCommand.java b/src/main/java/frc/robot/commands/OuttakeIndexCommand.java
index 589cfa1..69c8922 100644
--- a/src/main/java/frc/robot/commands/OuttakeIndexCommand.java
+++ b/src/main/java/frc/robot/commands/OuttakeIndexCommand.java
@@ -29,14 +29,12 @@ public void initialize() {
public void execute() {
m_indexer.runIndexerMotor(IndexerConstants.INDEXER_MOTOR_SPEED_DOWN);
m_intake.runIntakeMotor(IntakeConstants.INTAKE_MOTOR_SPEED_OUT);
-
}
@Override
public void end(boolean interrupted) {
m_indexer.indexerOff();
m_intake.intakeOff();
-
}
@Override
diff --git a/src/main/java/frc/robot/commands/PrintHoodEncoder.java b/src/main/java/frc/robot/commands/PrintHoodEncoder.java
index 3a96875..dfab3f0 100644
--- a/src/main/java/frc/robot/commands/PrintHoodEncoder.java
+++ b/src/main/java/frc/robot/commands/PrintHoodEncoder.java
@@ -20,7 +20,7 @@ public void initialize() {
@Override
public void execute() {
- System.out.println(m_hood.getPivotEncoderPosition());
+ System.out.println(m_hood.getPivotEncoderPosition());
}
@Override
diff --git a/src/main/java/frc/robot/subsystems/Climber.java b/src/main/java/frc/robot/subsystems/Climber.java
index be037cb..67debcf 100644
--- a/src/main/java/frc/robot/subsystems/Climber.java
+++ b/src/main/java/frc/robot/subsystems/Climber.java
@@ -7,7 +7,7 @@
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.ClimberConstants;
-/* THIS CODE IS PLACEHOLDER CODE AND NEEDS TO BE REPLACED WHEN CLIMBER DESIGN IS FINALIZED */
+import frc.robot.Constants.ClimberConstants;
public class Climber extends SubsystemBase {
private final CANSparkMax m_climberMotor = new CANSparkMax(ClimberConstants.CLIMBER_MOTOR_PORT, MotorType.kBrushless);
@@ -15,34 +15,51 @@ public class Climber extends SubsystemBase {
private final SparkRelativeEncoder m_climberEncoder = (SparkRelativeEncoder) m_climberMotor
.getEncoder(SparkRelativeEncoder.Type.kHallSensor, ClimberConstants.COUNTS_PER_REV);
- // Constructor for the Intake class
- public Climber(){
- }
+ /**
+ * Constructs a Climber subsystem.
+ */
+ public Climber() {}
- // returns encoder position
+ /**
+ * Gets climber encoder position.
+ *
+ * @return current encoder position (in "rotations")
+ */
public double getclimberEncoderPosition() {
return m_climberEncoder.getPosition();
}
- // sets encoder to desired position
+ /**
+ * Sets climber encoder position.
+ *
+ * @param position desired encoder position (in "rotations")
+ */
public void setClimberEncoderPosition(double position) {
m_climberEncoder.setPosition(position);
}
- // initializes encoder position to 0 - MAKE SURE INTAKE IS ALWAYS FULLY UP WHENEVER THIS METHOD IS CALLED
+ /**
+ * Initializes climber encoder position to 0.
+ */
public void initializeClimberEncoderPosition() {
- setClimberEncoderPosition(0); // TO DO: WRITE THE SET FUNCTION
+ setClimberEncoderPosition(0);
}
- // Sets intake motor speed (forward if positive, backward if negative)
+ /**
+ * Sets climber motor speed (forward if positive / backward if negative).
+ *
+ * @param speed desired motor speed (between -1.0 and 1.0)
+ */
public void runClimberMotor(double speed){
m_climberMotor.set(speed);
}
- // Sets intake motor speed to zero and stops motor
+ /**
+ * Sets climber motor speed to 0 and stops motor.
+ */
public void climberOff() {
- m_climberMotor.set(0);
- m_climberMotor.stopMotor();
+ m_climberMotor.set(0);
+ m_climberMotor.stopMotor();
}
}
diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java
index 5722169..a0c6b2f 100644
--- a/src/main/java/frc/robot/subsystems/Drivetrain.java
+++ b/src/main/java/frc/robot/subsystems/Drivetrain.java
@@ -140,4 +140,4 @@ public void tankDrive(double leftSpeed, double rightSpeed) {
public void stopMotors() {
m_robotDrive.stopMotor();
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/frc/robot/subsystems/ExampleSubsystem.java b/src/main/java/frc/robot/subsystems/ExampleSubsystem.java
index 8582eb3..f1122e7 100644
--- a/src/main/java/frc/robot/subsystems/ExampleSubsystem.java
+++ b/src/main/java/frc/robot/subsystems/ExampleSubsystem.java
@@ -1,9 +1,6 @@
-// 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;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
@@ -11,20 +8,45 @@ public class ExampleSubsystem extends SubsystemBase {
/** Creates a new ExampleSubsystem. */
public ExampleSubsystem() {}
- public Command exampleMethodCommand() {
- // Inline construction of command goes here.
- // Subsystem::RunOnce implicitly requires `this` subsystem.
- return runOnce(()
- -> {
- /* one-time action goes here */
- });
- }
+ /**
+ * Factory method to create command (not being used right now).
+ *
+ * @return a command
+ */
+ public Command exampleMethodCommand() {
+ // Inline construction of command
+ // Subsystem::RunOnce implicitly requires `this` subsystem
+ return runOnce(
+ () -> {
+ // One-time action
+ }
+ );
+ }
- public boolean exampleCondition() { return false; }
+ /**
+ * Method to query a boolean state of the subsystem (not being used right now).
+ *
+ * @return value of some boolean subsystem state
+ */
+ public boolean exampleCondition() {
+ // Query some boolean state, such as a digital sensor
+ return false;
+ }
- @Override
- public void periodic() {}
+ /**
+ * Method to be called once every scheduler run (not being used right now).
+ */
+ @Override
+ public void periodic() {
+ // Typically used for telemetry and other periodic actions that do not interfere with
+ // commands
+ }
- @Override
- public void simulationPeriodic() {}
+ /**
+ * Method to be called once every scheduler run during simulation (not being used right now).
+ */
+ @Override
+ public void simulationPeriodic() {
+ // Can be used to update state of robot
+ }
}
diff --git a/src/main/java/frc/robot/subsystems/Indexer.java b/src/main/java/frc/robot/subsystems/Indexer.java
index 9cc57ca..3b0122c 100644
--- a/src/main/java/frc/robot/subsystems/Indexer.java
+++ b/src/main/java/frc/robot/subsystems/Indexer.java
@@ -15,37 +15,37 @@
public class Indexer extends SubsystemBase {
- // instance variables
- private final CANSparkMax m_indexerMotor = new CANSparkMax(IndexerConstants.INDEXER_MOTOR_PORT, MotorType.kBrushless);
- private final SparkRelativeEncoder m_indexerEncoder = (SparkRelativeEncoder) m_indexerMotor
- .getEncoder(SparkRelativeEncoder.Type.kHallSensor, IndexerConstants.COUNTS_PER_REV);
-
- // constructor
- public Indexer() {}
-
- // Sets Indexer motor speed (forward if positive, backward if negative)
- public void runIndexerMotor(double speed) {
- m_indexerMotor.set(speed);
- }
-
- // Sets Indexer motor speed to zero and stops motor
- public void indexerOff() {
- m_indexerMotor.set(0);
- m_indexerMotor.stopMotor();
- }
-
- // returns encoder position
- public double getEncoderPosition() {
- return m_indexerEncoder.getPosition();
- }
-
- // sets encoder to desired position
- public void setEncoderPosition(double position) {
- m_indexerEncoder.setPosition(position);
- }
-
- // returns encoder velocity
- public double getEncoderVelocity() {
- return m_indexerEncoder.getVelocity();
- }
+ // instance variables
+ private final CANSparkMax m_indexerMotor = new CANSparkMax(IndexerConstants.INDEXER_MOTOR_PORT, MotorType.kBrushless);
+ private final SparkRelativeEncoder m_indexerEncoder = (SparkRelativeEncoder) m_indexerMotor
+ .getEncoder(SparkRelativeEncoder.Type.kHallSensor, IndexerConstants.COUNTS_PER_REV);
+
+ // constructor
+ public Indexer() {}
+
+ // Sets Indexer motor speed (forward if positive, backward if negative)
+ public void runIndexerMotor(double speed) {
+ m_indexerMotor.set(speed);
+ }
+
+ // Sets Indexer motor speed to zero and stops motor
+ public void indexerOff() {
+ m_indexerMotor.set(0);
+ m_indexerMotor.stopMotor();
+ }
+
+ // returns encoder position
+ public double getEncoderPosition() {
+ return m_indexerEncoder.getPosition();
+ }
+
+ // sets encoder to desired position
+ public void setEncoderPosition(double position) {
+ m_indexerEncoder.setPosition(position);
+ }
+
+ // returns encoder velocity
+ public double getEncoderVelocity() {
+ return m_indexerEncoder.getVelocity();
+ }
}
diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java
index 778f313..2614ab8 100644
--- a/src/main/java/frc/robot/subsystems/Intake.java
+++ b/src/main/java/frc/robot/subsystems/Intake.java
@@ -15,37 +15,38 @@
public class Intake extends SubsystemBase {
- // instance variables
- private final CANSparkMax m_intakeMotor = new CANSparkMax(IntakeConstants.INTAKE_MOTOR_PORT, MotorType.kBrushless);
- private final SparkRelativeEncoder m_intakeEncoder = (SparkRelativeEncoder) m_intakeMotor
- .getEncoder(SparkRelativeEncoder.Type.kHallSensor, IntakeConstants.COUNTS_PER_REV);
-
- // constructor
- public Intake() {}
-
- // Sets intake motor speed (forward if positive, backward if negative)
- public void runIntakeMotor(double speed) {
- m_intakeMotor.set(speed);
- }
-
- // Sets intake motor speed to zero and stops motor
- public void intakeOff() {
- m_intakeMotor.set(0);
- m_intakeMotor.stopMotor();
- }
-
- // returns encoder position
- public double getEncoderPosition() {
- return m_intakeEncoder.getPosition();
- }
-
- // sets encoder to desired position
- public void setEncoderPosition(double position) {
- m_intakeEncoder.setPosition(position);
- }
-
- // returns encoder velocity
- public double getEncoderVelocity() {
- return m_intakeEncoder.getVelocity();
- }
-}
+ // instance variables
+ private final CANSparkMax m_intakeMotor = new CANSparkMax(IntakeConstants.INTAKE_MOTOR_PORT,
+ MotorType.kBrushless);
+ private final SparkRelativeEncoder m_intakeEncoder = (SparkRelativeEncoder)
+ m_intakeMotor.getEncoder(SparkRelativeEncoder.Type.kHallSensor, IntakeConstants.COUNTS_PER_REV);
+
+ // constructor
+ public Intake() {}
+
+ // Sets intake motor speed (forward if positive, backward if negative)
+ public void runIntakeMotor(double speed) {
+ m_intakeMotor.set(speed);
+ }
+
+ // Sets intake motor speed to zero and stops motor
+ public void intakeOff() {
+ m_intakeMotor.set(0);
+ m_intakeMotor.stopMotor();
+ }
+
+ // returns encoder position
+ public double getEncoderPosition() {
+ return m_intakeEncoder.getPosition();
+ }
+
+ // sets encoder to desired position
+ public void setEncoderPosition(double position) {
+ m_intakeEncoder.setPosition(position);
+ }
+
+ // returns encoder velocity
+ public double getEncoderVelocity() {
+ return m_intakeEncoder.getVelocity();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java
index ac5fbdb..3bdc599 100644
--- a/src/main/java/frc/robot/subsystems/Shooter.java
+++ b/src/main/java/frc/robot/subsystems/Shooter.java
@@ -14,35 +14,36 @@
// ***NEED TO BE UPDATED FOR 2024 SEASON***
public class Shooter extends SubsystemBase {
- private final CANSparkMax m_shooterMotor = new CANSparkMax(ShooterConstants.SHOOTER_MOTOR_PORT, MotorType.kBrushless);
- private final SparkRelativeEncoder m_shooterEncoder = (SparkRelativeEncoder) m_shooterMotor
- .getEncoder(SparkRelativeEncoder.Type.kHallSensor, ShooterConstants.COUNTS_PER_REV);
-
- public Shooter() {}
-
- // Sets intake motor speed (forward if positive, backward if negative)
- public void runShooterMotor(double speed) {
- m_shooterMotor.set(speed);
- }
-
- // Sets intake motor speed to zero and stops motor
- public void shooterOff() {
- m_shooterMotor.set(0);
- m_shooterMotor.stopMotor();
- }
-
- // returns encoder position
- public double getEncoderPosition() {
- return m_shooterEncoder.getPosition();
- }
-
- // sets encoder to desired position
- public void setEncoderPosition(double position) {
- m_shooterEncoder.setPosition(position);
- }
-
- // returns encoder velocity
- public double getEncoderVelocity() {
- return m_shooterEncoder.getVelocity();
- }
+ private final CANSparkMax m_shooterMotor = new CANSparkMax(ShooterConstants.SHOOTER_MOTOR_PORT,
+ MotorType.kBrushless);
+ private final SparkRelativeEncoder m_shooterEncoder = (SparkRelativeEncoder)
+ m_shooterMotor.getEncoder(SparkRelativeEncoder.Type.kHallSensor, ShooterConstants.COUNTS_PER_REV);
+
+ public Shooter() {}
+
+ // Sets intake motor speed (forward if positive, backward if negative)
+ public void runShooterMotor(double speed) {
+ m_shooterMotor.set(speed);
+ }
+
+ // Sets intake motor speed to zero and stops motor
+ public void shooterOff() {
+ m_shooterMotor.set(0);
+ m_shooterMotor.stopMotor();
+ }
+
+ // returns encoder position
+ public double getEncoderPosition() {
+ return m_shooterEncoder.getPosition();
+ }
+
+ // sets encoder to desired position
+ public void setEncoderPosition(double position) {
+ m_shooterEncoder.setPosition(position);
+ }
+
+ // returns encoder velocity
+ public double getEncoderVelocity() {
+ return m_shooterEncoder.getVelocity();
+ }
}
\ No newline at end of file