Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9071d52
Add tests to sourcePaths (for intellisense etc.)
SCool62 Jan 16, 2026
b04b926
Impl AutoCloseable where nessesary
SCool62 Jan 16, 2026
1407864
Proof of concept test
SCool62 Jan 16, 2026
78ef8c5
Spotless
SCool62 Jan 16, 2026
609edf8
Hopefully make ci run on all prs?
SCool62 Jan 16, 2026
e87be96
Revert "Hopefully make ci run on all prs?"
SCool62 Jan 16, 2026
5cf1ff7
Merge branch 'feature/alpha-state-machine' into experiment/superstruc…
SCool62 Jan 17, 2026
5ee9c0b
Fix constructor
SCool62 Jan 17, 2026
9939f66
Re implement auto-closeable
SCool62 Jan 17, 2026
7b89e58
Make test build
SCool62 Jan 17, 2026
87cf920
Add test running to ci checks
SCool62 Jan 17, 2026
cdcc3db
Failing test to test ci
SCool62 Jan 17, 2026
4bed2b8
Turns out we don't need a seperate CI check, and the failing test doe…
SCool62 Jan 17, 2026
c31134a
Intake to READY test
SCool62 Jan 17, 2026
6e428c8
These assert statements should go the other way around lol
SCool62 Jan 17, 2026
dada1e7
Spotless
SCool62 Jan 17, 2026
66596f1
Intake to READY when full test
SCool62 Jan 17, 2026
da9eb81
Merge branch 'feature/alpha-state-machine' into experiment/superstruc…
SCool62 Jan 17, 2026
c8ffb98
Ready to score and ready to feed tests
SCool62 Jan 17, 2026
b89f1fd
Add score transition tests
SCool62 Jan 17, 2026
17cf7f1
I've decided it would be better to have seperate build and test ci ch…
SCool62 Jan 17, 2026
8578bb3
Failing test to test ci
SCool62 Jan 17, 2026
0df3fc9
Revert "Failing test to test ci" because we don't need the failing te…
SCool62 Jan 17, 2026
b8a3afd
IDLE to flowstate tests
SCool62 Jan 17, 2026
32bfc02
Flow state to idle
SCool62 Jan 18, 2026
a0ecf99
Merge branch 'main' into experiment/superstructure-tests
SCool62 Jan 23, 2026
31d4b27
Make it build
SCool62 Jan 23, 2026
9d57e73
Fix errors in
SCool62 Jan 23, 2026
e928608
Cleanup test class. Tests aren't passing but bringup has some fixes
SCool62 Jan 23, 2026
6a7e98b
Merge branch 'main' into experiment/superstructure-tests
SCool62 Jan 23, 2026
73c2db7
Autocloseable impl (again)
SCool62 Jan 23, 2026
b3061ff
Some cleanup in superstructure tests
SCool62 Jan 23, 2026
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
33 changes: 31 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ jobs:
run: chmod +x gradlew

# Runs a single command using the runners shell
- name: Compile and run tests on robot code
run: ./gradlew build
# Assemble builds the code without running tests
- name: Compile robot code
run: ./gradlew assemble

format:
name: Format
Expand Down Expand Up @@ -62,3 +63,31 @@ jobs:
# Runs a single command using the runners shell
- name: Run formatting check
run: ./gradlew spotlessCheck

test:
name: Test

runs-on: ubuntu-latest

# Wpilib docker container
# Latest as of 1/11/26
# Need to use a container without -py. The ones with -py don't have java installed
container: wpilib/roborio-cross-ubuntu:2025-22.04

# Steps represent a sequence of tasks that will be executed as part of the job
# Copied from Onseason implementation
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Declares the repository safe and not under dubious ownership.
- name: Add repository to git safe directories
run: git config --global --add safe.directory $GITHUB_WORKSPACE

# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew

# Runs a single command using the runners shell
- name: Run tests
run: ./gradlew test
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@
"java.dependency.enableDependencyCheckup": false,
"wpilib.selectDefaultSimulateExtension": false,
"wpilib.skipSelectSimulateExtension": true,
"java.project.sourcePaths": [
"src/main",
"src/test"
],
"wpilib.autoStartRioLog": false
}
43 changes: 41 additions & 2 deletions src/main/java/frc/robot/Superstructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.subsystems.indexer.Indexer;
import frc.robot.subsystems.indexer.LindexerSubsystem;
import frc.robot.subsystems.intake.Intake;
import frc.robot.subsystems.shooter.Shooter;
import frc.robot.subsystems.swerve.SwerveSubsystem;
Expand All @@ -19,7 +20,7 @@
import org.littletonrobotics.junction.AutoLogOutput;
import org.littletonrobotics.junction.Logger;

