Skip to content
Merged
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
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Enforce LF line endings for all text files
* text=auto eol=lf

# Explicitly binary files
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.jar binary
*.whl binary
*.glb binary
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@
"[java]": {
"editor.defaultFormatter": "richardwillis.vscode-spotless-gradle"
},
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx32G -Xms100m -Xlog:disable"
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx64G -Xms100m -Xlog:disable"
}
98 changes: 45 additions & 53 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

package frc.robot;

import static edu.wpi.first.units.Units.*;

import com.ctre.phoenix6.CANBus;
import edu.wpi.first.units.measure.AngularVelocity;
import edu.wpi.first.wpilibj.RobotBase;

/**
Expand Down Expand Up @@ -44,105 +41,100 @@ public static final class FeatureFlags {
public static final boolean PROFILING_ENABLED = false;

/** Set to false to disable the hopper subsystem entirely. */
public static final boolean kHopperEnabled = false;
public static final boolean HOPPER_ENABLED = false;
}

public final class RobotConstants {
public static final double kNominalVoltage = 12.0;
public static final double NOMINAL_VOLTAGE = 12.0;
}

public static final class MotorConstants {
public static final class NEOConstants {
public static final AngularVelocity kFreeSpeed = RPM.of(5676);
public static final int kDefaultSupplyCurrentLimit = 60;
public static final int kDefaultStatorCurrentLimit = 100;
public static final int DEFAULT_SUPPLY_CURRENT_LIMIT = 40;
public static final int DEFAULT_STATOR_CURRENT_LIMIT = 60;
}

public static final class NEO550Constants {
public static final AngularVelocity kFreeSpeed = RPM.of(11000);
public static final int kDefaultSupplyCurrentLimit = 10;
public static final int DEFAULT_SUPPLY_CURRENT_LIMIT = 5;
public static final int DEFAULT_STATOR_CURRENT_LIMIT = 10;
}

public static final class NEOVortexConstants {
public static final AngularVelocity kFreeSpeed = RPM.of(6784);
public static final int kDefaultSupplyCurrentLimit = 60;
public static final int kDefaultStatorCurrentLimit = 100;
public static final int DEFAULT_SUPPLY_CURRENT_LIMIT = 60;
public static final int DEFAULT_STATOR_CURRENT_LIMIT = 100;
}

public static final class KrakenX60Constants {
public static final AngularVelocity kFreeSpeed = RPM.of(6000);
public static final int kDefaultSupplyCurrentLimit = 60;
public static final int kDefaultStatorCurrentLimit = 100;
public static final int DEFAULT_SUPPLY_CURRENT_LIMIT = 60;
public static final int DEFAULT_STATOR_CURRENT_LIMIT = 100;
}
}

public static final class DIOPorts {
// max length is 8
public static final int[] autonomousModeSelector = {0, 1, 2};

public static final int allianceColorSelector = 3;
public static final int[] AUTONOMOUS_MODE_SELECTOR = {0, 1, 2};

public static final int turretAbsEncoder = 4;
}
public static final int ALLIANCE_COLOR_SELECTOR = 3;

public static final class OIPorts {
public static final int defaultDriver = 0;
public static final int defaultOperator = 1;
public static final int TURRET_ABS_ENCODER = 4;
}

public static final class CANBusPorts {

public static final class CAN2 {
public static final CANBus bus = CANBus.roboRIO();
public static final CANBus BUS = CANBus.roboRIO();

// Power distribution
public static final int PD = 1;

// Drivetrain
public static final int gyro = 0;
public static final int GYRO = 0;

// Launcher
public static final int turret = 12;
public static final int hood = 13;
public static final int flywheelLeader = 14;
public static final int flywheelFollower = 15;
public static final int TURRET = 12;
public static final int HOOD = 13;
public static final int FLYWHEEL_LEADER = 14;
public static final int FLYWHEEL_FOLLOWER = 15;

// Feeder
public static final int spindexer = 16;
public static final int kicker = 17;
public static final int SPINDEXER = 16;
public static final int KICKER = 17;

// Intake
public static final int intakeRollerLower = 22;
public static final int intakeRollerUpper = 23;
public static final int INTAKE_ROLLER_LOWER = 22;
public static final int INTAKE_ROLLER_UPPER = 23;
}

public static final class CANHD {
// CAN bus that the devices are located on;
// All swerve devices must share the same CAN bus
public static final CANBus bus = new CANBus("canivore");
public static final CANBus BUS = new CANBus("canivore");

// Drivetrain
public static final int backLeftDrive = 10;
public static final int backRightDrive = 18;
public static final int frontRightDrive = 20;
public static final int frontLeftDrive = 28;

public static final int backLeftTurn = 11;
public static final int backRightTurn = 19;
public static final int frontRightTurn = 21;
public static final int frontLeftTurn = 29;

public static final int backRightTurnAbsEncoder = 31;
public static final int frontRightTurnAbsEncoder = 33;
public static final int frontLeftTurnAbsEncoder = 43;
public static final int backLeftTurnAbsEncoder = 45;
public static final int BACK_LEFT_DRIVE = 10;
public static final int BACK_RIGHT_DRIVE = 18;
public static final int FRONT_RIGHT_DRIVE = 20;
public static final int FRONT_LEFT_DRIVE = 28;

public static final int BACK_LEFT_TURN = 11;
public static final int BACK_RIGHT_TURN = 19;
public static final int FRONT_RIGHT_TURN = 21;
public static final int FRONT_LEFT_TURN = 29;

public static final int BACK_RIGHT_TURN_ABS_ENC = 31;
public static final int FRONT_RIGHT_TURN_ABS_ENC = 33;
public static final int FRONT_LEFT_TURN_ABS_ENC = 43;
public static final int BACK_LEFT_TURN_ABS_ENC = 45;
}
}

public static final class PneumaticChannels {
// hopper
public static final int hopperForward = 14;
public static final int hopperReverse = 15;
public static final int HOPPER_FWD = 14;
public static final int HOPPER_REV = 15;

// intake arm
public static final int intakeArmForward = 0;
public static final int intakeArmReverse = 1;
public static final int INTAKE_ARM_FWD = 0;
public static final int INTAKE_ARM_REV = 1;
}
}
69 changes: 33 additions & 36 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import frc.lib.LoggedCompressor;
import frc.lib.LoggedPowerDistribution;
import frc.lib.ZorroController.Axis;
import frc.robot.Constants.CANBusPorts.CAN2;
import frc.robot.Constants.DIOPorts;
import frc.robot.Constants.FeatureFlags;
import frc.robot.auto.B_LeftTrenchAuto;
Expand Down Expand Up @@ -122,11 +123,11 @@ public class Robot extends LoggedRobot {
}

public static final AllianceSelector allianceSelector =
new AllianceSelector(DIOPorts.allianceColorSelector);
new AllianceSelector(DIOPorts.ALLIANCE_COLOR_SELECTOR);
public static final AutoSelector autoSelector =
new AutoSelector(DIOPorts.autonomousModeSelector, allianceSelector::getAllianceColor);
new AutoSelector(DIOPorts.AUTONOMOUS_MODE_SELECTOR, allianceSelector::getAllianceColor);
public final LoggedPowerDistribution powerDistribution =
new LoggedPowerDistribution(1, ModuleType.kRev, "PDH");
new LoggedPowerDistribution(CAN2.PD, ModuleType.kRev, "PD");

private final java.util.Set<String> activeCommands = new java.util.LinkedHashSet<>();

