Skip to content

Commit

Permalink
Changes from WPI day 2
Browse files Browse the repository at this point in the history
  • Loading branch information
camearle20 committed Feb 11, 2024
1 parent cd9294d commit 1026b3e
Show file tree
Hide file tree
Showing 83 changed files with 5,568 additions and 5,555 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ spotless {
toggleOffOn()
googleJavaFormat()
removeUnusedImports()
indentWithTabs(2)
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
Expand Down
Empty file.
Binary file not shown.
84 changes: 42 additions & 42 deletions src/main/java/org/littletonrobotics/frc2024/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,59 +26,59 @@
* constants are needed, to reduce verbosity.
*/
public final class Constants {
public static final int loopPeriodMs = 20;
private static RobotType robotType = RobotType.SIMBOT;
public static final boolean tuningMode = true;
public static final int loopPeriodMs = 20;
private static RobotType robotType = RobotType.DEVBOT;
public static final boolean tuningMode = true;

private static boolean invalidRobotAlertSent = false;
private static boolean invalidRobotAlertSent = false;

public static RobotType getRobot() {
if (!disableHAL && RobotBase.isReal() && robotType == RobotType.SIMBOT) {
new Alert("Invalid Robot Selected, using COMPBOT as default", Alert.AlertType.ERROR)
.set(true);
invalidRobotAlertSent = true;
robotType = RobotType.COMPBOT;
}
return robotType;
public static RobotType getRobot() {
if (!disableHAL && RobotBase.isReal() && robotType == RobotType.SIMBOT) {
new Alert("Invalid Robot Selected, using COMPBOT as default", Alert.AlertType.ERROR)
.set(true);
invalidRobotAlertSent = true;
robotType = RobotType.COMPBOT;
}
return robotType;
}

public static Mode getMode() {
return switch (robotType) {
case DEVBOT, COMPBOT -> RobotBase.isReal() ? Mode.REAL : Mode.REPLAY;
case SIMBOT -> Mode.SIM;
};
}
public static Mode getMode() {
return switch (robotType) {
case DEVBOT, COMPBOT -> RobotBase.isReal() ? Mode.REAL : Mode.REPLAY;
case SIMBOT -> Mode.SIM;
};
}

public static final Map<RobotType, String> logFolders = Map.of(RobotType.DEVBOT, "/media/sda1/");
public static final Map<RobotType, String> logFolders = Map.of(RobotType.DEVBOT, "/media/sda1/");

public enum Mode {
/** Running on a real robot. */
REAL,
public enum Mode {
/** Running on a real robot. */
REAL,

/** Running a physics simulator. */
SIM,
/** Running a physics simulator. */
SIM,

/** Replaying from a log file. */
REPLAY
}
/** Replaying from a log file. */
REPLAY
}

public enum RobotType {
SIMBOT,
DEVBOT,
COMPBOT
}
public enum RobotType {
SIMBOT,
DEVBOT,
COMPBOT
}

public static boolean disableHAL = false;
public static boolean disableHAL = false;

public static void disableHAL() {
disableHAL = true;
}
public static void disableHAL() {
disableHAL = true;
}

/** Checks whether the robot the correct robot is selected when deploying. */
public static void main(String... args) {
if (robotType == RobotType.SIMBOT) {
System.err.println("Cannot deploy, invalid robot selected: " + robotType.toString());
System.exit(1);
}
/** Checks whether the robot the correct robot is selected when deploying. */
public static void main(String... args) {
if (robotType == RobotType.SIMBOT) {
System.err.println("Cannot deploy, invalid robot selected: " + robotType.toString());
System.exit(1);
}
}
}
144 changes: 72 additions & 72 deletions src/main/java/org/littletonrobotics/frc2024/FieldConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,81 +19,81 @@
* Width refers to the <i>y</i> direction (as described by wpilib)
*/
public class FieldConstants {
public static double fieldLength = Units.inchesToMeters(651.223);
public static double fieldWidth = Units.inchesToMeters(323.277);
public static double wingX = Units.inchesToMeters(229.201);
public static double podiumX = Units.inchesToMeters(126.75);
public static double startingLineX = Units.inchesToMeters(74.111);

public static Translation2d ampCenter =
new Translation2d(Units.inchesToMeters(72.455), Units.inchesToMeters(322.996));

/** Staging locations for each note */
public static final class StagingLocations {
public static double centerlineX = fieldLength / 2.0;

// need to update
public static double centerlineFirstY = Units.inchesToMeters(29.638);
public static double centerlineSeparationY = Units.inchesToMeters(66);
public static double spikeX = Units.inchesToMeters(114);
// need
public static double spikeFirstY = Units.inchesToMeters(161.638);
public static double spikeSeparationY = Units.inchesToMeters(57);

public static Translation2d[] centerlineTranslations = new Translation2d[5];
public static Translation2d[] spikeTranslations = new Translation2d[3];

static {
for (int i = 0; i < centerlineTranslations.length; i++) {
centerlineTranslations[i] =
new Translation2d(centerlineX, centerlineFirstY + (i * centerlineSeparationY));
}
}

static {
for (int i = 0; i < spikeTranslations.length; i++) {
spikeTranslations[i] = new Translation2d(spikeX, spikeFirstY + (i * spikeSeparationY));
}
}
}
public static double fieldLength = Units.inchesToMeters(651.223);
public static double fieldWidth = Units.inchesToMeters(323.277);
public static double wingX = Units.inchesToMeters(229.201);
public static double podiumX = Units.inchesToMeters(126.75);
public static double startingLineX = Units.inchesToMeters(74.111);

public static Translation2d ampCenter =
new Translation2d(Units.inchesToMeters(72.455), Units.inchesToMeters(322.996));

/** Staging locations for each note */
public static final class StagingLocations {
public static double centerlineX = fieldLength / 2.0;

// need to update
public static double centerlineFirstY = Units.inchesToMeters(29.638);
public static double centerlineSeparationY = Units.inchesToMeters(66);
public static double spikeX = Units.inchesToMeters(114);
// need
public static double spikeFirstY = Units.inchesToMeters(161.638);
public static double spikeSeparationY = Units.inchesToMeters(57);

public static Translation2d[] centerlineTranslations = new Translation2d[5];
public static Translation2d[] spikeTranslations = new Translation2d[3];

/** Each corner of the speaker * */
public static final class Speaker {

// corners (blue alliance origin)
public static Translation3d topRightSpeaker =
new Translation3d(
Units.inchesToMeters(18.055),
Units.inchesToMeters(238.815),
Units.inchesToMeters(13.091));

public static Translation3d topLeftSpeaker =
new Translation3d(
Units.inchesToMeters(18.055),
Units.inchesToMeters(197.765),
Units.inchesToMeters(83.091));

public static Translation3d bottomRightSpeaker =
new Translation3d(0.0, Units.inchesToMeters(238.815), Units.inchesToMeters(78.324));
public static Translation3d bottomLeftSpeaker =
new Translation3d(0.0, Units.inchesToMeters(197.765), Units.inchesToMeters(78.324));

/** Center of the speaker opening (blue alliance) */
public static Translation3d centerSpeakerOpening =
new Translation3d(
topLeftSpeaker.getX() / 2.0,
fieldWidth - Units.inchesToMeters(104.0),
(bottomLeftSpeaker.getZ() + bottomRightSpeaker.getZ()) / 2.0);
static {
for (int i = 0; i < centerlineTranslations.length; i++) {
centerlineTranslations[i] =
new Translation2d(centerlineX, centerlineFirstY + (i * centerlineSeparationY));
}
}

public static double aprilTagWidth = Units.inchesToMeters(6.50);
public static AprilTagFieldLayout aprilTags;

static {
try {
aprilTags = AprilTagFieldLayout.loadFromResource(k2024Crescendo.m_resourceFile);
} catch (IOException e) {
throw new RuntimeException(e);
}
for (int i = 0; i < spikeTranslations.length; i++) {
spikeTranslations[i] = new Translation2d(spikeX, spikeFirstY + (i * spikeSeparationY));
}
}
}

/** Each corner of the speaker * */
public static final class Speaker {

// corners (blue alliance origin)
public static Translation3d topRightSpeaker =
new Translation3d(
Units.inchesToMeters(18.055),
Units.inchesToMeters(238.815),
Units.inchesToMeters(13.091));

public static Translation3d topLeftSpeaker =
new Translation3d(
Units.inchesToMeters(18.055),
Units.inchesToMeters(197.765),
Units.inchesToMeters(83.091));

public static Translation3d bottomRightSpeaker =
new Translation3d(0.0, Units.inchesToMeters(238.815), Units.inchesToMeters(78.324));
public static Translation3d bottomLeftSpeaker =
new Translation3d(0.0, Units.inchesToMeters(197.765), Units.inchesToMeters(78.324));

/** Center of the speaker opening (blue alliance) */
public static Translation3d centerSpeakerOpening =
new Translation3d(
topLeftSpeaker.getX() / 2.0,
fieldWidth - Units.inchesToMeters(104.0),
(bottomLeftSpeaker.getZ() + bottomRightSpeaker.getZ()) / 2.0);
}

public static double aprilTagWidth = Units.inchesToMeters(6.50);
public static AprilTagFieldLayout aprilTags;

static {
try {
aprilTags = AprilTagFieldLayout.loadFromResource(k2024Crescendo.m_resourceFile);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
18 changes: 9 additions & 9 deletions src/main/java/org/littletonrobotics/frc2024/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* call.
*/
public final class Main {
private Main() {}
private Main() {}

/**
* Main initialization function. Do not perform any initialization here.
*
* <p>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.
*
* <p>If you change your main robot class, change the parameter type.
*/
public static void main(String... args) {
RobotBase.startRobot(Robot::new);
}
}
Loading

0 comments on commit 1026b3e

Please sign in to comment.