Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
refactor: Clean up robot constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenheroux committed Apr 27, 2024
1 parent 0908617 commit 4642109
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 33 deletions.
23 changes: 3 additions & 20 deletions src/main/java/frc/robot/RobotConstants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package frc.robot;

import edu.wpi.first.math.util.Units;
import java.util.EnumSet;
import java.util.Set;

Expand All @@ -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,
Expand All @@ -37,9 +21,8 @@ public enum Subsystem {
SWERVE,
}

public static final Set<Subsystem> ALL_SUBSYSTEMS =
/** Real subsystems. */
public static final Set<Subsystem> REAL_SUBSYSTEMS =
EnumSet.of(
Subsystem.ARM, Subsystem.INTAKE, Subsystem.ODOMETRY, Subsystem.SHOOTER, Subsystem.SWERVE);

public static final Set<Subsystem> REAL_SUBSYSTEMS = ALL_SUBSYSTEMS;
}
26 changes: 13 additions & 13 deletions src/main/java/frc/robot/superstructure/SuperstructureMechanism.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 4642109

Please sign in to comment.