public class Superstructure {
public class Superstructure implements AutoCloseable {

/** We should have a state for every single action the robot will perform. */
public enum SuperState {
Expand Down Expand Up @@ -113,6 +114,35 @@ public Superstructure(
stateTimer.start();
}

// Used for testing
public Superstructure(
SwerveSubsystem swerve,
Indexer indexer,
Intake intake,
Shooter shooter,
Trigger scoreReq,
Trigger intakeReq,
Trigger feedReq,
Trigger antiJamReq,
Trigger isFull,
Trigger isEmpty) {
this.swerve = swerve;
this.intake = intake;
this.indexer = indexer;
this.shooter = shooter;
this.scoreReq = scoreReq;
this.intakeReq = intakeReq;
this.feedReq = feedReq;
this.antiJamReq = antiJamReq;
this.isFull = isFull;
this.isEmpty = isEmpty;
this.driver = null;
this.operator = null;

addTransitions();
addCommands();
}

private void addTriggers() {
// Toggles for feeding
operator.leftBumper().onTrue(Commands.runOnce(() -> shouldFeed = true));
Expand Down Expand Up @@ -149,7 +179,7 @@ private void addTransitions() {
(intakeReq.negate().and(scoreReq.negate()).and(isEmpty.negate())));
// .or(isFull));

// bindTransition(SuperState.INTAKE, SuperState.SPIN_UP_FEED, feedReq);
bindTransition(SuperState.READY, SuperState.SPIN_UP_FEED, feedReq);

bindTransition(SuperState.READY, SuperState.INTAKE, intakeReq);
// .and(isFull.negate()));
Expand Down Expand Up @@ -351,6 +381,15 @@ public boolean stateIsIdle() {
return getState() == SuperState.IDLE;
}

@Override
public void close() throws Exception {
intake.close();
shooter.close();
indexer.close();
swerve.close();
Superstructure.state = SuperState.IDLE;
}

private Alliance getStartingAlliance() {
String gameData = DriverStation.getGameSpecificMessage();
// gives first inactive alliance
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/frc/robot/components/camera/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.photonvision.targeting.PhotonTrackedTarget;

/** Add your docs here. */
public class Camera {
public class Camera implements AutoCloseable {

// The intrinsics and distortion coefficients are only actually used for sim
public record CameraConstants(
Expand Down Expand Up @@ -217,4 +217,9 @@ public CameraConstants getCameraConstants() {
public Pose3d getPose() {
return pose;
}

@Override
public void close() throws Exception {
io.close();
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/components/camera/CameraIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.photonvision.targeting.PhotonPipelineResult;

/** Add your docs here. */
public interface CameraIO {
public interface CameraIO extends AutoCloseable {
@AutoLog
public static class CameraIOInputs {
public PhotonPipelineResult result = new PhotonPipelineResult();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/components/camera/CameraIOReal.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public void setSimPose(Optional<EstimatedRobotPose> simEst, boolean newResult) {
public CameraConstants getCameraConstants() {
return constants;
}

@Override
public void close() throws Exception {
camera.close();
}
}
6 changes: 6 additions & 0 deletions src/main/java/frc/robot/components/camera/CameraIOSim.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@ public String getName() {
public CameraConstants getCameraConstants() {
return constants;
}

@Override
public void close() throws Exception {
camera.close();
simCamera.close();
}
}
7 changes: 6 additions & 1 deletion src/main/java/frc/robot/components/rollers/RollerIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import edu.wpi.first.wpilibj2.command.Command;
import org.littletonrobotics.junction.AutoLog;

public class RollerIO {
public class RollerIO implements AutoCloseable {

@AutoLog
public static class RollerIOInputs {
Expand Down Expand Up @@ -94,4 +94,9 @@ public Command getVoltage() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getVoltage'");
}

@Override
public void close() throws Exception {
motor.close();
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/indexer/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import edu.wpi.first.wpilibj2.command.Command;

/** Add your docs here. */
public interface Indexer {
public interface Indexer extends AutoCloseable {

public boolean isFull();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import frc.robot.components.rollers.RollerIOInputsAutoLogged;
import org.littletonrobotics.junction.Logger;

/** Lindexer = Linear Indexer. !! ALPHA !! */
public class LindexerSubsystem extends SubsystemBase implements Indexer {
// Add actual CanBus

public static final double GEAR_RATIO = 2.0;
private CANrangeIOReal firstCANRangeIO;
Expand Down Expand Up @@ -175,4 +175,10 @@ public Command runRollerSysId() {
indexRollerSysid.dynamic(Direction.kForward),
indexRollerSysid.dynamic(Direction.kReverse));
}

@Override
public void close() throws Exception {
indexRollerIO.close();
kickerIO.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ public Command rest() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'rest'");
}

@Override
public void close() throws Exception {
// No-op rn bc nothing to close
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,9 @@ public static TalonFXConfiguration getIntakeConfig() {

return config;
}

@Override
public void close() throws Exception {
io.close();
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/intake/Intake.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import edu.wpi.first.wpilibj2.command.Command;

/** Add your docs here. */
public interface Intake {
public interface Intake extends AutoCloseable {
/** Run balls towards the shooter */
public Command intake();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public Command rest() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'rest'");
}

@Override
public void close() throws Exception {
// No-op rn bc nothing to close
}
}
8 changes: 7 additions & 1 deletion src/main/java/frc/robot/subsystems/shooter/FlywheelIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.littletonrobotics.junction.AutoLogOutput;

/** Add your docs here. */
public class FlywheelIO {
public class FlywheelIO implements AutoCloseable {

@AutoLog
public static class FlywheelIOInputs {
Expand Down Expand Up @@ -183,4 +183,10 @@ public void updateInputs(FlywheelIOInputs inputs) {
public double getSetpointRotPerSec() {
return velocitySetpointRotPerSec;
}

@Override
public void close() {
flywheelFollower.close();
flywheelLeader.close();
}
}
7 changes: 6 additions & 1 deletion src/main/java/frc/robot/subsystems/shooter/HoodIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.littletonrobotics.junction.AutoLog;
import org.littletonrobotics.junction.AutoLogOutput;

public class HoodIO {
public class HoodIO implements AutoCloseable {
/** Creates a new HoodIOReal. */
@AutoLog
public static class HoodIOInputs {
Expand Down Expand Up @@ -143,4 +143,9 @@ public Rotation2d getHoodSetpoint() {
public void resetEncoder(Rotation2d rotations) {
hoodMotor.setPosition(rotations.getRotations());
}

@Override
public void close() throws Exception {
hoodMotor.close();
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/shooter/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.function.Supplier;

/** Add your docs here. */
public interface Shooter {
public interface Shooter extends AutoCloseable {

/**
* Sets hood angle and flywheel velocity based on distance from hub from the shot map + current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
import org.littletonrobotics.junction.AutoLogOutput;
import org.littletonrobotics.junction.Logger;

/** Fixed shooter. !! ALPHA !! */
public class ShooterSubsystem extends SubsystemBase implements Shooter {
public static double HOOD_GEAR_RATIO = 24.230769;
public static double HOOD_GEAR_RATIO = 147.0 / 13.0;
public static Rotation2d HOOD_MAX_ROTATION = Rotation2d.fromDegrees(40);
public static Rotation2d HOOD_MIN_ROTATION = Rotation2d.fromDegrees(2);

Expand Down Expand Up @@ -184,4 +183,10 @@ public boolean atHoodSetpoint() {
public Command zeroHood() {
return this.runOnce(() -> hoodIO.resetEncoder(HOOD_MIN_ROTATION));
}

@Override
public void close() throws Exception {
flywheelIO.close();
hoodIO.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ public Command testShoot() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'testShoot'");
}

@Override
public void close() throws Exception {
// No-op rn bc nothing to close
}
}
13 changes: 12 additions & 1 deletion src/main/java/frc/robot/subsystems/swerve/SwerveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
import org.littletonrobotics.junction.AutoLogOutput;
import org.littletonrobotics.junction.Logger;

public class SwerveSubsystem extends SubsystemBase {
public class SwerveSubsystem extends SubsystemBase implements AutoCloseable {
// decide which set of swerve constants to use based on robot edition
// defaulting to comp is probably safer?
public static final SwerveConstants SWERVE_CONSTANTS =
Expand Down Expand Up @@ -737,4 +737,15 @@ public void simulationPeriodic() {
// Log simulated pose
Logger.recordOutput("MapleSim/Pose", swerveSimulation.getSimulatedDriveTrainPose());
}

@Override
public void close() throws Exception {
for (Module module : modules) {
module.close();
}
gyroIO.close();
for (Camera camera : cameras) {
camera.close();
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/swerve/gyro/GyroIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import edu.wpi.first.math.geometry.Rotation2d;
import org.littletonrobotics.junction.AutoLog;

public interface GyroIO {
public interface GyroIO extends AutoCloseable {

@AutoLog
public static class GyroIOInputs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ public void updateInputs(GyroIOInputs inputs) {
public void setYaw(Rotation2d yaw) {
pigeon.setYaw(yaw.getDegrees());
}

@Override
public void close() throws Exception {
pigeon.close();
}
}
Loading
Loading