ci/test: add automated simulation testing to CI/CD and unit test suite - #127
ci/test: add automated simulation testing to CI/CD and unit test suite#127arena-ai-coding-agent[bot] wants to merge 5 commits into
Conversation
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughThe pull request adds headless simulation verification, reusable simulation test setup and cleanup, lifecycle controls for simulation notifiers, and tests for robot mechanisms, superstructure, autonomous routines, and full robot simulation. ChangesSimulation testing
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant SimTestBase
participant SimLoop
participant DriverStation
participant CommandScheduler
participant RobotSimulation
SimTestBase->>SimLoop: reset simulation state
SimTestBase->>DriverStation: enable autonomous or teleoperated simulation
SimTestBase->>CommandScheduler: run scheduled commands during stepSim
SimTestBase->>RobotSimulation: advance simulation
SimTestBase->>SimLoop: clear callbacks and notifier during teardown
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/test/java/frc/robot/sim/AutonSimTest.java`:
- Around line 30-51: The full robot-stack construction is duplicated across four
test sites; centralize it in a shared SimTestBase factory. Add a helper that
wires the OM2026-configured Swerve, all listed subsystems, and SuperStructure
while preserving resource ownership, then replace the duplicate blocks in
src/test/java/frc/robot/sim/AutonSimTest.java lines 30-51 and 65-86,
src/test/java/frc/robot/sim/RobotSimTest.java lines 30-51, and
src/test/java/frc/robot/sim/SuperStructureSimTest.java lines 30-51 with the
shared helper call.
In `@src/test/java/frc/robot/sim/MechanismSimTest.java`:
- Around line 49-61: Update testIntakeExtensionSimPeriodic to construct
IntakeExtension with a valid populated IntakeExtensionConfig, following the
existing OM2026 configuration pattern used by the other simulation tests, or
provide valid LeftConfig and RightConfig arguments directly. Preserve the test’s
scheduler registration, simulation stepping, and getSim assertion.
In `@src/test/java/frc/robot/sim/SuperStructureSimTest.java`:
- Around line 57-59: Replace the deprecated schedule() call in
SuperStructureSimTest with CommandScheduler.getInstance().schedule(...), passing
the command returned by
setStateCommand(SuperStructure.WantedSuperState.INTAKE_FUEL). Preserve the
existing command behavior and add or use the appropriate scheduler import.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5e8a9213-977d-4f0c-b4cf-8f12f5dca334
📒 Files selected for processing (11)
build.gradledocs/tools/simulation.mdscripts/verify.shsrc/main/java/frc/robot/auton/Auton.javasrc/main/java/frc/robot/subsystems/swerve/Swerve.javasrc/main/java/frc/spectrumLib/sim/SimLoop.javasrc/test/java/frc/robot/sim/AutonSimTest.javasrc/test/java/frc/robot/sim/MechanismSimTest.javasrc/test/java/frc/robot/sim/RobotSimTest.javasrc/test/java/frc/robot/sim/SimTestBase.javasrc/test/java/frc/robot/sim/SuperStructureSimTest.java
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 5 file(s) based on 3 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 5 file(s) based on 3 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @Project516. The following files were modified: * `src/main/java/frc/robot/subsystems/swerve/Swerve.java` * `src/main/java/frc/spectrumLib/sim/SimLoop.java` * `src/test/java/frc/robot/sim/SimTestBase.java` These files were ignored: * `src/test/java/frc/robot/sim/AutonSimTest.java` * `src/test/java/frc/robot/sim/MechanismSimTest.java` * `src/test/java/frc/robot/sim/RobotSimTest.java` * `src/test/java/frc/robot/sim/SuperStructureSimTest.java` These file types are not supported: * `build.gradle` * `docs/tools/simulation.md`
|
✅ Committed CI fixes to this branch (
2 failing check(s)
2 file(s) modified
View agent analysis |
…: CI / 0_build.txt Co-Authored-By: CodeRabbit <noreply@coderabbit.ai>
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/test/java/frc/robot/sim/SimTestBase.java (1)
158-164: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAdvance the requested simulation duration exactly.
Math.round(durationSeconds / dtSeconds)can advance less or more time thandurationSeconds. This changes test behavior for non-integral durations.Execute full steps and one final remainder step.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/frc/robot/sim/SimTestBase.java` around lines 158 - 164, Update stepSim to advance exactly durationSeconds by executing the full dtSeconds steps, then one final step for any remaining fractional duration. Replace the rounded step count logic while preserving the existing SimHooks.stepTiming and CommandScheduler execution for every step.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/frc/spectrumLib/sim/SimLoop.java`:
- Around line 45-49: Update the Javadoc for the tick() method by removing the
invalid `@param` dt tag and keeping the description focused on notifying
registered callbacks with the computed elapsed time.
In `@src/test/java/frc/robot/sim/RobotSimTest.java`:
- Around line 20-21: At the four try-with-resources sites in
src/test/java/frc/robot/sim/RobotSimTest.java (20-21),
src/test/java/frc/robot/sim/SuperStructureSimTest.java (21-22), and
src/test/java/frc/robot/sim/AutonSimTest.java (20-21, 34-35), remove the local
Swerve resource variable and use stack.swerve directly; remove the now-unused
Swerve imports from all affected files.
In `@src/test/java/frc/robot/sim/SimTestBase.java`:
- Around line 89-119: Update createRobotStack around the Swerve and subsequent
subsystem construction so any constructor failure closes the already-created
swerve before rethrowing the original failure. Preserve normal RobotStack
creation and return behavior when construction succeeds.
---
Outside diff comments:
In `@src/test/java/frc/robot/sim/SimTestBase.java`:
- Around line 158-164: Update stepSim to advance exactly durationSeconds by
executing the full dtSeconds steps, then one final step for any remaining
fractional duration. Replace the rounded step count logic while preserving the
existing SimHooks.stepTiming and CommandScheduler execution for every step.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 36fd3f0d-cdad-424e-af1e-a6685d7025df
📒 Files selected for processing (7)
src/main/java/frc/robot/subsystems/swerve/Swerve.javasrc/main/java/frc/spectrumLib/sim/SimLoop.javasrc/test/java/frc/robot/sim/AutonSimTest.javasrc/test/java/frc/robot/sim/MechanismSimTest.javasrc/test/java/frc/robot/sim/RobotSimTest.javasrc/test/java/frc/robot/sim/SimTestBase.javasrc/test/java/frc/robot/sim/SuperStructureSimTest.java
| /** | ||
| * Advances the simulation loop and notifies each registered callback of the elapsed time. | ||
| * | ||
| * @param dt the elapsed time in seconds since the previous update | ||
| */ |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C3 'javadoc|doclint|Xdoclint' build.gradle build.gradle.kts 2>/dev/null || true
sed -n '45,56p' src/main/java/frc/spectrumLib/sim/SimLoop.javaRepository: Spectrum3847/2026-Spectrum
Length of output: 1453
Remove the invalid @param dt tag. tick() has no dt parameter. Keep the description focused on notifying callbacks with the computed elapsed time.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/main/java/frc/spectrumLib/sim/SimLoop.java` around lines 45 - 49, Update
the Javadoc for the tick() method by removing the invalid `@param` dt tag and
keeping the description focused on notifying registered callbacks with the
computed elapsed time.
| RobotStack stack = createRobotStack(); | ||
| try (Swerve swerve = stack.swerve) { |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C2 'sourceCompatibility|targetCompatibility|JavaLanguageVersion' build.gradle build.gradle.kts 2>/dev/null || true
rg -n -C2 'try \(Swerve swerve = stack\.swerve\)' src/test/java/frc/robot/simRepository: Spectrum3847/2026-Spectrum
Length of output: 2536
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- test files ---'
cat -n src/test/java/frc/robot/sim/RobotSimTest.java
cat -n src/test/java/frc/robot/sim/SuperStructureSimTest.java
cat -n src/test/java/frc/robot/sim/AutonSimTest.java
printf '%s\n' '--- RobotStack and Swerve declarations/usages ---'
rg -n -C3 'class RobotStack|record RobotStack|stack\.swerve|class Swerve|interface Swerve|implements .*AutoCloseable|close\(' src/main/java src/test/java build.gradle gradle.properties 2>/dev/null || true
printf '%s\n' '--- PMD configuration and Java toolchain ---'
rg -n -C3 'pmd|PMD|sourceCompatibility|targetCompatibility|toolchain|JavaLanguageVersion' . -g '!build' -g '!node_modules' -g '!vendor' 2>/dev/null || trueRepository: Spectrum3847/2026-Spectrum
Length of output: 13135
🏁 Script executed:
#!/bin/bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
cat >"$tmpdir/TryResourceField.java" <<'JAVA'
public class TryResourceField {
static class Resource implements AutoCloseable {
public void close() {}
}
static class Holder {
Resource resource = new Resource();
void method() {
try (resource) {
System.out.println("body");
}
}
}
public static void main(String[] args) {
new Holder().method();
}
}
JAVA
if command -v javac >/dev/null 2>&1; then
javac --release 17 "$tmpdir/TryResourceField.java"
echo 'Java 17 accepts an instance-field try-with-resources reference.'
else
echo 'javac is unavailable; source-level behavior requires manual verification.'
fiRepository: Spectrum3847/2026-Spectrum
Length of output: 238
🌐 Web query:
Java 17 JLS try-with-resources VariableAccess field access effectively final resource
💡 Result:
As of Java 17 and later, the Java Language Specification (JLS) allows a try-with-resources statement to use an existing variable as a resource, provided that the variable is final or effectively final [1][2]. This capability was introduced in Java 9 to simplify resource management [1][2]. Under the JLS, the resource specification in a try-with-resources statement can consist of: 1. A formal local variable declaration (the original Java 7 approach) [2][3]. 2. A reference to an existing final or effectively final local variable [1][2]. It is important to note that field access or other arbitrary expressions (such as array access or method calls) are not permitted directly within the resource specification [4]. The resource must be a simple variable name that refers to an object implementing AutoCloseable [4]. If you need to manage a resource accessed via a field, you must first assign that field to a local variable and ensure that the local variable remains effectively final before using it in the try-with-resources statement [4]. A variable is considered effectively final if its value is not changed after it is initialized [2]. If you attempt to use a non-final or non-effectively final variable (e.g., a variable reassigned later in the scope) as a resource, the compiler will issue an error [2]. The requirement for a final or effectively final variable ensures that the resource being closed is the same one intended throughout the block's lifecycle, avoiding ambiguity [5].
Citations:
- 1: https://alidg.me/blog/2017/8/8/try-with-resources-effectively-final
- 2: https://www.baeldung.com/java-try-with-resources
- 3: https://stackoverflow.com/questions/26331705/why-cant-i-reuse-a-reference-variable-in-a-try-with-resources-try-clause
- 4: https://errorprone.info/bugpattern/TryWithResourcesVariable
- 5: https://bugs.openjdk.org/browse/JDK-7196163
🌐 Web query:
site:docs.oracle.com/javase/specs/jls/se17/html/jls-14.html try-with-resources VariableAccess FieldAccess
💡 Result:
In a try-with-resources statement in Java, the resources declared within the resource specification act as local variables [1]. These variables are scoped strictly to the try-with-resources statement itself, meaning they are accessible within the associated try block and any corresponding catch or finally blocks [1]. Regarding VariableAccess and FieldAccess, there are no special restrictions imposed by the try-with-resources construct that prevent you from accessing class fields or other variables that are in scope [1]. You can access instance or static fields of an object, or any other accessible variables, from within the body of the try-with-resources statement just as you would in any other block of code [1]. The resource variables declared in the header are simply treated as local variable declarations, adhering to standard Java scoping and access rules [1].
Citations:
🌐 Web query:
Java 17 javac try (object.field) field access try-with-resources
💡 Result:
In Java 17, the try-with-resources statement does not support arbitrary field access expressions (such as object.field) directly within the resource specification [1][2]. Starting with Java 9, the try-with-resources statement was enhanced to allow the use of existing variables, provided they are declared as final or effectively final [2][3][4][5]. However, this support is strictly limited to variable identifiers; it does not extend to general expressions like field access expressions (object.field) or array access expressions [2][6][5]. If you attempt to use a field expression like try (this.field) { ... } or try (obj.field) { ... }, the compiler will generate an error because the syntax requires a simple variable identifier [4][5]. To use an instance field in a try-with-resources statement, you must first assign the field's value to a local final or effectively final variable [2][3]: final var myResource = this.field; try (myResource) { // Use myResource here } This design restriction exists for several reasons: 1. Stability: Fields can be modified by other threads or parts of the program during the execution of the try block, which could lead to unpredictable behavior regarding resource cleanup [2][3][4]. 2. Complexity: Allowing general expressions introduces significant specification and implementation complexities, particularly concerning how to evaluate the expression, when to capture its value, and how to handle potential side effects [6][5]. 3. Semantics: Requiring a simple variable identifier ensures clarity regarding the lifecycle and closing of the resource [6][5].
Citations:
- 1: https://docs.oracle.com/javase/specs/jls/se17/jls17.pdf
- 2: https://stackoverflow.com/questions/17235307/why-doesnt-try-with-resources-work-with-field-variables
- 3: https://tarikbilla.com/why-doesnt-try-with-resources-work-with-field-variables/
- 4: https://stackoverflow.com/questions/64688022/understanding-try-with-resources-enhancement-in-java-9
- 5: https://stackoverflow.com/questions/16588843/why-does-try-with-resource-require-a-local-variable
- 6: https://bugs.openjdk.org/browse/JDK-7196163
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from urllib.request import urlopen
from re import search
urls = [
"https://docs.oracle.com/javase/specs/jls/se17/html/jls-14.html",
"https://docs.oracle.com/javase/specs/jls/se17/jls17.pdf",
]
for url in urls:
try:
data = urlopen(url, timeout=15).read()
print(f"URL: {url}")
print(f"HTTP bytes: {len(data)}")
if url.endswith(".html"):
text = data.decode("utf-8", "replace")
for needle in ("Resource:", "VariableAccess:", "FieldAccess:"):
pos = text.find(needle)
print(f"--- {needle} ---")
print(text[pos:pos + 1800] if pos >= 0 else "not found")
except Exception as exc:
print(f"URL: {url}\nERROR: {exc}")
PY
printf '%s\n' '--- available Java tools ---'
for tool in javac java ecj kotlinc groovy; do
if command -v "$tool" >/dev/null 2>&1; then
printf '%s: %s\n' "$tool" "$(command -v "$tool")"
fi
doneRepository: Spectrum3847/2026-Spectrum
Length of output: 626
🏁 Script executed:
#!/bin/bash
set -euo pipefail
if command -v curl >/dev/null 2>&1; then
curl --silent --show-error --fail --insecure \
https://docs.oracle.com/javase/specs/jls/se17/html/jls-14.html |
sed -n '/id="jls-14.20.3"/,/id="jls-14.20.4"/p' |
grep -E -A8 -B3 'Resource:|VariableAccess:|FieldAccess:' || true
fi
printf '%s\n' '--- Java compiler module availability ---'
java --list-modules 2>/dev/null | grep -E '^(jdk.compiler|java.compiler)@' || true
printf '%s\n' '--- Java runtime version ---'
java -version 2>&1Repository: Spectrum3847/2026-Spectrum
Length of output: 483
🏁 Script executed:
#!/bin/bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
cat >"$tmpdir/TryResourceField.java" <<'JAVA'
public class TryResourceField {
static final class Resource implements AutoCloseable {
`@Override`
public void close() {}
}
static final class RobotStack {
public final Resource swerve = new Resource();
}
static void useStack() {
RobotStack stack = new RobotStack();
try (stack.swerve) {
System.out.println("body");
}
}
}
JAVA
java --add-modules jdk.compiler com.sun.tools.javac.Main \
--release 17 -d "$tmpdir/out" "$tmpdir/TryResourceField.java"
echo 'Java 17 accepted try (stack.swerve).'Repository: Spectrum3847/2026-Spectrum
Length of output: 201
Remove the unused resource locals and imports.
At all four sites, use try (stack.swerve) and remove the now-unused Swerve imports.
🧰 Tools
🪛 PMD (7.26.0)
[Medium] 21-21: UnusedLocalVariable (Best Practices): Avoid unused local variables such as 'swerve'.
(UnusedLocalVariable (Best Practices))
📍 Affects 3 files
src/test/java/frc/robot/sim/RobotSimTest.java#L20-L21(this comment)src/test/java/frc/robot/sim/SuperStructureSimTest.java#L21-L22src/test/java/frc/robot/sim/AutonSimTest.java#L20-L21src/test/java/frc/robot/sim/AutonSimTest.java#L34-L35
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/test/java/frc/robot/sim/RobotSimTest.java` around lines 20 - 21, At the
four try-with-resources sites in src/test/java/frc/robot/sim/RobotSimTest.java
(20-21), src/test/java/frc/robot/sim/SuperStructureSimTest.java (21-22), and
src/test/java/frc/robot/sim/AutonSimTest.java (20-21, 34-35), remove the local
Swerve resource variable and use stack.swerve directly; remove the now-unused
Swerve imports from all affected files.
Source: Linters/SAST tools
| Swerve swerve = new Swerve(config.swerve); | ||
| FuelIntake fuelIntake = new FuelIntake(config.fuelIntake); | ||
| IntakeExtension intakeExtension = new IntakeExtension(config.intakeExtension); | ||
| DyeRotor dyeRotor = new DyeRotor(config.dyeRotor); | ||
| Launcher launcher = new Launcher(config.launcher); | ||
| LauncherTower launcherTower = new LauncherTower(config.launcherTower); | ||
| Turret turret = new Turret(config.turret); | ||
| Hood hood = new Hood(config.hood); | ||
|
|
||
| SuperStructure superStructure = | ||
| new SuperStructure( | ||
| swerve, | ||
| fuelIntake, | ||
| intakeExtension, | ||
| dyeRotor, | ||
| launcher, | ||
| launcherTower, | ||
| turret, | ||
| hood); | ||
|
|
||
| return new RobotStack( | ||
| config, | ||
| swerve, | ||
| fuelIntake, | ||
| intakeExtension, | ||
| dyeRotor, | ||
| launcher, | ||
| launcherTower, | ||
| turret, | ||
| hood, | ||
| superStructure); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Close Swerve when stack construction fails.
If a constructor after Line 89 throws, createRobotStack() does not return. The caller never enters its try-with-resources block. The Swerve notifier then remains active for later tests.
Close swerve in a catch block before rethrowing the failure.
Proposed fix
Swerve swerve = new Swerve(config.swerve);
- FuelIntake fuelIntake = new FuelIntake(config.fuelIntake);
- IntakeExtension intakeExtension = new IntakeExtension(config.intakeExtension);
- DyeRotor dyeRotor = new DyeRotor(config.dyeRotor);
- Launcher launcher = new Launcher(config.launcher);
- LauncherTower launcherTower = new LauncherTower(config.launcherTower);
- Turret turret = new Turret(config.turret);
- Hood hood = new Hood(config.hood);
+ try {
+ FuelIntake fuelIntake = new FuelIntake(config.fuelIntake);
+ IntakeExtension intakeExtension = new IntakeExtension(config.intakeExtension);
+ DyeRotor dyeRotor = new DyeRotor(config.dyeRotor);
+ Launcher launcher = new Launcher(config.launcher);
+ LauncherTower launcherTower = new LauncherTower(config.launcherTower);
+ Turret turret = new Turret(config.turret);
+ Hood hood = new Hood(config.hood);
- SuperStructure superStructure =
- new SuperStructure(
- swerve,
- fuelIntake,
- intakeExtension,
- dyeRotor,
- launcher,
- launcherTower,
- turret,
- hood);
+ SuperStructure superStructure =
+ new SuperStructure(
+ swerve,
+ fuelIntake,
+ intakeExtension,
+ dyeRotor,
+ launcher,
+ launcherTower,
+ turret,
+ hood);
- return new RobotStack(
- config,
- swerve,
- fuelIntake,
- intakeExtension,
- dyeRotor,
- launcher,
- launcherTower,
- turret,
- hood,
- superStructure);
+ return new RobotStack(
+ config,
+ swerve,
+ fuelIntake,
+ intakeExtension,
+ dyeRotor,
+ launcher,
+ launcherTower,
+ turret,
+ hood,
+ superStructure);
+ } catch (RuntimeException | Error exception) {
+ swerve.close();
+ throw exception;
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Swerve swerve = new Swerve(config.swerve); | |
| FuelIntake fuelIntake = new FuelIntake(config.fuelIntake); | |
| IntakeExtension intakeExtension = new IntakeExtension(config.intakeExtension); | |
| DyeRotor dyeRotor = new DyeRotor(config.dyeRotor); | |
| Launcher launcher = new Launcher(config.launcher); | |
| LauncherTower launcherTower = new LauncherTower(config.launcherTower); | |
| Turret turret = new Turret(config.turret); | |
| Hood hood = new Hood(config.hood); | |
| SuperStructure superStructure = | |
| new SuperStructure( | |
| swerve, | |
| fuelIntake, | |
| intakeExtension, | |
| dyeRotor, | |
| launcher, | |
| launcherTower, | |
| turret, | |
| hood); | |
| return new RobotStack( | |
| config, | |
| swerve, | |
| fuelIntake, | |
| intakeExtension, | |
| dyeRotor, | |
| launcher, | |
| launcherTower, | |
| turret, | |
| hood, | |
| superStructure); | |
| Swerve swerve = new Swerve(config.swerve); | |
| try { | |
| FuelIntake fuelIntake = new FuelIntake(config.fuelIntake); | |
| IntakeExtension intakeExtension = new IntakeExtension(config.intakeExtension); | |
| DyeRotor dyeRotor = new DyeRotor(config.dyeRotor); | |
| Launcher launcher = new Launcher(config.launcher); | |
| LauncherTower launcherTower = new LauncherTower(config.launcherTower); | |
| Turret turret = new Turret(config.turret); | |
| Hood hood = new Hood(config.hood); | |
| SuperStructure superStructure = | |
| new SuperStructure( | |
| swerve, | |
| fuelIntake, | |
| intakeExtension, | |
| dyeRotor, | |
| launcher, | |
| launcherTower, | |
| turret, | |
| hood); | |
| return new RobotStack( | |
| config, | |
| swerve, | |
| fuelIntake, | |
| intakeExtension, | |
| dyeRotor, | |
| launcher, | |
| launcherTower, | |
| turret, | |
| hood, | |
| superStructure); | |
| } catch (RuntimeException | Error exception) { | |
| swerve.close(); | |
| throw exception; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/test/java/frc/robot/sim/SimTestBase.java` around lines 89 - 119, Update
createRobotStack around the Swerve and subsequent subsystem construction so any
constructor failure closes the already-created swerve before rethrowing the
original failure. Preserve normal RobotStack creation and return behavior when
construction succeeds.
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 5 file(s) based on 3 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 5 file(s) based on 3 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
|
last ci ran for an hour i canceled it |
Summary
Adds automated simulation testing to the repository so that robot simulation, mechanism physics, subsystem state transitions, and autonomous routines are tested automatically in CI/CD without requiring GUI/X11 display servers.
Changes
1. Automated Simulation Integration Tests (
src/test/java/frc/robot/sim/)SimTestBase: Shared test fixture that initializes WPILib HAL in simulation mode (HAL.initialize(50, 0)), manages DriverStation simulation states (DriverStationSim), provides time-stepping helperstepSim(dt, duration), and cleans upCommandSchedulerand simulation loops between tests.MechanismSimTest: Tests initialization and simulation loop updates for individual subsystem mechanisms (Hood,Turret,IntakeExtension).SuperStructureSimTest: Tests initialization and coordination ofSuperStructureacross all subsystems and verifies state transitions (e.g.INTAKE_FUEL).AutonSimTest: Tests autonomous chooser registration andAuton.init()execution in simulated autonomous mode.RobotSimTest: TestsRobotSimvisualizer and fuel physics simulation updates in simulated teleop.2. Headless Simulation Support (
build.gradle)wpi.sim.addGui().defaultEnabledandwpi.sim.addDriverstation().defaultEnabledwhen running in CI (CI=true) or when-Pheadless=trueis passed.testLoggingto report passed, skipped, and failed test events in CI logs.3. Subsystem & Sim Lifecycle Hardening
SimLoop.reset(): Added static reset method so step callbacks and notifier threads are cleanly reset between test runs.Swerve.close(): ImplementedAutoCloseableonSwerveto stop the MapleSim simulation notifier thread when a test closes the subsystem.Auton.pathChooser: Added getter annotation so tests can verify SendableChooser registration.4. Local Verification Script & Docs
scripts/verify.sh: Single-command verification script to run Spotless, SpotBugs, and headless unit/simulation tests locally.docs/tools/simulation.md: Documented the new automated simulation testing setup.Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores