diff --git a/src/main/java/edu/bearbots/BearLib/drivebase/Drivebase.java b/src/main/java/edu/bearbots/BearLib/drivebase/Drivebase.java index 39ef02a..c84ca75 100644 --- a/src/main/java/edu/bearbots/BearLib/drivebase/Drivebase.java +++ b/src/main/java/edu/bearbots/BearLib/drivebase/Drivebase.java @@ -1,14 +1,10 @@ package edu.bearbots.BearLib.drivebase; import com.revrobotics.CANSparkMax; -import com.revrobotics.REVLibError; import com.revrobotics.CANSparkMax.IdleMode; +import com.revrobotics.REVLibError; -import java.util.Map; - -/** - * Abstract class to handle common drivebase motor controller functions. - */ +/** Abstract class to handle common drivebase motor controller functions. */ public abstract class Drivebase { // for all drive bases? don't implement motors // odometry @@ -16,12 +12,12 @@ public abstract class Drivebase { // move to /** - * Sets the current limit for Spark Max motor controllers, given a free limit - * and a stall limit (in amps) as well as any number of Spark Maxes. - * - * @param freeLimit The free limit (in amps) + * Sets the current limit for Spark Max motor controllers, given a free limit and a stall limit + * (in amps) as well as any number of Spark Maxes. + * + * @param freeLimit The free limit (in amps) * @param stallLimit The stall limit (in amps) - * @param motor The Spark Maxes + * @param motor The Spark Maxes * @return An array of errors, if any */ public REVLibError[] setCurrentLimit(int freeLimit, int stallLimit, CANSparkMax... motor) { @@ -35,13 +31,12 @@ public REVLibError[] setCurrentLimit(int freeLimit, int stallLimit, CANSparkMax. return errors; } - /** - * Sets the idle mode for Spark Max motor controllers, given an idle mode and - * any number of Spark Maxes. - * - * @param mode The idle mode + * Sets the idle mode for Spark Max motor controllers, given an idle mode and any number of Spark + * Maxes. + * + * @param mode The idle mode * @param motor The Spark Maxes * @return An array of errors, if any */ @@ -57,4 +52,4 @@ public REVLibError[] setIdleMode(IdleMode mode, CANSparkMax... motor) { return errors; } } -// inclue \ No newline at end of file +// inclue diff --git a/src/main/java/edu/bearbots/BearLib/drivebase/MecanumDrivebase.java b/src/main/java/edu/bearbots/BearLib/drivebase/MecanumDrivebase.java index 3454ffc..fad51d5 100644 --- a/src/main/java/edu/bearbots/BearLib/drivebase/MecanumDrivebase.java +++ b/src/main/java/edu/bearbots/BearLib/drivebase/MecanumDrivebase.java @@ -1,4 +1,3 @@ package edu.bearbots.BearLib.drivebase; -public abstract class MecanumDrivebase extends Drivebase { -} \ No newline at end of file +public abstract class MecanumDrivebase extends Drivebase {} diff --git a/src/main/java/edu/bearbots/BearLib/drivebase/SwerveDrivebase.java b/src/main/java/edu/bearbots/BearLib/drivebase/SwerveDrivebase.java index 830a8e2..75a3b8c 100644 --- a/src/main/java/edu/bearbots/BearLib/drivebase/SwerveDrivebase.java +++ b/src/main/java/edu/bearbots/BearLib/drivebase/SwerveDrivebase.java @@ -1,4 +1,3 @@ package edu.bearbots.BearLib.drivebase; -public abstract class SwerveDrivebase extends Drivebase { -} \ No newline at end of file +public abstract class SwerveDrivebase extends Drivebase {} diff --git a/src/main/java/edu/bearbots/BearLib/drivebase/TankDrivebase.java b/src/main/java/edu/bearbots/BearLib/drivebase/TankDrivebase.java index 6a87612..45cf305 100644 --- a/src/main/java/edu/bearbots/BearLib/drivebase/TankDrivebase.java +++ b/src/main/java/edu/bearbots/BearLib/drivebase/TankDrivebase.java @@ -1,4 +1,3 @@ package edu.bearbots.BearLib.drivebase; -public abstract class TankDrivebase extends Drivebase { -} \ No newline at end of file +public abstract class TankDrivebase extends Drivebase {} diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 66f220b..7290622 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -8,15 +8,11 @@ import edu.wpi.first.wpilibj.XboxController; /** - * 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 + * 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 { diff --git a/src/main/java/frc/robot/Interfaces/CANSparkMax.java b/src/main/java/frc/robot/Interfaces/CANSparkMax.java index 67a8645..f836c23 100644 --- a/src/main/java/frc/robot/Interfaces/CANSparkMax.java +++ b/src/main/java/frc/robot/Interfaces/CANSparkMax.java @@ -141,14 +141,14 @@ public CANSparkMax(int deviceId, MotorType type) { * public boolean isInverted; * public boolean roboRIO; * } - * + * * public class PeriodicStatus1 { * public double sensorVelocity; * public byte motorTemperature; * public double busVoltage; * public double outputCurrent; * } - * + * * public class PeriodicStatus2 { * public double sensorPosition; * public double iAccum; diff --git a/src/main/java/frc/robot/Main.java b/src/main/java/frc/robot/Main.java index 5ed4cb7..dc3756f 100644 --- a/src/main/java/frc/robot/Main.java +++ b/src/main/java/frc/robot/Main.java @@ -7,21 +7,17 @@ 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 + * 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() { - } + private Main() {} /** * Main initialization function. Do not perform any initialization here. * - *
- * If you change your main robot class, change the parameter type. + *
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/RebindHat.java b/src/main/java/frc/robot/RebindHat.java index c131f10..c813ac8 100644 --- a/src/main/java/frc/robot/RebindHat.java +++ b/src/main/java/frc/robot/RebindHat.java @@ -1,12 +1,12 @@ package frc.robot; -/** @deprecated */ +/** + * @deprecated + */ // dude come onthis is the deffinition fo unnesseary complecity @Deprecated public class RebindHat { - public static double JoystickToYAxis() { - - } + public static double JoystickToYAxis() {} public static double JoystickToXAxis() { if (RobotContainer.m_armController.getPOV() == -1 diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index be67fa4..7ed8b47 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -12,12 +12,9 @@ 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 - * the package after creating this project, you must also update the - * build.gradle file in the + * 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 + * the package after creating this project, you must also update the build.gradle file in the * project. */ public class Robot extends TimedRobot { @@ -26,8 +23,7 @@ public class Robot extends TimedRobot { private RobotContainer m_robotContainer; /** - * This function is run when the robot is first started up and should be used - * for any + * This function is run when the robot is first started up and should be used for any * initialization code. */ @Override @@ -45,13 +41,10 @@ public void robotInit() { } /** - * This function is called every 20 ms, no matter the mode. Use this for items - * like diagnostics + * 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 + *
This runs after the mode specific periodic functions, but before LiveWindow and * SmartDashboard integrated updating. */ @Override @@ -69,17 +62,12 @@ public void robotPeriodic() { /** This function is called once each time the robot enters Disabled mode. */ @Override - public void disabledInit() { - } + public void disabledInit() {} @Override - public void disabledPeriodic() { - } + public void disabledPeriodic() {} - /** - * This autonomous runs the autonomous command selected by your - * {@link RobotContainer} class. - */ + /** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */ @Override public void autonomousInit() { m_autonomousCommand = m_robotContainer.getAutonomousCommand(); @@ -92,8 +80,7 @@ public void autonomousInit() { /** This function is called periodically during autonomous. */ @Override - public void autonomousPeriodic() { - } + public void autonomousPeriodic() {} @Override public void teleopInit() { @@ -110,8 +97,7 @@ public void teleopInit() { /** This function is called periodically during operator control. */ @Override - public void teleopPeriodic() { - } + public void teleopPeriodic() {} @Override public void testInit() { @@ -121,16 +107,13 @@ public void testInit() { /** This function is called periodically during test mode. */ @Override - public void testPeriodic() { - } + public void testPeriodic() {} /** This function is called once when the robot is first started up. */ @Override - public void simulationInit() { - } + public void simulationInit() {} /** This function is called periodically whilst in simulation. */ @Override - public void simulationPeriodic() { - } + public void simulationPeriodic() {} } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 61638c9..98a037f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -17,12 +17,9 @@ import io.github.oblarg.oblog.Logger; /** - * 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 + * 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 * subsystems, commands, and button mappings) should be declared here. */ public class RobotContainer { @@ -30,9 +27,10 @@ public class RobotContainer { // INSTANTIATES ALL JOYSTICKS - /** @deprecated The drivers are much more comfortable with an xbox controller */ - @Deprecated - public static final Joystick m_armController = new Joystick(0); + /** + * @deprecated The drivers are much more comfortable with an xbox controller + */ + @Deprecated public static final Joystick m_armController = new Joystick(0); public static final XboxController m_armController2 = new XboxController(1); public static final XboxController m_driverController = new XboxController(2); @@ -53,19 +51,20 @@ public class RobotContainer { private final BalanceCommand m_BalanceCommand = new BalanceCommand(m_PID, m_Tank); private final AutoCommand m_AutoCommand = new AutoCommand(m_PID, m_Tank, m_Arm, m_Claw); private final InvertDriveCommand m_InvertDriveCommand = new InvertDriveCommand(m_Tank, this); - private final PlaceConeSecondLevelCommand m_PlaceConeSecondLevelCommand = new PlaceConeSecondLevelCommand(m_Tank, - m_Arm, m_Claw); - private final IncreaseMaxSpeedCommand m_IncreaseMaxSpeedCommand = new IncreaseMaxSpeedCommand(m_Tank); - private final DecreaseMaxSpeedCommand m_DecreaseMaxSpeedCommand = new DecreaseMaxSpeedCommand(m_Tank); + private final PlaceConeSecondLevelCommand m_PlaceConeSecondLevelCommand = + new PlaceConeSecondLevelCommand(m_Tank, m_Arm, m_Claw); + private final IncreaseMaxSpeedCommand m_IncreaseMaxSpeedCommand = + new IncreaseMaxSpeedCommand(m_Tank); + private final DecreaseMaxSpeedCommand m_DecreaseMaxSpeedCommand = + new DecreaseMaxSpeedCommand(m_Tank); private final FineDriveCommand m_FineDriveCommand = new FineDriveCommand(m_Tank); - private final PlaceCubeSecondLevelCommand m_PlaceCubeSecondLevelCommand = new PlaceCubeSecondLevelCommand(m_Tank, - m_Arm, m_Claw); + private final PlaceCubeSecondLevelCommand m_PlaceCubeSecondLevelCommand = + new PlaceCubeSecondLevelCommand(m_Tank, m_Arm, m_Claw); - private GenericEntry timeWidget = Shuffleboard.getTab("stuff").add("time", 0).withWidget("Match Time").getEntry(); + private GenericEntry timeWidget = + Shuffleboard.getTab("stuff").add("time", 0).withWidget("Match Time").getEntry(); - /** - * The container for the robot. Contains subsystems, OI devices, and commands. - */ + /** The container for the robot. Contains subsystems, OI devices, and commands. */ public RobotContainer() { // Configure the button bindings configureButtonBindings(); @@ -113,16 +112,14 @@ private void configureButtonBindings() { // .whileTrue(m_OpenClawCommand); new JoystickButton(m_armController2, XboxController.Button.kLeftBumper.value) .whileTrue(m_FineDriveCommand); - new JoystickButton(m_armController2, XboxController.Button.kY.value).whileTrue(m_PlaceConeSecondLevelCommand); + new JoystickButton(m_armController2, XboxController.Button.kY.value) + .whileTrue(m_PlaceConeSecondLevelCommand); // new JoystickButton(m_armController2, XboxController.Button.kB.value) // .whileTrue(m_PlaceConeSecondLevelCommand); } - /** - * gets the value of the left stick on the driver controller to be used for - * turning - */ + /** gets the value of the left stick on the driver controller to be used for turning */ public static double getTurningStickInput() { // uses the left stick on the driver controller double axis = m_driverController.getRawAxis(1); @@ -133,9 +130,7 @@ public static double getTurningStickInput() { return axis * -1; } - /** - * returns value used for turning - */ + /** returns value used for turning */ public static double getAdjustedTurningStickInput() { double val = getTurningStickInput(); if (val > 0) { @@ -148,8 +143,8 @@ public static double getAdjustedTurningStickInput() { } /** - * gets the value of the right stick on the driver controller to be used for - * forward and backward movement + * gets the value of the right stick on the driver controller to be used for forward and backward + * movement */ public static double getForwardStickInput() { double axis = m_driverController.getRawAxis(4); @@ -172,11 +167,10 @@ public static double getAdjustedForwardStickInput() { } /** - * This function gets the joystick value of the left stick on the arm controller - * The left stick is used to move the arm up and down - * The function returns the value of the left stick - * The value of the left stick is put on the smart dashboard - * + * This function gets the joystick value of the left stick on the arm controller The left stick is + * used to move the arm up and down The function returns the value of the left stick The value of + * the left stick is put on the smart dashboard + * * @deprecated This controller is no longer used */ @Deprecated @@ -191,18 +185,17 @@ public static double getJoystickArmControllerLeftStickY() { } /** - * This function gets the joystick x-value of the right stick on the arm - * controller - * The right stick is used to move the arm left and right - * The function returns the value of the right stick + * This function gets the joystick x-value of the right stick on the arm controller The right + * stick is used to move the arm left and right The function returns the value of the right stick * The value of the right stick is put on the smart dashboard - * - * @deprecated The turret is no longer on the arm, and this controller is no - * longer used + * + * @deprecated The turret is no longer on the arm, and this controller is no longer used */ @Deprecated - public static double getJoystickArmControllerRightStickX() { // "do not forget to remove this deprecated code someday" - // lmao never + public static double + getJoystickArmControllerRightStickX() { // "do not forget to remove this deprecated code + // someday" + // lmao never double axis = m_armController.getRawAxis(4); SmartDashboard.putNumber("arm right stick x", axis); @@ -213,9 +206,8 @@ public static double getJoystickArmControllerRightStickX() { // "do not forget t } /** - * This function gets the y-value of the left stick on the arm controller - * The left stick is used to move the arm up and down - * The function returns the value of the left stick + * This function gets the y-value of the left stick on the arm controller The left stick is used + * to move the arm up and down The function returns the value of the left stick */ public static double getControllerLeftStickY() { double axis = m_armController2.getRawAxis(1); @@ -233,11 +225,7 @@ public static double getControllerRightStickX() { return axis; } - /** - * gets value from the right trigger axis (yes, it's an axis) for grabbing up - * the game piece - */ - + /** gets value from the right trigger axis (yes, it's an axis) for grabbing up the game piece */ public static double getClawInValue() { double axis = m_armController2.getRightTriggerAxis(); if (Math.abs(axis) < 0.01) { @@ -246,10 +234,7 @@ public static double getClawInValue() { return axis; } - /** - * gets value from the left trigger axis (yes, it's an axis) for ejecting the - * game piece - */ + /** gets value from the left trigger axis (yes, it's an axis) for ejecting the game piece */ public static double getClawOutValue() { double axis = m_armController2.getLeftTriggerAxis(); if (Math.abs(axis) < 0.01) { diff --git a/src/main/java/frc/robot/commands/AutoCommand.java b/src/main/java/frc/robot/commands/AutoCommand.java index 22a5e39..f1ac5e2 100644 --- a/src/main/java/frc/robot/commands/AutoCommand.java +++ b/src/main/java/frc/robot/commands/AutoCommand.java @@ -13,28 +13,31 @@ public class AutoCommand extends SequentialCommandGroup { public AutoCommand(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) { - //pick one - //sideAutoWCone(m_pid,m_driveBase,m_arm,m_claw); - //sideAutoWCube(m_pid,m_driveBase,m_arm,m_claw); - //middleAutoWCone(m_pid,m_driveBase,m_arm,m_claw); - //middleAutoWCube(m_pid,m_driveBase,m_arm,m_claw); + // pick one + // sideAutoWCone(m_pid,m_driveBase,m_arm,m_claw); + // sideAutoWCube(m_pid,m_driveBase,m_arm,m_claw); + // middleAutoWCone(m_pid,m_driveBase,m_arm,m_claw); + // middleAutoWCube(m_pid,m_driveBase,m_arm,m_claw); } // TODO document this - private void sideAutoWCone(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) - { + private void sideAutoWCone(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) { addCommands(new PlaceConeSecondLevelCommand(m_driveBase, m_arm, m_claw)); } - private void sideAutoWCube(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) - { + + private void sideAutoWCube(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) { addCommands(new PlaceCubeSecondLevelCommand(m_driveBase, m_arm, m_claw)); } - private void middleAutoWCone(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) - { - addCommands(new PlaceConeSecondLevelCommand(m_driveBase, m_arm, m_claw), new BalanceCommand(m_pid, m_driveBase)); + + private void middleAutoWCone(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) { + addCommands( + new PlaceConeSecondLevelCommand(m_driveBase, m_arm, m_claw), + new BalanceCommand(m_pid, m_driveBase)); } - private void middleAutoWCube(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) - { - addCommands(new PlaceCubeSecondLevelCommand(m_driveBase, m_arm, m_claw), new BalanceCommand(m_pid, m_driveBase)); + + private void middleAutoWCube(PID m_pid, Tank m_driveBase, Arm m_arm, Claw m_claw) { + addCommands( + new PlaceCubeSecondLevelCommand(m_driveBase, m_arm, m_claw), + new BalanceCommand(m_pid, m_driveBase)); } } diff --git a/src/main/java/frc/robot/commands/BalanceCommand.java b/src/main/java/frc/robot/commands/BalanceCommand.java index 7a3f962..3420169 100644 --- a/src/main/java/frc/robot/commands/BalanceCommand.java +++ b/src/main/java/frc/robot/commands/BalanceCommand.java @@ -11,11 +11,9 @@ import frc.robot.subsystems.PID; import frc.robot.subsystems.Tank; -/** - * This command balances the robot on the charge station. Default auto command. - */ +/** This command balances the robot on the charge station. Default auto command. */ public class BalanceCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final PID pidLoop; private final Tank driveBase; @@ -53,8 +51,7 @@ public void execute() { SmartDashboard.putNumber("pitch offset", pitchOffset); SmartDashboard.putBoolean("onRamp", onRamp); SmartDashboard.putNumber("max offset", maxPitch); - SmartDashboard.putNumber( - "motor speed", Constants.OperatorConstants.Pconstant * (pitchOffset)); + SmartDashboard.putNumber("motor speed", Constants.OperatorConstants.Pconstant * (pitchOffset)); /* * if (pitchOffset > maxPitch) { * maxPitch = pitchOffset; diff --git a/src/main/java/frc/robot/commands/DecreaseMaxSpeedCommand.java b/src/main/java/frc/robot/commands/DecreaseMaxSpeedCommand.java index 26c03c0..f0a3c96 100644 --- a/src/main/java/frc/robot/commands/DecreaseMaxSpeedCommand.java +++ b/src/main/java/frc/robot/commands/DecreaseMaxSpeedCommand.java @@ -9,7 +9,7 @@ /** Decrease the maximum speed of the drivebase. */ public class DecreaseMaxSpeedCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Tank m_subsystem; public DecreaseMaxSpeedCommand(Tank subsystem) { @@ -23,13 +23,10 @@ public void initialize() { } @Override - public void execute() { - - } + public void execute() {} @Override - public void end(boolean interrupted) { - } + public void end(boolean interrupted) {} @Override public boolean isFinished() { diff --git a/src/main/java/frc/robot/commands/DriveCommand.java b/src/main/java/frc/robot/commands/DriveCommand.java index 62c7397..20c6908 100644 --- a/src/main/java/frc/robot/commands/DriveCommand.java +++ b/src/main/java/frc/robot/commands/DriveCommand.java @@ -11,7 +11,7 @@ import frc.robot.subsystems.Tank; public class DriveCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Tank m_drivebase; public DriveCommand(Tank subsystem) { @@ -28,8 +28,9 @@ public void initialize() { public void execute() { // double check getMaxSpeed(), might be wrong Tank.arcadeDrive( - /* rotation */RobotContainer.getAdjustedTurningStickInput() * Constants.CanConstants.maxSpeed, - /* speed */RobotContainer.getAdjustedForwardStickInput() * 0.7); + /* rotation */ RobotContainer.getAdjustedTurningStickInput() + * Constants.CanConstants.maxSpeed, + /* speed */ RobotContainer.getAdjustedForwardStickInput() * 0.7); SmartDashboard.putNumber("maxSpeed", Constants.CanConstants.maxSpeed); } diff --git a/src/main/java/frc/robot/commands/ExampleCommand.java b/src/main/java/frc/robot/commands/ExampleCommand.java index dfcf11d..63992c9 100644 --- a/src/main/java/frc/robot/commands/ExampleCommand.java +++ b/src/main/java/frc/robot/commands/ExampleCommand.java @@ -8,7 +8,7 @@ import frc.robot.subsystems.ExampleSubsystem; public class ExampleCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField", "PMD.UnusedImport" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField", "PMD.UnusedImport"}) private final ExampleSubsystem m_subsystem; // NOPMD public ExampleCommand(ExampleSubsystem subsystem) { diff --git a/src/main/java/frc/robot/commands/FineDriveCommand.java b/src/main/java/frc/robot/commands/FineDriveCommand.java index 1370a13..6095fdd 100644 --- a/src/main/java/frc/robot/commands/FineDriveCommand.java +++ b/src/main/java/frc/robot/commands/FineDriveCommand.java @@ -9,7 +9,7 @@ import frc.robot.subsystems.Tank; public class FineDriveCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Tank m_drivebase; public FineDriveCommand(Tank subsystem) { @@ -25,8 +25,7 @@ public void initialize() { @Override public void execute() { // double check getMaxSpeed(), might be wrong - Tank.arcadeDrive( - RebindHat.ControllerToYAxis() * 0.43, RebindHat.ControllerToXAxis() * 0.43); + Tank.arcadeDrive(RebindHat.ControllerToYAxis() * 0.43, RebindHat.ControllerToXAxis() * 0.43); } @Override diff --git a/src/main/java/frc/robot/commands/IncreaseMaxSpeedCommand.java b/src/main/java/frc/robot/commands/IncreaseMaxSpeedCommand.java index eb5287c..cc0a308 100644 --- a/src/main/java/frc/robot/commands/IncreaseMaxSpeedCommand.java +++ b/src/main/java/frc/robot/commands/IncreaseMaxSpeedCommand.java @@ -8,7 +8,7 @@ import frc.robot.subsystems.Tank; public class IncreaseMaxSpeedCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Tank m_subsystem; public IncreaseMaxSpeedCommand(Tank subsystem) { @@ -22,12 +22,10 @@ public void initialize() { } @Override - public void execute() { - } + public void execute() {} @Override - public void end(boolean interrupted) { - } + public void end(boolean interrupted) {} @Override public boolean isFinished() { diff --git a/src/main/java/frc/robot/commands/InvertDriveCommand.java b/src/main/java/frc/robot/commands/InvertDriveCommand.java index b4540fd..8026f72 100644 --- a/src/main/java/frc/robot/commands/InvertDriveCommand.java +++ b/src/main/java/frc/robot/commands/InvertDriveCommand.java @@ -4,16 +4,15 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandBase; import frc.robot.Constants; -import frc.robot.Robot; import frc.robot.RobotContainer; import frc.robot.subsystems.Tank; public class InvertDriveCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Tank m_drivebase; + private final RobotContainer robot; public InvertDriveCommand(Tank subsystem, RobotContainer robot) { diff --git a/src/main/java/frc/robot/commands/MoveArmXCommand.java b/src/main/java/frc/robot/commands/MoveArmXCommand.java index 3098b2f..2049149 100644 --- a/src/main/java/frc/robot/commands/MoveArmXCommand.java +++ b/src/main/java/frc/robot/commands/MoveArmXCommand.java @@ -9,7 +9,7 @@ import frc.robot.subsystems.Turret; public class MoveArmXCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Turret m_subsystem; public MoveArmXCommand(Turret subsystem) { @@ -18,8 +18,7 @@ public MoveArmXCommand(Turret subsystem) { } @Override - public void initialize() { - } + public void initialize() {} @Override public void execute() { @@ -27,8 +26,7 @@ public void execute() { } @Override - public void end(boolean interrupted) { - } + public void end(boolean interrupted) {} @Override public boolean isFinished() { diff --git a/src/main/java/frc/robot/commands/MoveArmYCommand.java b/src/main/java/frc/robot/commands/MoveArmYCommand.java index 8559d65..cf5c3a4 100644 --- a/src/main/java/frc/robot/commands/MoveArmYCommand.java +++ b/src/main/java/frc/robot/commands/MoveArmYCommand.java @@ -9,7 +9,7 @@ import frc.robot.subsystems.Arm; public class MoveArmYCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Arm m_subsystem; public MoveArmYCommand(Arm subsystem) { @@ -18,8 +18,7 @@ public MoveArmYCommand(Arm subsystem) { } @Override - public void initialize() { - } + public void initialize() {} @Override public void execute() { @@ -27,8 +26,7 @@ public void execute() { } @Override - public void end(boolean interrupted) { - } + public void end(boolean interrupted) {} @Override public boolean isFinished() { diff --git a/src/main/java/frc/robot/commands/MoveClawCommand.java b/src/main/java/frc/robot/commands/MoveClawCommand.java index 5b8c433..07fe37e 100644 --- a/src/main/java/frc/robot/commands/MoveClawCommand.java +++ b/src/main/java/frc/robot/commands/MoveClawCommand.java @@ -9,7 +9,7 @@ import frc.robot.subsystems.Claw; public class MoveClawCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Claw m_subsystem; public MoveClawCommand(Claw subsystem) { @@ -18,8 +18,7 @@ public MoveClawCommand(Claw subsystem) { } @Override - public void initialize() { - } + public void initialize() {} @Override public void execute() { diff --git a/src/main/java/frc/robot/commands/PlaceConeSecondLevelCommand.java b/src/main/java/frc/robot/commands/PlaceConeSecondLevelCommand.java index 3ca2cde..de1d2ee 100644 --- a/src/main/java/frc/robot/commands/PlaceConeSecondLevelCommand.java +++ b/src/main/java/frc/robot/commands/PlaceConeSecondLevelCommand.java @@ -1,6 +1,6 @@ // Copyright (c) Elliot Snyder, Parker Brownlowe, and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of -// the WTFPL license file in the internet. Any questions about the mental +// the WTFPL license file in the internet. Any questions about the mental // health of the authors can be shouted into the endless void of the internet. package frc.robot.commands; @@ -9,8 +9,9 @@ import frc.robot.subsystems.*; public class PlaceConeSecondLevelCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Tank drive; + private final Claw claw; private final Arm arm; private boolean coneOut; diff --git a/src/main/java/frc/robot/commands/PlaceCubeSecondLevelCommand.java b/src/main/java/frc/robot/commands/PlaceCubeSecondLevelCommand.java index 1da8e44..7fb2b89 100644 --- a/src/main/java/frc/robot/commands/PlaceCubeSecondLevelCommand.java +++ b/src/main/java/frc/robot/commands/PlaceCubeSecondLevelCommand.java @@ -10,8 +10,9 @@ import frc.robot.subsystems.*; public class PlaceCubeSecondLevelCommand extends CommandBase { - @SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" }) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) private final Tank drive; + private final Claw claw; private final Arm arm; private GenericEntry widget; @@ -26,7 +27,6 @@ public PlaceCubeSecondLevelCommand(Tank drive, Arm arm, Claw claw) { this.claw = claw; addRequirements(drive); addRequirements(arm); - } @Override @@ -41,7 +41,10 @@ public void initialize() { finalStep = false; done = false; arm.armMotor.getEncoder().setPosition(0); - widget = Shuffleboard.getTab("stuff").add("arm thing", arm.armMotor.getEncoder().getPosition()).getEntry(); + widget = + Shuffleboard.getTab("stuff") + .add("arm thing", arm.armMotor.getEncoder().getPosition()) + .getEntry(); claw.closeClaw(); arm.armMotor.set(0.25); } @@ -72,7 +75,6 @@ public void execute() { drive.setAllMotors(0); done = true; } - } @Override @@ -87,7 +89,6 @@ public void end(boolean interrupted) { // drive.setAllMotors(0); arm.armMotor.set(0); // stop the arm motor - } @Override diff --git a/src/main/java/frc/robot/subsystems/Arm.java b/src/main/java/frc/robot/subsystems/Arm.java index 2ed7103..5e4d837 100644 --- a/src/main/java/frc/robot/subsystems/Arm.java +++ b/src/main/java/frc/robot/subsystems/Arm.java @@ -4,15 +4,13 @@ package frc.robot.subsystems; -import com.revrobotics.REVPhysicsSim; import com.revrobotics.CANSparkMax.IdleMode; import com.revrobotics.CANSparkMaxLowLevel.MotorType; - +import com.revrobotics.REVPhysicsSim; import edu.wpi.first.networktables.GenericEntry; import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.RobotBase; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.interfaces.CANSparkMax; @@ -36,7 +34,10 @@ public Arm() { armMotor.burnFlash(); addChild("Arm Motor", armMotor); - encoderWidget = Shuffleboard.getTab("Motors").add("Arm Encoder", armMotor.getEncoder().getPosition()).getEntry(); + encoderWidget = + Shuffleboard.getTab("Motors") + .add("Arm Encoder", armMotor.getEncoder().getPosition()) + .getEntry(); Shuffleboard.getTab("Motors").add("Arm", armMotor); @@ -45,7 +46,6 @@ public Arm() { physicsSim = new REVPhysicsSim(); physicsSim.addSparkMax(armMotor, 5000, 20); } - } @Override @@ -55,17 +55,14 @@ public void periodic() { encoderWidget.setDouble(armMotor.getEncoder().getPosition()); } - /** - * uses input double value to set the motor speed of the arm - */ + /** uses input double value to set the motor speed of the arm */ public void moveArm(double value) { double speed = 0.8; double motorDrive = value * speed; armMotor.set(motorDrive); } - public void moveArmToZeroDeg() { - } + public void moveArmToZeroDeg() {} @Override public void simulationPeriodic() { diff --git a/src/main/java/frc/robot/subsystems/Claw.java b/src/main/java/frc/robot/subsystems/Claw.java index d8e2e9b..11ffe31 100644 --- a/src/main/java/frc/robot/subsystems/Claw.java +++ b/src/main/java/frc/robot/subsystems/Claw.java @@ -6,12 +6,7 @@ import com.revrobotics.CANSparkMax.IdleMode; import com.revrobotics.CANSparkMaxLowLevel.MotorType; -import edu.wpi.first.networktables.GenericEntry; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; -import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; -import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets; -import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; -import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.RobotContainer; @@ -30,7 +25,6 @@ public Claw() { addChild("Claw Motor", clawMotor); Shuffleboard.getTab("Motors").add("Claw", clawMotor); - } @Override diff --git a/src/main/java/frc/robot/subsystems/ExampleSubsystem.java b/src/main/java/frc/robot/subsystems/ExampleSubsystem.java index 210f136..caaef81 100644 --- a/src/main/java/frc/robot/subsystems/ExampleSubsystem.java +++ b/src/main/java/frc/robot/subsystems/ExampleSubsystem.java @@ -8,8 +8,7 @@ public class ExampleSubsystem extends SubsystemBase { /** Creates a new ExampleSubsystem. */ - public ExampleSubsystem() { - } + public ExampleSubsystem() {} /** * Example command factory method. @@ -18,8 +17,7 @@ public ExampleSubsystem() { */ /** - * An example method querying a boolean state of the subsystem (for example, a - * digital sensor). + * An example method querying a boolean state of the subsystem (for example, a digital sensor). * * @return value of some boolean subsystem state, such as a digital sensor. */ diff --git a/src/main/java/frc/robot/subsystems/FieldConstants.java b/src/main/java/frc/robot/subsystems/FieldConstants.java index b78eab5..47f0c8b 100644 --- a/src/main/java/frc/robot/subsystems/FieldConstants.java +++ b/src/main/java/frc/robot/subsystems/FieldConstants.java @@ -18,356 +18,357 @@ import java.util.List; /** - * Contains various field dimensions and useful reference points. Dimensions are - * in meters, and sets + * Contains various field dimensions and useful reference points. Dimensions are in meters, and sets * of corners start in the lower left moving clockwise. * - *
- * All translations and poses are stored with the origin at the rightmost point - * on the BLUE - * ALLIANCE wall. Use the {@link #allianceFlip(Translation2d)} and - * {@link #allianceFlip(Pose2d)} + *
All translations and poses are stored with the origin at the rightmost point on the BLUE
+ * ALLIANCE wall. Use the {@link #allianceFlip(Translation2d)} and {@link #allianceFlip(Pose2d)}
* methods to flip these values based on the current alliance color.
*/
public final class FieldConstants {
- public static final boolean isWPIField = false; // Red alliance
+ public static final boolean isWPIField = false; // Red alliance
- public static final double fieldLength = Units.inchesToMeters(651.25);
- public static final double fieldWidth = Units.inchesToMeters(315.5)
- + (isWPIField ? Units.inchesToMeters(3.0) : 0.0);
- public static final double tapeWidth = Units.inchesToMeters(2.0);
+ public static final double fieldLength = Units.inchesToMeters(651.25);
+ public static final double fieldWidth =
+ Units.inchesToMeters(315.5) + (isWPIField ? Units.inchesToMeters(3.0) : 0.0);
+ public static final double tapeWidth = Units.inchesToMeters(2.0);
- // Dimensions for community and charging station, including the tape.
- public static final class Community {
- // Region dimensions
- public static final double innerX = 0.0;
- public static final double midX = Units.inchesToMeters(132.375); // Tape to the left of charging station
- public static final double outerX = Units.inchesToMeters(193.25); // Tape to the right of charging
- // station
- public static final double leftY = Units.feetToMeters(18.0);
- public static final double midY = leftY - Units.inchesToMeters(59.39) + tapeWidth;
- public static final double rightY = 0.0;
- public static final Translation2d[] regionCorners = new Translation2d[] {
- new Translation2d(innerX, rightY),
- new Translation2d(innerX, leftY),
- new Translation2d(midX, leftY),
- new Translation2d(midX, midY),
- new Translation2d(outerX, midY),
- new Translation2d(outerX, rightY),
- };
+ // Dimensions for community and charging station, including the tape.
+ public static final class Community {
+ // Region dimensions
+ public static final double innerX = 0.0;
+ public static final double midX =
+ Units.inchesToMeters(132.375); // Tape to the left of charging station
+ public static final double outerX =
+ Units.inchesToMeters(193.25); // Tape to the right of charging
+ // station
+ public static final double leftY = Units.feetToMeters(18.0);
+ public static final double midY = leftY - Units.inchesToMeters(59.39) + tapeWidth;
+ public static final double rightY = 0.0;
+ public static final Translation2d[] regionCorners =
+ new Translation2d[] {
+ new Translation2d(innerX, rightY),
+ new Translation2d(innerX, leftY),
+ new Translation2d(midX, leftY),
+ new Translation2d(midX, midY),
+ new Translation2d(outerX, midY),
+ new Translation2d(outerX, rightY),
+ };
- // Charging station dimensions
- public static final double chargingStationLength = Units.inchesToMeters(76.125);
- public static final double chargingStationWidth = Units.inchesToMeters(97.25);
- public static final double chargingStationOuterX = outerX - tapeWidth;
- public static final double chargingStationInnerX = chargingStationOuterX - chargingStationLength;
- public static final double chargingStationLeftY = midY - tapeWidth;
- public static final double chargingStationRightY = chargingStationLeftY - chargingStationWidth;
- public static final Translation2d[] chargingStationCorners = new Translation2d[] {
- new Translation2d(chargingStationInnerX, chargingStationRightY),
- new Translation2d(chargingStationInnerX, chargingStationLeftY),
- new Translation2d(chargingStationOuterX, chargingStationRightY),
- new Translation2d(chargingStationOuterX, chargingStationLeftY)
- };
+ // Charging station dimensions
+ public static final double chargingStationLength = Units.inchesToMeters(76.125);
+ public static final double chargingStationWidth = Units.inchesToMeters(97.25);
+ public static final double chargingStationOuterX = outerX - tapeWidth;
+ public static final double chargingStationInnerX =
+ chargingStationOuterX - chargingStationLength;
+ public static final double chargingStationLeftY = midY - tapeWidth;
+ public static final double chargingStationRightY = chargingStationLeftY - chargingStationWidth;
+ public static final Translation2d[] chargingStationCorners =
+ new Translation2d[] {
+ new Translation2d(chargingStationInnerX, chargingStationRightY),
+ new Translation2d(chargingStationInnerX, chargingStationLeftY),
+ new Translation2d(chargingStationOuterX, chargingStationRightY),
+ new Translation2d(chargingStationOuterX, chargingStationLeftY)
+ };
- // Cable bump
- public static final double cableBumpInnerX = innerX + Grids.outerX + Units.inchesToMeters(95.25);
- public static final double cableBumpOuterX = cableBumpInnerX + Units.inchesToMeters(7);
- public static final Translation2d[] cableBumpCorners = new Translation2d[] {
- new Translation2d(cableBumpInnerX, 0.0),
- new Translation2d(cableBumpInnerX, chargingStationRightY),
- new Translation2d(cableBumpOuterX, 0.0),
- new Translation2d(cableBumpOuterX, chargingStationRightY)
- };
- }
+ // Cable bump
+ public static final double cableBumpInnerX =
+ innerX + Grids.outerX + Units.inchesToMeters(95.25);
+ public static final double cableBumpOuterX = cableBumpInnerX + Units.inchesToMeters(7);
+ public static final Translation2d[] cableBumpCorners =
+ new Translation2d[] {
+ new Translation2d(cableBumpInnerX, 0.0),
+ new Translation2d(cableBumpInnerX, chargingStationRightY),
+ new Translation2d(cableBumpOuterX, 0.0),
+ new Translation2d(cableBumpOuterX, chargingStationRightY)
+ };
+ }
- // Dimensions for grids and nodes
- public static final class Grids {
- // X layout
- public static final double outerX = Units.inchesToMeters(54.25);
- public static final double lowX = outerX - (Units.inchesToMeters(14.25) / 2.0); // Centered when under
- // cube
- // nodes
- public static final double midX = outerX - Units.inchesToMeters(22.75);
- public static final double highX = outerX - Units.inchesToMeters(39.75);
+ // Dimensions for grids and nodes
+ public static final class Grids {
+ // X layout
+ public static final double outerX = Units.inchesToMeters(54.25);
+ public static final double lowX =
+ outerX - (Units.inchesToMeters(14.25) / 2.0); // Centered when under
+ // cube
+ // nodes
+ public static final double midX = outerX - Units.inchesToMeters(22.75);
+ public static final double highX = outerX - Units.inchesToMeters(39.75);
- // Y layout
- public static final int nodeRowCount = 9;
- public static final double[] nodeY = isWPIField
- ? new double[] {
- Units.inchesToMeters(20.19 + 22.0 * 0),
- Units.inchesToMeters(20.19 + 22.0 * 1),
- Units.inchesToMeters(20.19 + 22.0 * 2),
- Units.inchesToMeters(20.19 + 22.0 * 3),
- Units.inchesToMeters(20.19 + 22.0 * 4),
- Units.inchesToMeters(20.19 + 22.0 * 5),
- Units.inchesToMeters(20.19 + 22.0 * 6),
- Units.inchesToMeters(20.19 + 22.0 * 7),
- Units.inchesToMeters(20.19 + 22.0 * 8 + 2.5)
- }
- : new double[] {
- Units.inchesToMeters(20.19 + 22.0 * 0),
- Units.inchesToMeters(20.19 + 22.0 * 1),
- Units.inchesToMeters(20.19 + 22.0 * 2),
- Units.inchesToMeters(20.19 + 22.0 * 3),
- Units.inchesToMeters(20.19 + 22.0 * 4),
- Units.inchesToMeters(20.19 + 22.0 * 5),
- Units.inchesToMeters(20.19 + 22.0 * 6),
- Units.inchesToMeters(20.19 + 22.0 * 7),
- Units.inchesToMeters(20.19 + 22.0 * 8)
- };
+ // Y layout
+ public static final int nodeRowCount = 9;
+ public static final double[] nodeY =
+ isWPIField
+ ? new double[] {
+ Units.inchesToMeters(20.19 + 22.0 * 0),
+ Units.inchesToMeters(20.19 + 22.0 * 1),
+ Units.inchesToMeters(20.19 + 22.0 * 2),
+ Units.inchesToMeters(20.19 + 22.0 * 3),
+ Units.inchesToMeters(20.19 + 22.0 * 4),
+ Units.inchesToMeters(20.19 + 22.0 * 5),
+ Units.inchesToMeters(20.19 + 22.0 * 6),
+ Units.inchesToMeters(20.19 + 22.0 * 7),
+ Units.inchesToMeters(20.19 + 22.0 * 8 + 2.5)
+ }
+ : new double[] {
+ Units.inchesToMeters(20.19 + 22.0 * 0),
+ Units.inchesToMeters(20.19 + 22.0 * 1),
+ Units.inchesToMeters(20.19 + 22.0 * 2),
+ Units.inchesToMeters(20.19 + 22.0 * 3),
+ Units.inchesToMeters(20.19 + 22.0 * 4),
+ Units.inchesToMeters(20.19 + 22.0 * 5),
+ Units.inchesToMeters(20.19 + 22.0 * 6),
+ Units.inchesToMeters(20.19 + 22.0 * 7),
+ Units.inchesToMeters(20.19 + 22.0 * 8)
+ };
- // Z layout
- public static final double cubeEdgeHigh = Units.inchesToMeters(3.0);
- public static final double highCubeZ = Units.inchesToMeters(35.5) - cubeEdgeHigh;
- public static final double midCubeZ = Units.inchesToMeters(23.5) - cubeEdgeHigh;
- public static final double highConeZ = Units.inchesToMeters(46.0);
- public static final double midConeZ = Units.inchesToMeters(34.0);
+ // Z layout
+ public static final double cubeEdgeHigh = Units.inchesToMeters(3.0);
+ public static final double highCubeZ = Units.inchesToMeters(35.5) - cubeEdgeHigh;
+ public static final double midCubeZ = Units.inchesToMeters(23.5) - cubeEdgeHigh;
+ public static final double highConeZ = Units.inchesToMeters(46.0);
+ public static final double midConeZ = Units.inchesToMeters(34.0);
- // Translations (all nodes in the same column/row have the same X/Y coordinate)
- public static final Translation2d[] lowTranslations = new Translation2d[nodeRowCount];
- public static final Translation3d[] low3dTranslations = new Translation3d[nodeRowCount];
- public static final Translation2d[] midTranslations = new Translation2d[nodeRowCount];
- public static final Translation3d[] mid3dTranslations = new Translation3d[nodeRowCount];
- public static final Translation2d[] highTranslations = new Translation2d[nodeRowCount];
- public static final Translation3d[] high3dTranslations = new Translation3d[nodeRowCount];
+ // Translations (all nodes in the same column/row have the same X/Y coordinate)
+ public static final Translation2d[] lowTranslations = new Translation2d[nodeRowCount];
+ public static final Translation3d[] low3dTranslations = new Translation3d[nodeRowCount];
+ public static final Translation2d[] midTranslations = new Translation2d[nodeRowCount];
+ public static final Translation3d[] mid3dTranslations = new Translation3d[nodeRowCount];
+ public static final Translation2d[] highTranslations = new Translation2d[nodeRowCount];
+ public static final Translation3d[] high3dTranslations = new Translation3d[nodeRowCount];
- static {
- for (int i = 0; i < nodeRowCount; i++) {
- boolean isCube = i == 1 || i == 4 || i == 7;
- lowTranslations[i] = new Translation2d(lowX, nodeY[i]);
- low3dTranslations[i] = new Translation3d(lowX, nodeY[i], 0.0);
- midTranslations[i] = new Translation2d(midX, nodeY[i]);
- mid3dTranslations[i] = new Translation3d(midX, nodeY[i], isCube ? midCubeZ : midConeZ);
- highTranslations[i] = new Translation2d(highX, nodeY[i]);
- high3dTranslations[i] = new Translation3d(highX, nodeY[i],
- isCube ? highCubeZ : highConeZ);
- }
- }
+ static {
+ for (int i = 0; i < nodeRowCount; i++) {
+ boolean isCube = i == 1 || i == 4 || i == 7;
+ lowTranslations[i] = new Translation2d(lowX, nodeY[i]);
+ low3dTranslations[i] = new Translation3d(lowX, nodeY[i], 0.0);
+ midTranslations[i] = new Translation2d(midX, nodeY[i]);
+ mid3dTranslations[i] = new Translation3d(midX, nodeY[i], isCube ? midCubeZ : midConeZ);
+ highTranslations[i] = new Translation2d(highX, nodeY[i]);
+ high3dTranslations[i] = new Translation3d(highX, nodeY[i], isCube ? highCubeZ : highConeZ);
+ }
+ }
- // Complex low layout (shifted to account for cube vs cone rows and wide edge
- // nodes)
- public static final double complexLowXCones = outerX - Units.inchesToMeters(16.0) / 2.0; // Centered X
- // under
- // cone nodes
- public static final double complexLowXCubes = lowX; // Centered X under cube nodes
- public static final double complexLowOuterYOffset = nodeY[0]
- - (Units.inchesToMeters(3.0) + (Units.inchesToMeters(25.75) / 2.0));
+ // Complex low layout (shifted to account for cube vs cone rows and wide edge
+ // nodes)
+ public static final double complexLowXCones =
+ outerX - Units.inchesToMeters(16.0) / 2.0; // Centered X
+ // under
+ // cone nodes
+ public static final double complexLowXCubes = lowX; // Centered X under cube nodes
+ public static final double complexLowOuterYOffset =
+ nodeY[0] - (Units.inchesToMeters(3.0) + (Units.inchesToMeters(25.75) / 2.0));
- public static final Translation2d[] complexLowTranslations = new Translation2d[] {
- new Translation2d(complexLowXCones, nodeY[0] - complexLowOuterYOffset),
- new Translation2d(complexLowXCubes, nodeY[1]),
- new Translation2d(complexLowXCones, nodeY[2]),
- new Translation2d(complexLowXCones, nodeY[3]),
- new Translation2d(complexLowXCubes, nodeY[4]),
- new Translation2d(complexLowXCones, nodeY[5]),
- new Translation2d(complexLowXCones, nodeY[6]),
- new Translation2d(complexLowXCubes, nodeY[7]),
- new Translation2d(complexLowXCones, nodeY[8] + complexLowOuterYOffset),
- };
+ public static final Translation2d[] complexLowTranslations =
+ new Translation2d[] {
+ new Translation2d(complexLowXCones, nodeY[0] - complexLowOuterYOffset),
+ new Translation2d(complexLowXCubes, nodeY[1]),
+ new Translation2d(complexLowXCones, nodeY[2]),
+ new Translation2d(complexLowXCones, nodeY[3]),
+ new Translation2d(complexLowXCubes, nodeY[4]),
+ new Translation2d(complexLowXCones, nodeY[5]),
+ new Translation2d(complexLowXCones, nodeY[6]),
+ new Translation2d(complexLowXCubes, nodeY[7]),
+ new Translation2d(complexLowXCones, nodeY[8] + complexLowOuterYOffset),
+ };
- public static final Translation3d[] complexLow3dTranslations = new Translation3d[] {
- new Translation3d(complexLowXCones, nodeY[0] - complexLowOuterYOffset, 0.0),
- new Translation3d(complexLowXCubes, nodeY[1], 0.0),
- new Translation3d(complexLowXCones, nodeY[2], 0.0),
- new Translation3d(complexLowXCones, nodeY[3], 0.0),
- new Translation3d(complexLowXCubes, nodeY[4], 0.0),
- new Translation3d(complexLowXCones, nodeY[5], 0.0),
- new Translation3d(complexLowXCones, nodeY[6], 0.0),
- new Translation3d(complexLowXCubes, nodeY[7], 0.0),
- new Translation3d(complexLowXCones, nodeY[8] + complexLowOuterYOffset, 0.0),
- };
- }
+ public static final Translation3d[] complexLow3dTranslations =
+ new Translation3d[] {
+ new Translation3d(complexLowXCones, nodeY[0] - complexLowOuterYOffset, 0.0),
+ new Translation3d(complexLowXCubes, nodeY[1], 0.0),
+ new Translation3d(complexLowXCones, nodeY[2], 0.0),
+ new Translation3d(complexLowXCones, nodeY[3], 0.0),
+ new Translation3d(complexLowXCubes, nodeY[4], 0.0),
+ new Translation3d(complexLowXCones, nodeY[5], 0.0),
+ new Translation3d(complexLowXCones, nodeY[6], 0.0),
+ new Translation3d(complexLowXCubes, nodeY[7], 0.0),
+ new Translation3d(complexLowXCones, nodeY[8] + complexLowOuterYOffset, 0.0),
+ };
+ }
- // Dimensions for loading zone and substations, including the tape
- public static final class LoadingZone {
- // Region dimensions
- public static final double width = Units.inchesToMeters(99.0);
- public static final double innerX = FieldConstants.fieldLength;
- public static final double midX = fieldLength - Units.inchesToMeters(132.25);
- public static final double outerX = fieldLength - Units.inchesToMeters(264.25);
- public static final double leftY = FieldConstants.fieldWidth;
- public static final double midY = leftY - Units.inchesToMeters(50.5);
- public static final double rightY = leftY - width;
- public static final Translation2d[] regionCorners = new Translation2d[] {
- new Translation2d(
- midX, rightY), // Start at lower left next to border with opponent
- // community
- new Translation2d(midX, midY),
- new Translation2d(outerX, midY),
- new Translation2d(outerX, leftY),
- new Translation2d(innerX, leftY),
- new Translation2d(innerX, rightY),
- };
+ // Dimensions for loading zone and substations, including the tape
+ public static final class LoadingZone {
+ // Region dimensions
+ public static final double width = Units.inchesToMeters(99.0);
+ public static final double innerX = FieldConstants.fieldLength;
+ public static final double midX = fieldLength - Units.inchesToMeters(132.25);
+ public static final double outerX = fieldLength - Units.inchesToMeters(264.25);
+ public static final double leftY = FieldConstants.fieldWidth;
+ public static final double midY = leftY - Units.inchesToMeters(50.5);
+ public static final double rightY = leftY - width;
+ public static final Translation2d[] regionCorners =
+ new Translation2d[] {
+ new Translation2d(midX, rightY), // Start at lower left next to border with opponent
+ // community
+ new Translation2d(midX, midY),
+ new Translation2d(outerX, midY),
+ new Translation2d(outerX, leftY),
+ new Translation2d(innerX, leftY),
+ new Translation2d(innerX, rightY),
+ };
- // Double substation dimensions
- public static final double doubleSubstationLength = Units.inchesToMeters(14.0);
- public static final double doubleSubstationX = innerX - doubleSubstationLength;
- public static final double doubleSubstationShelfZ = Units.inchesToMeters(37.375);
- public static final double doubleSubstationCenterY = fieldWidth - Units.inchesToMeters(49.76);
+ // Double substation dimensions
+ public static final double doubleSubstationLength = Units.inchesToMeters(14.0);
+ public static final double doubleSubstationX = innerX - doubleSubstationLength;
+ public static final double doubleSubstationShelfZ = Units.inchesToMeters(37.375);
+ public static final double doubleSubstationCenterY = fieldWidth - Units.inchesToMeters(49.76);
- // Single substation dimensions
- public static final double singleSubstationWidth = Units.inchesToMeters(22.75);
- public static final double singleSubstationLeftX = FieldConstants.fieldLength - doubleSubstationLength
- - Units.inchesToMeters(88.77);
- public static final double singleSubstationCenterX = singleSubstationLeftX
- + (singleSubstationWidth / 2.0);
- public static final double singleSubstationRightX = singleSubstationLeftX + singleSubstationWidth;
- public static final Translation2d singleSubstationTranslation = new Translation2d(
- singleSubstationCenterX,
- leftY);
+ // Single substation dimensions
+ public static final double singleSubstationWidth = Units.inchesToMeters(22.75);
+ public static final double singleSubstationLeftX =
+ FieldConstants.fieldLength - doubleSubstationLength - Units.inchesToMeters(88.77);
+ public static final double singleSubstationCenterX =
+ singleSubstationLeftX + (singleSubstationWidth / 2.0);
+ public static final double singleSubstationRightX =
+ singleSubstationLeftX + singleSubstationWidth;
+ public static final Translation2d singleSubstationTranslation =
+ new Translation2d(singleSubstationCenterX, leftY);
- public static final double singleSubstationHeight = Units.inchesToMeters(18.0);
- public static final double singleSubstationLowZ = Units.inchesToMeters(27.125);
- public static final double singleSubstationCenterZ = singleSubstationLowZ
- + (singleSubstationHeight / 2.0);
- public static final double singleSubstationHighZ = singleSubstationLowZ + singleSubstationHeight;
- }
+ public static final double singleSubstationHeight = Units.inchesToMeters(18.0);
+ public static final double singleSubstationLowZ = Units.inchesToMeters(27.125);
+ public static final double singleSubstationCenterZ =
+ singleSubstationLowZ + (singleSubstationHeight / 2.0);
+ public static final double singleSubstationHighZ =
+ singleSubstationLowZ + singleSubstationHeight;
+ }
- // Locations of staged game pieces
- public static final class StagingLocations {
- public static final double centerOffsetX = Units.inchesToMeters(47.36);
- public static final double positionX = fieldLength / 2.0 - Units.inchesToMeters(47.36);
- public static final double firstY = Units.inchesToMeters(36.19);
- public static final double separationY = Units.inchesToMeters(48.0);
- public static final Translation2d[] translations = new Translation2d[4];
+ // Locations of staged game pieces
+ public static final class StagingLocations {
+ public static final double centerOffsetX = Units.inchesToMeters(47.36);
+ public static final double positionX = fieldLength / 2.0 - Units.inchesToMeters(47.36);
+ public static final double firstY = Units.inchesToMeters(36.19);
+ public static final double separationY = Units.inchesToMeters(48.0);
+ public static final Translation2d[] translations = new Translation2d[4];
- static {
- for (int i = 0; i < translations.length; i++) {
- translations[i] = new Translation2d(positionX, firstY + (i * separationY));
- }
- }
- }
+ static {
+ for (int i = 0; i < translations.length; i++) {
+ translations[i] = new Translation2d(positionX, firstY + (i * separationY));
+ }
+ }
+ }
- // AprilTag constants
- public static final double aprilTagWidth = Units.inchesToMeters(6.0);
- public static final AprilTagFieldLayout aprilTags = isWPIField
- ? new AprilTagFieldLayout(
- List.of(
- new AprilTag(
- 1,
- new Pose3d(
- Units.inchesToMeters(610.125),
- Units.inchesToMeters(43.5),
- Units.inchesToMeters(19.25),
- new Rotation3d(0.0, 0.0,
- Math.PI))),
- new AprilTag(
- 2,
- new Pose3d(
- Units.inchesToMeters(610.375),
- Units.inchesToMeters(109.5),
- Units.inchesToMeters(19.25),
- new Rotation3d(0.0, 0.0,
- Math.PI))),
- new AprilTag(
- 3,
- new Pose3d(
- Units.inchesToMeters(610.0),
- Units.inchesToMeters(176.0),
- Units.inchesToMeters(19.25),
- new Rotation3d(0.0, 0.0,
- Math.PI))),
- new AprilTag(
- 4,
- new Pose3d(
- Units.inchesToMeters(635.375),
- Units.inchesToMeters(272.0),
- Units.inchesToMeters(27.25),
- new Rotation3d(0.0, 0.0,
- Math.PI))),
- new AprilTag(
- 5,
- new Pose3d(
- Units.inchesToMeters(14.25),
- LoadingZone.doubleSubstationCenterY,
- Units.inchesToMeters(27.38),
- new Rotation3d())),
- new AprilTag(
- 6,
- new Pose3d(
- Units.inchesToMeters(40.45),
- Grids.nodeY[7],
- Units.inchesToMeters(18.22),
- new Rotation3d())),
- new AprilTag(
- 7,
- new Pose3d(
- Units.inchesToMeters(40.45),
- Grids.nodeY[4],
- Units.inchesToMeters(18.22),
- new Rotation3d())),
- new AprilTag(
- 8,
- new Pose3d(
- Units.inchesToMeters(40.45),
- Grids.nodeY[1],
- Units.inchesToMeters(18.22),
- new Rotation3d()))),
- fieldLength,
- fieldWidth)
- : new AprilTagFieldLayout(
- List.of(
- new AprilTag(
- 1,
- new Pose3d(
- Units.inchesToMeters(610.77),
- Grids.nodeY[1],
- Units.inchesToMeters(18.22),
- new Rotation3d(0.0, 0.0,
- Math.PI))),
- new AprilTag(
- 2,
- new Pose3d(
- Units.inchesToMeters(610.77),
- Grids.nodeY[4],
- Units.inchesToMeters(18.22),
- new Rotation3d(0.0, 0.0,
- Math.PI))),
- new AprilTag(
- 3,
- new Pose3d(
- Units.inchesToMeters(610.77),
- Grids.nodeY[7],
- Units.inchesToMeters(18.22),
- new Rotation3d(0.0, 0.0,
- Math.PI))),
- new AprilTag(
- 4,
- new Pose3d(
- Units.inchesToMeters(636.96),
- LoadingZone.doubleSubstationCenterY,
- Units.inchesToMeters(27.38),
- new Rotation3d(0.0, 0.0,
- Math.PI))),
- new AprilTag(
- 5,
- new Pose3d(
- Units.inchesToMeters(14.25),
- LoadingZone.doubleSubstationCenterY,
- Units.inchesToMeters(27.38),
- new Rotation3d())),
- new AprilTag(
- 6,
- new Pose3d(
- Units.inchesToMeters(40.45),
- Grids.nodeY[7],
- Units.inchesToMeters(18.22),
- new Rotation3d())),
- new AprilTag(
- 7,
- new Pose3d(
- Units.inchesToMeters(40.45),
- Grids.nodeY[4],
- Units.inchesToMeters(18.22),
- new Rotation3d())),
- new AprilTag(
- 8,
- new Pose3d(
- Units.inchesToMeters(40.45),
- Grids.nodeY[1],
- Units.inchesToMeters(18.22),
- new Rotation3d()))),
- fieldLength,
- fieldWidth);
-}
\ No newline at end of file
+ // AprilTag constants
+ public static final double aprilTagWidth = Units.inchesToMeters(6.0);
+ public static final AprilTagFieldLayout aprilTags =
+ isWPIField
+ ? new AprilTagFieldLayout(
+ List.of(
+ new AprilTag(
+ 1,
+ new Pose3d(
+ Units.inchesToMeters(610.125),
+ Units.inchesToMeters(43.5),
+ Units.inchesToMeters(19.25),
+ new Rotation3d(0.0, 0.0, Math.PI))),
+ new AprilTag(
+ 2,
+ new Pose3d(
+ Units.inchesToMeters(610.375),
+ Units.inchesToMeters(109.5),
+ Units.inchesToMeters(19.25),
+ new Rotation3d(0.0, 0.0, Math.PI))),
+ new AprilTag(
+ 3,
+ new Pose3d(
+ Units.inchesToMeters(610.0),
+ Units.inchesToMeters(176.0),
+ Units.inchesToMeters(19.25),
+ new Rotation3d(0.0, 0.0, Math.PI))),
+ new AprilTag(
+ 4,
+ new Pose3d(
+ Units.inchesToMeters(635.375),
+ Units.inchesToMeters(272.0),
+ Units.inchesToMeters(27.25),
+ new Rotation3d(0.0, 0.0, Math.PI))),
+ new AprilTag(
+ 5,
+ new Pose3d(
+ Units.inchesToMeters(14.25),
+ LoadingZone.doubleSubstationCenterY,
+ Units.inchesToMeters(27.38),
+ new Rotation3d())),
+ new AprilTag(
+ 6,
+ new Pose3d(
+ Units.inchesToMeters(40.45),
+ Grids.nodeY[7],
+ Units.inchesToMeters(18.22),
+ new Rotation3d())),
+ new AprilTag(
+ 7,
+ new Pose3d(
+ Units.inchesToMeters(40.45),
+ Grids.nodeY[4],
+ Units.inchesToMeters(18.22),
+ new Rotation3d())),
+ new AprilTag(
+ 8,
+ new Pose3d(
+ Units.inchesToMeters(40.45),
+ Grids.nodeY[1],
+ Units.inchesToMeters(18.22),
+ new Rotation3d()))),
+ fieldLength,
+ fieldWidth)
+ : new AprilTagFieldLayout(
+ List.of(
+ new AprilTag(
+ 1,
+ new Pose3d(
+ Units.inchesToMeters(610.77),
+ Grids.nodeY[1],
+ Units.inchesToMeters(18.22),
+ new Rotation3d(0.0, 0.0, Math.PI))),
+ new AprilTag(
+ 2,
+ new Pose3d(
+ Units.inchesToMeters(610.77),
+ Grids.nodeY[4],
+ Units.inchesToMeters(18.22),
+ new Rotation3d(0.0, 0.0, Math.PI))),
+ new AprilTag(
+ 3,
+ new Pose3d(
+ Units.inchesToMeters(610.77),
+ Grids.nodeY[7],
+ Units.inchesToMeters(18.22),
+ new Rotation3d(0.0, 0.0, Math.PI))),
+ new AprilTag(
+ 4,
+ new Pose3d(
+ Units.inchesToMeters(636.96),
+ LoadingZone.doubleSubstationCenterY,
+ Units.inchesToMeters(27.38),
+ new Rotation3d(0.0, 0.0, Math.PI))),
+ new AprilTag(
+ 5,
+ new Pose3d(
+ Units.inchesToMeters(14.25),
+ LoadingZone.doubleSubstationCenterY,
+ Units.inchesToMeters(27.38),
+ new Rotation3d())),
+ new AprilTag(
+ 6,
+ new Pose3d(
+ Units.inchesToMeters(40.45),
+ Grids.nodeY[7],
+ Units.inchesToMeters(18.22),
+ new Rotation3d())),
+ new AprilTag(
+ 7,
+ new Pose3d(
+ Units.inchesToMeters(40.45),
+ Grids.nodeY[4],
+ Units.inchesToMeters(18.22),
+ new Rotation3d())),
+ new AprilTag(
+ 8,
+ new Pose3d(
+ Units.inchesToMeters(40.45),
+ Grids.nodeY[1],
+ Units.inchesToMeters(18.22),
+ new Rotation3d()))),
+ fieldLength,
+ fieldWidth);
+}
diff --git a/src/main/java/frc/robot/subsystems/PDP.java b/src/main/java/frc/robot/subsystems/PDP.java
index f356923..6825eab 100644
--- a/src/main/java/frc/robot/subsystems/PDP.java
+++ b/src/main/java/frc/robot/subsystems/PDP.java
@@ -1,15 +1,13 @@
package frc.robot.subsystems;
import edu.wpi.first.wpilibj.PowerDistribution;
-import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.PowerDistribution.ModuleType;
+import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
import edu.wpi.first.wpilibj.shuffleboard.ComplexWidget;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
-import edu.wpi.first.wpilibj.simulation.BatterySim;
import edu.wpi.first.wpilibj.simulation.PDPSim;
-import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class PDP extends SubsystemBase {
@@ -28,7 +26,6 @@ public PDP() {
if (!RobotBase.isReal()) {
// this is a simulation, so add a simulated PDP
pdpSim = new PDPSim(pdp);
-
}
}
@@ -53,18 +50,13 @@ public double getTemperature() {
}
/**
- * @param param the channel to get the current from, or any string to get the
- * total current
- * @return the current drawn from the specified channel, or all channels, in
- * Amps
+ * @param param the channel to get the current from, or any string to get the total current
+ * @return the current drawn from the specified channel, or all channels, in Amps
*/
public double getCurrent(Object param) {
- if (param instanceof Integer)
- return pdp.getCurrent((int) param);
- else if (param instanceof String)
- return pdp.getTotalCurrent();
- else
- return 0;
+ if (param instanceof Integer) return pdp.getCurrent((int) param);
+ else if (param instanceof String) return pdp.getTotalCurrent();
+ else return 0;
}
/**
diff --git a/src/main/java/frc/robot/subsystems/PID.java b/src/main/java/frc/robot/subsystems/PID.java
index 086327a..a5e4f78 100644
--- a/src/main/java/frc/robot/subsystems/PID.java
+++ b/src/main/java/frc/robot/subsystems/PID.java
@@ -1,10 +1,7 @@
package frc.robot.subsystems;
import com.kauailabs.navx.frc.AHRS;
-import edu.wpi.first.math.controller.PIDController;
-import edu.wpi.first.wpilibj.SPI;
import edu.wpi.first.wpilibj.Timer;
-import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
@@ -30,7 +27,6 @@ public PID() {
iLimit = 2.0;
initPitch = gyro.getPitch();
-
}
@Override
@@ -79,6 +75,5 @@ private float getPitchOffset() {
}
@Override
- public void simulationPeriodic() {
- }
+ public void simulationPeriodic() {}
}
diff --git a/src/main/java/frc/robot/subsystems/Tank.java b/src/main/java/frc/robot/subsystems/Tank.java
index 3fd1239..23a9675 100644
--- a/src/main/java/frc/robot/subsystems/Tank.java
+++ b/src/main/java/frc/robot/subsystems/Tank.java
@@ -1,14 +1,15 @@
package frc.robot.subsystems;
import com.kauailabs.navx.frc.AHRS;
-import com.revrobotics.REVPhysicsSim;
import com.revrobotics.CANSparkMax.IdleMode;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
-
+import com.revrobotics.REVPhysicsSim;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.kinematics.DifferentialDriveOdometry;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.networktables.GenericEntry;
+import edu.wpi.first.wpilibj.RobotBase;
+import edu.wpi.first.wpilibj.SPI;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;
import edu.wpi.first.wpilibj.shuffleboard.*;
@@ -18,8 +19,6 @@
import frc.robot.Constants;
import frc.robot.RobotContainer;
import frc.robot.interfaces.*;
-import edu.wpi.first.wpilibj.RobotBase;
-import edu.wpi.first.wpilibj.SPI;
public class Tank extends SubsystemBase {
public CANSparkMax leftFront;
@@ -149,13 +148,17 @@ public Tank() {
rightRear.setSmartCurrentLimit(40, 50);
// implement odometry
- odometry = new DifferentialDriveOdometry(Rotation2d.fromDegrees(gyro.getAngle()),
- Units.inchesToMeters(
- (leftFront.getEncoder().getPosition() / 10) * (leftFront.getEncoder().getPosition() / 10)
- * Math.PI),
- Units.inchesToMeters(
- (rightFront.getEncoder().getPosition() / 10) * (rightFront.getEncoder().getPosition() / 10)
- * Math.PI));
+ odometry =
+ new DifferentialDriveOdometry(
+ Rotation2d.fromDegrees(gyro.getAngle()),
+ Units.inchesToMeters(
+ (leftFront.getEncoder().getPosition() / 10)
+ * (leftFront.getEncoder().getPosition() / 10)
+ * Math.PI),
+ Units.inchesToMeters(
+ (rightFront.getEncoder().getPosition() / 10)
+ * (rightFront.getEncoder().getPosition() / 10)
+ * Math.PI));
field2d = new Field2d();
SmartDashboard.putData(field2d);
@@ -171,7 +174,6 @@ public Tank() {
// run the simulation
physicsSim.run();
}
-
}
@Override
@@ -181,12 +183,15 @@ public void periodic() {
// i hate my life
- odometry.update(Rotation2d.fromDegrees(gyro.getAngle()),
+ odometry.update(
+ Rotation2d.fromDegrees(gyro.getAngle()),
Units.inchesToMeters(
- (leftFront.getEncoder().getPosition() / 10) * (leftFront.getEncoder().getPosition() / 10)
+ (leftFront.getEncoder().getPosition() / 10)
+ * (leftFront.getEncoder().getPosition() / 10)
* Math.PI),
Units.inchesToMeters(
- (rightFront.getEncoder().getPosition() / 10) * (rightFront.getEncoder().getPosition() / 10)
+ (rightFront.getEncoder().getPosition() / 10)
+ * (rightFront.getEncoder().getPosition() / 10)
* Math.PI));
field2d.setRobotPose(odometry.getPoseMeters());
@@ -199,14 +204,13 @@ public double getMaxSpeed() {
/**
* Drives the robot using arcade drive.
*
- * @param speed The forward/backward speed.
+ * @param speed The forward/backward speed.
* @param rotation The rotation speed.
*/
public static void arcadeDrive(double speed, double rotation) {
drive.arcadeDrive(
-speed * Math.pow(Math.abs(speed), 0.5), rotation * Math.pow(Math.abs(rotation), 0.5));
-
}
public void increaseMaxSpeed() {
@@ -262,7 +266,6 @@ public void setRampRate(double rampRate) {
leftRear.setOpenLoopRampRate(rampRate);
rightFront.setOpenLoopRampRate(rampRate);
rightRear.setOpenLoopRampRate(rampRate);
-
}
// for some reason -speed is forward. dont ask me why
@@ -272,17 +275,18 @@ public void setAllMotors(double speed) {
leftRear.set(-speed);
rightFront.set(-speed);
rightRear.set(-speed);
-
}
public double getLeftDistance() {
- double numRotations = (leftFront.getEncoder().getPosition() + leftRear.getEncoder().getPosition()) / 2;
+ double numRotations =
+ (leftFront.getEncoder().getPosition() + leftRear.getEncoder().getPosition()) / 2;
return -numRotations
* Constants.AutoConstants.encoderFactor; // This is flipped to make forward positive
}
public double getRightDistance() {
- double numRotations = (rightFront.getEncoder().getPosition() + rightRear.getEncoder().getPosition()) / 2;
+ double numRotations =
+ (rightFront.getEncoder().getPosition() + rightRear.getEncoder().getPosition()) / 2;
return -numRotations
* Constants.AutoConstants.encoderFactor; // This is flipped to make forward positive
}
diff --git a/src/main/java/frc/robot/subsystems/Vision.java b/src/main/java/frc/robot/subsystems/Vision.java
index b5f9637..e93a06c 100644
--- a/src/main/java/frc/robot/subsystems/Vision.java
+++ b/src/main/java/frc/robot/subsystems/Vision.java
@@ -21,16 +21,20 @@ public class Vision extends SubsystemBase {
private double goalHeightInches = 24.125;
private double angleToGoalRadians = limelightMountAngleDegrees + targetOffsetAngle_Vertical;
private double angleToGoalDegrees = Units.radiansToDegrees(angleToGoalRadians);
- private double distanceFromLimelightToGoalInches = (goalHeightInches - limelightLensHeightInches)
- / Math.tan(angleToGoalRadians);
+ private double distanceFromLimelightToGoalInches =
+ (goalHeightInches - limelightLensHeightInches) / Math.tan(angleToGoalRadians);
public GenericEntry widget;
public Vision() {
// Stuff goes here
- widget = Shuffleboard.getTab("stuff")
- .add("distance",
- -(goalHeightInches - limelightLensHeightInches) / Math.tan(limelightMountAngleDegrees + ty.getDouble(0)))
- .withWidget(BuiltInWidgets.kGraph).getEntry();
+ widget =
+ Shuffleboard.getTab("stuff")
+ .add(
+ "distance",
+ -(goalHeightInches - limelightLensHeightInches)
+ / Math.tan(limelightMountAngleDegrees + ty.getDouble(0)))
+ .withWidget(BuiltInWidgets.kGraph)
+ .getEntry();
}
// display camera on shuffleboard
@@ -39,8 +43,8 @@ public Vision() {
public void periodic() {
// This method will be called once per scheduler run
widget.setDouble(
- -(goalHeightInches - limelightLensHeightInches) / Math.tan(limelightMountAngleDegrees + ty.getDouble(0)));
-
+ -(goalHeightInches - limelightLensHeightInches)
+ / Math.tan(limelightMountAngleDegrees + ty.getDouble(0)));
}
@Override
@@ -54,7 +58,8 @@ public void simulationPeriodic() {
* @param property The property to fetch.
* @return The fetched property.
*/
- public double[] getProperties() { // we don't know what type we return until we process it in the if statement
+ public double[]
+ getProperties() { // we don't know what type we return until we process it in the if statement
//
var tx = NetworkTableInstance.getDefault().getTable("limelight").getEntry("tx").getDouble(0);
var ty = NetworkTableInstance.getDefault().getTable("limelight").getEntry("ty").getDouble(0);
@@ -62,11 +67,15 @@ public double[] getProperties() { // we don't know what type we return until we
var ta = NetworkTableInstance.getDefault().getTable("limelight").getEntry("ta").getDouble(0);
var tl = NetworkTableInstance.getDefault().getTable("limelight").getEntry("tl").getDouble(0);
var cl = NetworkTableInstance.getDefault().getTable("limelight").getEntry("cl").getDouble(0);
- var tshort = NetworkTableInstance.getDefault().getTable("limelight").getEntry("tshort").getDouble(0);
- var tlong = NetworkTableInstance.getDefault().getTable("limelight").getEntry("tlong").getDouble(0);
- var thor = NetworkTableInstance.getDefault().getTable("limelight").getEntry("thor").getDouble(0);
- var tvert = NetworkTableInstance.getDefault().getTable("limelight").getEntry("tvert").getDouble(0);
+ var tshort =
+ NetworkTableInstance.getDefault().getTable("limelight").getEntry("tshort").getDouble(0);
+ var tlong =
+ NetworkTableInstance.getDefault().getTable("limelight").getEntry("tlong").getDouble(0);
+ var thor =
+ NetworkTableInstance.getDefault().getTable("limelight").getEntry("thor").getDouble(0);
+ var tvert =
+ NetworkTableInstance.getDefault().getTable("limelight").getEntry("tvert").getDouble(0);
- return new double[] { tx, ty, tv, ta, tl, cl, tshort, tlong, thor, tvert };
+ return new double[] {tx, ty, tv, ta, tl, cl, tshort, tlong, thor, tvert};
}
}
diff --git a/src/main/java/frc/robot/util/limelight/LEDMode.java b/src/main/java/frc/robot/util/limelight/LEDMode.java
index 4b760f1..5fd1eeb 100644
--- a/src/main/java/frc/robot/util/limelight/LEDMode.java
+++ b/src/main/java/frc/robot/util/limelight/LEDMode.java
@@ -3,26 +3,26 @@
import java.util.Objects;
public enum LEDMode {
- PIPELINE(0),
- OFF(1),
- BLINK(2),
- ON(3);
- private int value;
+ PIPELINE(0),
+ OFF(1),
+ BLINK(2),
+ ON(3);
+ private int value;
- LEDMode(int value) {
- this.value = value;
- }
+ LEDMode(int value) {
+ this.value = value;
+ }
- public int getValue() {
- return value;
- }
+ public int getValue() {
+ return value;
+ }
- public static LEDMode fromValue(int value) {
- for (LEDMode ledMode : LEDMode.values()) {
- if (Objects.equals(ledMode.value, value)) {
- return ledMode;
- }
- }
- return null;
+ public static LEDMode fromValue(int value) {
+ for (LEDMode ledMode : LEDMode.values()) {
+ if (Objects.equals(ledMode.value, value)) {
+ return ledMode;
+ }
}
+ return null;
+ }
}
diff --git a/src/main/java/frc/robot/util/limelight/Limelight.java b/src/main/java/frc/robot/util/limelight/Limelight.java
index ce8974c..10915fa 100644
--- a/src/main/java/frc/robot/util/limelight/Limelight.java
+++ b/src/main/java/frc/robot/util/limelight/Limelight.java
@@ -3,93 +3,92 @@
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
-
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
public class Limelight {
- private NetworkTable table;
- private NetworkTableEntry tv;
- private NetworkTableEntry tx;
- private NetworkTableEntry ty;
- private NetworkTableEntry ta;
- private NetworkTableEntry ts;
- private NetworkTableEntry tl;
- private NetworkTableEntry ledMode;
- private NetworkTableEntry pipeline;
- private NetworkTableEntry stream;
- private List