From 464210910662e632482262b1a3ba665a633c7c3d Mon Sep 17 00:00:00 2001 From: Hayden Heroux Date: Sat, 27 Apr 2024 12:59:52 -0400 Subject: [PATCH] refactor: Clean up robot constants. --- src/main/java/frc/robot/RobotConstants.java | 23 +++------------- .../SuperstructureMechanism.java | 26 +++++++++---------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/main/java/frc/robot/RobotConstants.java b/src/main/java/frc/robot/RobotConstants.java index 37dd4d4..5cf5189 100644 --- a/src/main/java/frc/robot/RobotConstants.java +++ b/src/main/java/frc/robot/RobotConstants.java @@ -1,6 +1,5 @@ package frc.robot; -import edu.wpi.first.math.util.Units; import java.util.EnumSet; import java.util.Set; @@ -13,22 +12,7 @@ public class RobotConstants { /** Duration of each robot periodic call in seconds. */ public static final double PERIODIC_DURATION = 1.0 / PERIODIC_RATE; - /** Voltage of the robot's battery, */ - public static final double BATTERY_VOLTAGE = 12.0; - - /** Distance from the frame perimeter to the origin in meters. */ - public static final double FRAME_PERIMETER_TO_ORIGIN_DISTANCE = Units.inchesToMeters(14); - - /** Maximum horizontal extension distance in meters. */ - public static final double MAX_HORIZONTAL_EXTENSION_DISTANCE = Units.feetToMeters(1); - - /** Maximum vertical extension distance in meters. */ - public static final double MAX_VERTICAL_EXTENSION_DISTANCE = Units.inchesToMeters(48); - - /** If true, provide additional information using telemetry. */ - public static final boolean USE_TELEMETRY = true; - - /** Robot subsystems. */ + /** Subsystems. */ public enum Subsystem { ARM, INTAKE, @@ -37,9 +21,8 @@ public enum Subsystem { SWERVE, } - public static final Set ALL_SUBSYSTEMS = + /** Real subsystems. */ + public static final Set REAL_SUBSYSTEMS = EnumSet.of( Subsystem.ARM, Subsystem.INTAKE, Subsystem.ODOMETRY, Subsystem.SHOOTER, Subsystem.SWERVE); - - public static final Set REAL_SUBSYSTEMS = ALL_SUBSYSTEMS; } diff --git a/src/main/java/frc/robot/superstructure/SuperstructureMechanism.java b/src/main/java/frc/robot/superstructure/SuperstructureMechanism.java index b75a9c6..6fb1182 100644 --- a/src/main/java/frc/robot/superstructure/SuperstructureMechanism.java +++ b/src/main/java/frc/robot/superstructure/SuperstructureMechanism.java @@ -8,7 +8,6 @@ import edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d; import edu.wpi.first.wpilibj.util.Color; import edu.wpi.first.wpilibj.util.Color8Bit; -import frc.robot.RobotConstants; /** Superstructure mechanism renderer. */ public class SuperstructureMechanism { @@ -22,14 +21,21 @@ public class SuperstructureMechanism { /** Superstructure mechanism ligaments. */ private MechanismLigament2d shoulder, flywheel, serializer, rollers; + /** Distance from the frame perimeter to the origin in meters. */ + public static final double FRAME_PERIMETER_TO_ORIGIN_DISTANCE = Units.inchesToMeters(14); + + /** Maximum horizontal extension distance in meters. */ + public static final double MAX_HORIZONTAL_EXTENSION_DISTANCE = Units.feetToMeters(1); + + /** Maximum vertical extension distance in meters. */ + public static final double MAX_VERTICAL_EXTENSION_DISTANCE = Units.inchesToMeters(48); + /** Superstructure mechanism width. */ private final double WIDTH = - 2 - * (RobotConstants.FRAME_PERIMETER_TO_ORIGIN_DISTANCE - + RobotConstants.MAX_HORIZONTAL_EXTENSION_DISTANCE); + 2 * (FRAME_PERIMETER_TO_ORIGIN_DISTANCE + MAX_HORIZONTAL_EXTENSION_DISTANCE); /** Superstructure mechanism height. */ - private final double HEIGHT = RobotConstants.MAX_VERTICAL_EXTENSION_DISTANCE; + private final double HEIGHT = MAX_VERTICAL_EXTENSION_DISTANCE; /** Superstructure mechanism origin (horizontally centered). */ private final Translation2d ORIGIN = new Translation2d(WIDTH / 2, 0); @@ -112,19 +118,13 @@ private SuperstructureMechanism() { double framePerimeterThickness = Units.inchesToMeters(1) * 10; mechanism - .getRoot( - "framePerimeterLeft", - ORIGIN.getX() - RobotConstants.FRAME_PERIMETER_TO_ORIGIN_DISTANCE, - 0) + .getRoot("framePerimeterLeft", ORIGIN.getX() - FRAME_PERIMETER_TO_ORIGIN_DISTANCE, 0) .append( new MechanismLigament2d( "framePerimeterLeft_", HEIGHT, 90, framePerimeterThickness, DEFAULT_COLOR)); mechanism - .getRoot( - "framePerimeterRight", - ORIGIN.getX() + RobotConstants.FRAME_PERIMETER_TO_ORIGIN_DISTANCE, - 0) + .getRoot("framePerimeterRight", ORIGIN.getX() + FRAME_PERIMETER_TO_ORIGIN_DISTANCE, 0) .append( new MechanismLigament2d( "framePerimeterRight_", HEIGHT, 90, framePerimeterThickness, DEFAULT_COLOR));