Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,6 @@ tasks.withType(JavaCompile).configureEach {
options.errorprone {
disableWarningsInGeneratedCode = true
// Exclude auto-generated files and vendor utilities we don't own
excludedPaths = '.*/BuildConstants\\.java|.*/LimelightHelpers\\.java'
excludedPaths = '.*/BuildConstants\\.java|.*/LimelightHelpers\\.java|.*/build/generated/.*'
}
}
4 changes: 1 addition & 3 deletions src/main/java/frc/robot/AutoChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ private boolean matchesAlliance(String name, Optional<Alliance> alliance) {
return result;
}

/**
* @return the currently selected autonomous command
*/
/** return the currently selected autonomous command */
public Command getSelected() {
return chooser.getSelected();
}
Expand Down
38 changes: 14 additions & 24 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,23 @@ public static enum RobotType {
static RobotType robotType;

public static LinearVelocity getMaxSpeed() {
switch (getRobotType()) {
case WOODBOT:
return WoodBotConstants.maxSpeed;
case COMPBOT:
return CompBotConstants.maxSpeed;
case PRACTICEBOT:
return PracticeBotConstants.maxSpeed;
case SIM:
return SimulationConstants.maxSpeed;
default:
return PracticeBotConstants.maxSpeed;
}
return switch (getRobotType()) {
case WOODBOT -> WoodBotConstants.maxSpeed;
case COMPBOT -> CompBotConstants.maxSpeed;
case PRACTICEBOT -> PracticeBotConstants.maxSpeed;
case SIM -> SimulationConstants.maxSpeed;
default -> PracticeBotConstants.maxSpeed;
};
}

public static AngularVelocity getMaxAngularVelocity() {
switch (getRobotType()) {
case WOODBOT:
return WoodBotConstants.maxAngularVelocity;
case COMPBOT:
return CompBotConstants.maxAngularVelocity;
case PRACTICEBOT:
return PracticeBotConstants.maxAngularVelocity;
case SIM:
return SimulationConstants.maxAngularVelocity;
default:
return PracticeBotConstants.maxAngularVelocity;
}
return switch (getRobotType()) {
case WOODBOT -> WoodBotConstants.maxAngularVelocity;
case COMPBOT -> CompBotConstants.maxAngularVelocity;
case PRACTICEBOT -> PracticeBotConstants.maxAngularVelocity;
case SIM -> SimulationConstants.maxAngularVelocity;
default -> PracticeBotConstants.maxAngularVelocity;
};
}

public static RobotType getRobotType() {
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,16 @@ public Robot() {
}

switch (Constants.getRobotType()) {
case SIM:
// Running a physics simulator, log to NT
Logger.addDataReceiver(new NT4Publisher());
break;
case REPLAY:
case SIM -> // Running a physics simulator, log to NT
Logger.addDataReceiver(new NT4Publisher());
case REPLAY -> {
// Replaying a log, set up replay source
setUseTiming(false); // Run as fast as possible
String logPath = LogFileUtil.findReplayLog();
Logger.setReplaySource(new WPILOGReader(logPath));
Logger.addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(logPath, "_sim")));
break;
default:
}
default -> {}
}