Expand Down Expand Up @@ -176,30 +177,30 @@ public Robot() {
drive =
new Drive(
new GyroIOBoron(),
new ModuleIOTalonFX(DriveConstants.FrontLeft),
new ModuleIOTalonFX(DriveConstants.FrontRight),
new ModuleIOTalonFX(DriveConstants.BackLeft),
new ModuleIOTalonFX(DriveConstants.BackRight));
new ModuleIOTalonFX(DriveConstants.FRONT_LEFT),
new ModuleIOTalonFX(DriveConstants.FRONT_RIGHT),
new ModuleIOTalonFX(DriveConstants.BACK_LEFT),
new ModuleIOTalonFX(DriveConstants.BACK_RIGHT));
vision =
new Vision(
drive::addVisionMeasurement,
drive::getFieldRelativeHeading,
new VisionIOPhotonVision(cameraFrontRightName, robotToFrontRightCamera),
new VisionIOPhotonVision(cameraFrontLeftName, robotToFrontLeftCamera),
new VisionIOPhotonVision(cameraBackRightName, robotToBackRightCamera),
new VisionIOPhotonVision(cameraBackLeftName, robotToBackLeftCamera));
new VisionIOPhotonVision(FRONT_RIGHT_CAMERA),
new VisionIOPhotonVision(FRONT_LEFT_CAMERA),
new VisionIOPhotonVision(BACK_RIGHT_CAMERA),
new VisionIOPhotonVision(BACK_LEFT_CAMERA));
launcher =
new Launcher(
drive::getPose,
drive::getRobotRelativeChassisSpeeds,
new TurretIOSpark(),
new FlywheelIOTalonFX(),
new HoodIOSpark());
if (FeatureFlags.kHopperEnabled) hopper = new Hopper(new HopperIOReal());
if (FeatureFlags.HOPPER_ENABLED) hopper = new Hopper(new HopperIOReal());
intake =
new Intake(
new RollerIOSpark(RollerConstants.upperRollerConfig),
new RollerIOSpark(RollerConstants.lowerRollerConfig),
new RollerIOSpark(RollerConstants.UPPER_ROLLER_CONFIG),
new RollerIOSpark(RollerConstants.LOWER_ROLLER_CONFIG),
new IntakeArmIOReal());
feeder = new Feeder(new SpindexerIOSpark(), new KickerIOSpark());
compressor = new LoggedCompressor(PneumaticsModuleType.REVPH, "Compressor");
Expand All @@ -217,22 +218,18 @@ public Robot() {
drive =
new Drive(
new GyroIO() {},
new ModuleIOSimWPI(DriveConstants.FrontLeft),
new ModuleIOSimWPI(DriveConstants.FrontRight),
new ModuleIOSimWPI(DriveConstants.BackLeft),
new ModuleIOSimWPI(DriveConstants.BackRight));
new ModuleIOSimWPI(DriveConstants.FRONT_LEFT),
new ModuleIOSimWPI(DriveConstants.FRONT_RIGHT),
new ModuleIOSimWPI(DriveConstants.BACK_LEFT),
new ModuleIOSimWPI(DriveConstants.BACK_RIGHT));
vision =
new Vision(
drive::addVisionMeasurement,
drive::getFieldRelativeHeading,
new VisionIOPhotonVisionSim(
cameraFrontRightName, robotToFrontRightCamera, drive::getPose),
new VisionIOPhotonVisionSim(
cameraFrontLeftName, robotToFrontLeftCamera, drive::getPose),
new VisionIOPhotonVisionSim(
cameraBackRightName, robotToBackRightCamera, drive::getPose),
new VisionIOPhotonVisionSim(
cameraBackLeftName, robotToBackLeftCamera, drive::getPose));
new VisionIOPhotonVisionSim(FRONT_RIGHT_CAMERA, drive::getPose),
new VisionIOPhotonVisionSim(FRONT_LEFT_CAMERA, drive::getPose),
new VisionIOPhotonVisionSim(BACK_RIGHT_CAMERA, drive::getPose),
new VisionIOPhotonVisionSim(BACK_LEFT_CAMERA, drive::getPose));
launcher =
new Launcher(
drive::getPose,
Expand All @@ -241,12 +238,12 @@ public Robot() {
new FlywheelIOSimTalonFX(),
new HoodIOSimSpark());
feeder = new Feeder(new SpindexerIOSimSpark(), new KickerIOSimSpark());
if (FeatureFlags.kHopperEnabled) hopper = new Hopper(new HopperIOSim());
if (FeatureFlags.HOPPER_ENABLED) hopper = new Hopper(new HopperIOSim());
var intakeArmIOSim = new IntakeArmIOSim();
intake =
new Intake(
new RollerIOSimSpark(RollerConstants.upperRollerConfig),
new RollerIOSimSpark(RollerConstants.lowerRollerConfig),
new RollerIOSimSpark(RollerConstants.UPPER_ROLLER_CONFIG),
new RollerIOSimSpark(RollerConstants.LOWER_ROLLER_CONFIG),
intakeArmIOSim);
pneumaticsSimulator =
new PneumaticsSimulator(intakeArmIOSim.intakeArmPneumatic, new REVPHSim(1));
Expand Down Expand Up @@ -283,7 +280,7 @@ public Robot() {
new TurretIO() {},
new FlywheelIO() {},
new HoodIO() {});
if (FeatureFlags.kHopperEnabled) hopper = new Hopper(new HopperIO() {});
if (FeatureFlags.HOPPER_ENABLED) hopper = new Hopper(new HopperIO() {});
intake = new Intake(new RollerIO() {}, new RollerIO() {}, new IntakeArmIO() {});
feeder = new Feeder(new SpindexerIO() {}, new KickerIO() {});
break;
Expand All @@ -302,13 +299,13 @@ public Robot() {

// Wire the hopper/intake interlocks. Done here (after both subsystems exist) to avoid a
// circular dependency between the two subsystems.
if (FeatureFlags.kHopperEnabled) {
if (FeatureFlags.HOPPER_ENABLED) {
intake.setDeployInterlock(
hopper::isDeployed,
() -> hopper.getDeployCommand().withTimeout(IntakeConstants.kInterlockSettleSeconds));
() -> hopper.getDeployCommand().withTimeout(IntakeConstants.INTERLOCK_SETTLE_SECONDS));
hopper.setRetractInterlock(
intake::isStowed,
() -> intake.getStopCommand().withTimeout(IntakeConstants.kInterlockSettleSeconds));
() -> intake.getStopCommand().withTimeout(IntakeConstants.INTERLOCK_SETTLE_SECONDS));
}

configureControlPanelBindings();
Expand Down Expand Up @@ -352,8 +349,8 @@ public void robotPeriodic() {
CommandScheduler.getInstance().run();
long t1 = FeatureFlags.PROFILING_ENABLED ? System.nanoTime() : 0;

logCANBus("CAN2", Constants.CANBusPorts.CAN2.bus);
logCANBus("CANHD", Constants.CANBusPorts.CANHD.bus);
logCANBus("CAN2", Constants.CANBusPorts.CAN2.BUS);
logCANBus("CANHD", Constants.CANBusPorts.CANHD.BUS);
powerDistribution.log();
if (compressor != null) compressor.log();
logHIDs();
Expand Down Expand Up @@ -548,7 +545,7 @@ public boolean getFieldRelativeInput() {
// Toggle hopper: deploy if stowed, stow if deployed (retracting intake first if needed).
// runOnce has no subsystem requirements so it always executes; the scheduled command
// requires hopper and will interrupt whatever is currently running on that subsystem.
if (FeatureFlags.kHopperEnabled)
if (FeatureFlags.HOPPER_ENABLED)
zorroDriver
.DIn()
.onTrue(
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/commands/DriveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,18 +486,18 @@ public static Command wheelRadiusCharacterization(Drive drive) {
return;
}

double wheelRadius =
(state.gyroDelta * driveBaseRadius.in(Meters)) / wheelDelta;
double WHEEL_RADIUS =
(state.gyroDelta * DRIVE_BASE_RADIUS.in(Meters)) / wheelDelta;

System.out.println(
"\tWheel Delta: " + formatter.format(wheelDelta) + " radians");
System.out.println(
"\tGyro Delta: " + formatter.format(state.gyroDelta) + " radians");
System.out.println(
"\tWheel Radius: "
+ formatter.format(wheelRadius)
+ formatter.format(WHEEL_RADIUS)
+ " meters, "
+ formatter.format(Units.metersToInches(wheelRadius))
+ formatter.format(Units.metersToInches(WHEEL_RADIUS))
+ " inches");
})));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/PathCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private static PathPlannerPath createPath(List<Waypoint> waypoints, Rotation2d e
var path =
new PathPlannerPath(
waypoints,
pathFollowingConstraints,
PATH_FOLLOWING_CONSTRAINTS,
// The ideal starting state, this is only relevant for pre-planned paths,
// so can be null for on-the-fly paths.
null,
Expand Down
Loading
Loading