Logger.start(); // Start logging! No more data receivers, replay sources, or metadata values may
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
*/
public class RobotContainer {

private static final double PRE_SHOT_UNJAM_SECONDS = 0.05;
private static final double AUTO_SHOOT_TIMEOUT_SECONDS = 5.0;
private static final double AUTO_SHOOT_NO_LAUNCH_TIMEOUT_SECONDS = 0.8;

Expand Down Expand Up @@ -122,8 +121,6 @@ public class RobotContainer {
// Replace with CommandPS4Controller or CommandJoystick if needed

private final CommandXboxController driverCont = new CommandXboxController(0);
private final CommandXboxController operatorCont = new CommandXboxController(1);
private final CommandXboxController testCont1 = new CommandXboxController(5);

/** Threshold above which a loop cycle is considered an overrun (22ms for a 20ms loop). */
private static final double LOOP_OVERRUN_THRESHOLD_SECONDS = 0.022;
Expand Down Expand Up @@ -182,11 +179,11 @@ public RobotContainer() {
indexer = new Indexer(new IndexerIOWB());
vision =
new Vision(
((new VisionIOLimelight3G(
new VisionIOLimelight3G(
Constants.WoodBotConstants.LIMELIGHT_3,
() -> drivetrain.getAngle(),
() -> drivetrain.getAngularRate(),
true))));
true));
intakeRoller = new IntakeRoller(new IntakeRollerIOWB());
flywheelKicker = new FlywheelKicker(new FlywheelKickerIOWB());
intakePivot = new IntakePivot(new IntakePivotIONoop());
Expand Down Expand Up @@ -222,11 +219,11 @@ public RobotContainer() {
indexer = new Indexer(new IndexerIOPB());
vision =
new Vision(
((new VisionIOLimelight3G(
new VisionIOLimelight3G(
Constants.PracticeBotConstants.LIMELIGHT_RIGHT,
() -> drivetrain.getAngle(),
() -> drivetrain.getAngularRate(),
true))),
true),
new VisionIOLimelight3G(
Constants.PracticeBotConstants.LIMELIGHT_LEFT,
() -> drivetrain.getAngle(),
Expand Down Expand Up @@ -272,11 +269,11 @@ public RobotContainer() {
indexer = new Indexer(new IndexerIOCB());
vision =
new Vision(
((new VisionIOLimelight4(
new VisionIOLimelight4(
Constants.CompBotConstants.LIMELIGHT_RIGHT,
() -> drivetrain.getAngle(),
() -> drivetrain.getAngularRate(),
true))),
true),
new VisionIOLimelight4(
Constants.CompBotConstants.LIMELIGHT_LEFT,
() -> drivetrain.getAngle(),
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/frc/robot/autos/BLinePaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,4 @@ static Translation2d flipAndMirror(Translation2d t) {
static Rotation2d flipAndMirrorRotation(Rotation2d r) {
return mirrorRotation(flipRotation(r));
}

// ─────────────────────────────────────────────────────────────────────────────
// Rotation constants
// ─────────────────────────────────────────────────────────────────────────────

private static final Rotation2d ROT_0 = Rotation2d.fromDegrees(0);
private static final Rotation2d ROT_180 = Rotation2d.fromDegrees(180);
private static final Rotation2d ROT_90 = Rotation2d.fromDegrees(90);
private static final Rotation2d ROT_NEG_90 = Rotation2d.fromDegrees(-90);
}
16 changes: 7 additions & 9 deletions src/main/java/frc/robot/commands/XOutWhileAligningCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,22 @@ private void updateState(double vx, double vy, Rotation2d heading) {
Logger.recordOutput(LOG_PREFIX + "HasDriverInput", hasDriverInput);

switch (state) {
case FACING_ANGLE:
case FACING_ANGLE -> {
double entryErrorRad = heading.minus(drivetrain.getRotation2d()).getRadians();
if (!hasDriverInput && Math.abs(entryErrorRad) < HEADING_TOLERANCE_RAD) {
state = State.X_OUT;
}
break;
}

case X_OUT:
case X_OUT -> {
double headingErrorRad = heading.minus(drivetrain.getRotation2d()).getRadians();
boolean stillAligned = Math.abs(headingErrorRad) < HEADING_TOLERANCE_RAD;

if (hasDriverInput || !stillAligned) {
state = State.FACING_ANGLE;
drivetrain.resetHeadingController();
}
break;
}
}

Logger.recordOutput(LOG_PREFIX + "State", state.name());
Expand All @@ -142,15 +142,13 @@ private void updateState(double vx, double vy, Rotation2d heading) {
*/
private void applyState(double vx, double vy, Rotation2d heading) {
switch (state) {
case FACING_ANGLE:
case FACING_ANGLE -> {
boolean isBlueAlliance = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Blue;
drivetrain.faceAngleWhileDriving(
isBlueAlliance ? vx : -vx, isBlueAlliance ? vy : -vy, heading);
break;
}

case X_OUT:
drivetrain.xOut();
break;
case X_OUT -> drivetrain.xOut();
}
}

Expand Down
40 changes: 31 additions & 9 deletions src/main/java/frc/robot/generated/CompBotDrivetrain.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
package frc.robot.generated;

import static edu.wpi.first.units.Units.*;
import static edu.wpi.first.units.Units.Amps;
import static edu.wpi.first.units.Units.Inches;
import static edu.wpi.first.units.Units.KilogramSquareMeters;
import static edu.wpi.first.units.Units.Meters;
import static edu.wpi.first.units.Units.MetersPerSecond;
import static edu.wpi.first.units.Units.Rotations;
import static edu.wpi.first.units.Units.Volts;

import com.ctre.phoenix6.CANBus;
import com.ctre.phoenix6.configs.*;
import com.ctre.phoenix6.hardware.*;
import com.ctre.phoenix6.signals.*;
import com.ctre.phoenix6.swerve.*;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.*;
import com.ctre.phoenix6.configs.CANcoderConfiguration;
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.Pigeon2Configuration;
import com.ctre.phoenix6.configs.Slot0Configs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.hardware.CANcoder;
import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.signals.StaticFeedforwardSignValue;
import com.ctre.phoenix6.swerve.SwerveDrivetrain;
import com.ctre.phoenix6.swerve.SwerveDrivetrainConstants;
import com.ctre.phoenix6.swerve.SwerveModuleConstants;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.ClosedLoopOutputType;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.DriveMotorArrangement;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerFeedbackType;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerMotorArrangement;
import com.ctre.phoenix6.swerve.SwerveModuleConstantsFactory;
import edu.wpi.first.math.Matrix;
import edu.wpi.first.math.numbers.N1;
import edu.wpi.first.math.numbers.N3;
import edu.wpi.first.units.measure.*;
import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.Current;
import edu.wpi.first.units.measure.Distance;
import edu.wpi.first.units.measure.LinearVelocity;
import edu.wpi.first.units.measure.MomentOfInertia;
import edu.wpi.first.units.measure.Voltage;
import frc.robot.subsystems.CommandSwerveDrivetrain;

// Generated by the 2026 Tuner X Swerve Project Generator
Expand Down Expand Up @@ -108,7 +130,7 @@ public class CompBotDrivetrain {
private static final Voltage kSteerFrictionVoltage = Volts.of(0.2);
private static final Voltage kDriveFrictionVoltage = Volts.of(0.2);

public static final SwerveDrivetrainConstants DrivetrainConstants =
public static final SwerveDrivetrainConstants drivetrainConstants =
new SwerveDrivetrainConstants()
.withCANBusName(kCANBus.getName())
.withPigeon2Id(kPigeonId)
Expand Down Expand Up @@ -243,7 +265,7 @@ public class CompBotDrivetrain {
*/
public static CommandSwerveDrivetrain createDrivetrain() {
return new CommandSwerveDrivetrain(
DrivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight);
drivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight);
}

/** Swerve Drive class utilizing CTR Electronics' Phoenix 6 API with the selected device types. */
Expand Down
40 changes: 31 additions & 9 deletions src/main/java/frc/robot/generated/PracticeBotDrivetrain.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
package frc.robot.generated;

import static edu.wpi.first.units.Units.*;
import static edu.wpi.first.units.Units.Amps;
import static edu.wpi.first.units.Units.Inches;
import static edu.wpi.first.units.Units.KilogramSquareMeters;
import static edu.wpi.first.units.Units.Meters;
import static edu.wpi.first.units.Units.MetersPerSecond;
import static edu.wpi.first.units.Units.Rotations;
import static edu.wpi.first.units.Units.Volts;

import com.ctre.phoenix6.CANBus;
import com.ctre.phoenix6.configs.*;
import com.ctre.phoenix6.hardware.*;
import com.ctre.phoenix6.signals.*;
import com.ctre.phoenix6.swerve.*;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.*;
import com.ctre.phoenix6.configs.CANcoderConfiguration;
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.Pigeon2Configuration;
import com.ctre.phoenix6.configs.Slot0Configs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.hardware.CANcoder;
import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.signals.StaticFeedforwardSignValue;
import com.ctre.phoenix6.swerve.SwerveDrivetrain;
import com.ctre.phoenix6.swerve.SwerveDrivetrainConstants;
import com.ctre.phoenix6.swerve.SwerveModuleConstants;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.ClosedLoopOutputType;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.DriveMotorArrangement;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerFeedbackType;
import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerMotorArrangement;
import com.ctre.phoenix6.swerve.SwerveModuleConstantsFactory;
import edu.wpi.first.math.Matrix;
import edu.wpi.first.math.numbers.N1;
import edu.wpi.first.math.numbers.N3;
import edu.wpi.first.units.measure.*;
import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.Current;
import edu.wpi.first.units.measure.Distance;
import edu.wpi.first.units.measure.LinearVelocity;
import edu.wpi.first.units.measure.MomentOfInertia;
import edu.wpi.first.units.measure.Voltage;
import frc.robot.subsystems.CommandSwerveDrivetrain;

// Generated by the 2026 Tuner X Swerve Project Generator
Expand Down Expand Up @@ -106,7 +128,7 @@ public class PracticeBotDrivetrain {
private static final Voltage kSteerFrictionVoltage = Volts.of(0.2);
private static final Voltage kDriveFrictionVoltage = Volts.of(0.2);

public static final SwerveDrivetrainConstants DrivetrainConstants =
public static final SwerveDrivetrainConstants drivetrainConstants =
new SwerveDrivetrainConstants()
.withCANBusName(kCANBus.getName())
.withPigeon2Id(kPigeonId)
Expand Down Expand Up @@ -241,7 +263,7 @@ public class PracticeBotDrivetrain {
*/
public static CommandSwerveDrivetrain createDrivetrain() {
return new CommandSwerveDrivetrain(
DrivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight);
drivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight);
}

/** Swerve Drive class utilizing CTR Electronics' Phoenix 6 API with the selected device types. */
Expand Down
Loading
Loading