4.2 Simulation validation: scenarios and thresholds
The maple-sim SIMBOT physics suite uses maple-sim 0.4.0-beta, a 50 Hz fixed timestep,
and a fresh JVM per scenario. Run these commands from tests/robot/java_sim/:
./gradlew test
./gradlew test --tests "frc.robot.sim.*"Host timing
The follower is time-controlled and physics advances in fixed steps. Host scheduling can change how far the simulated robot moves within a test’s time budget, so metrics must be compared on the same test machine.
These scenarios are tagged fidelity and excluded when CI is set. CI checks
that every routine lowers a runtime and takes the drivetrain. Establish a local
baseline on the test machine and run the full suite after tuning changes.
What each scenario measures
Each scenario defines its own path so competition-route tuning leaves the scenario baseline unchanged.
| Scenario | Path | Vision | Measures |
|---|---|---|---|
| S1 straight | 4.8 m straight leg down the neutral lane, x 6.00 -> 10.80 at y 4.03 | off | clean straight-line tracking; the only scenario that also asserts final heading |
| S2 multi-segment | (1.50, 4.00) -> (3.30, 4.00) -> (2.00, 5.50), Arrival.STOP between | 15 Hz | junction behavior and multi-leg sequencing |
| S3 obstacle route | S1’s lane, with a 0.80 m radius avoid circle at (8.40, 4.03) | 15 Hz | the planner detouring and rejoining |
| S4 disturbance | S2’s path, with a 1.2 m lateral shove at 2.0 s | 15 Hz | recovery; asserts a tracking spike above 0.6 m and completion afterward |
| S5 odometry stress | S2’s path | off | odometry drift with no vision correction |
| S6 dynamic obstacle | straight leg with an avoid zone injected mid-path | 15 Hz | replanning around something that appears after planning; asserts zero contact |
Thresholds
The table lists the bounds asserted by the test classes. Each bound was set as the worst observed over 12 fresh-JVM runs x 1.4, then rounded. The margin allows observed run-to-run variation while requiring completion and bounded tracking, drift, and final error.
Translation errors are in meters. FINAL_ROT_MAX is in radians.
| Scenario | TRACK_MAX | DRIFT_MAX | FINAL_POS_MAX | FINAL_ROT_MAX |
|---|---|---|---|---|
| S1 straight | 0.03 | 0.13 | 0.04 | 0.02 |
| S2 multi-segment | 0.05 | 0.06 | 0.19 | not asserted |
| S3 obstacle route | 0.27 | 0.06 | 0.15 | not asserted |
| S4 disturbance | 1.68 | 1.71 | 0.17 | not asserted |
| S5 odometry stress | 0.04 | 0.09 | 0.14 | not asserted |
| S6 dynamic obstacle | not asserted | not asserted | 0.40 | not asserted |
There is no separate completion-time assertion. completed() is only true when
the route finishes inside the harness cap, so asserting it already bounds the time.
S1 asserts final heading for straight-line motion with a fixed heading. S2 to S6 record their mode-dependent final headings without a heading assertion.
S1’s final position bound comes from 12 runs on 2026-10-09 with the follower’s default gains of 8 (translation) and 6 (heading). The worst was 0.023 m. The robot reaches the 5 cm arrival tolerance still slowing and coasts the rest. The same runs’ worst tracking errors were S1 0.017, S2 0.041, S3 0.020 and S5 0.013 m.
S4 also asserts a lower bound (maxTrackingErrorM > 0.6) so the shove must register.
Its upper bounds derive from its own displacement of about 1.2 m x 1.4 instead of
from the millimeter-scale tracking of the other scenarios.
Determinism
maple-sim steps physics in per-JVM hash order, so metrics vary run to run. Tests fork one JVM
per class (forkEvery = 1) because maple-sim shares one drivetrain per JVM and exposes no
module-azimuth reset. A shared JVM would carry module state between scenarios.
CI also runs one fork at a time (maxParallelForks = 1). Two physics JVMs on a
two-core runner starve each other enough to produce CommandScheduler loop overruns.
The steer loop is robot-side closed-loop PID (ModuleIOMapleSim), deterministic in
sim time. Hardware uses device control loops and requires separate validation.
Intermittent threshold failures
Investigate the failure before widening a threshold. Retain the completion and
S4 spike assertions. In one observed case S6’s zero-contact check
can trip with visionStack = UNTESTED. PhotonVision sim noise perturbs the estimate
enough that the detour occasionally clips the injected zone.
SimSession experiments
frc.robot.sim.SimSession controls the headless robot’s pose, alliance, mechanism
activity, and enabled state. It wraps SimRobot and TempoTrackingMonitor.
This fragment runs inside a JUnit test in frc.robot.sim. The complete test is
ControlPathPinsTest.
import static org.junit.jupiter.api.Assertions.assertTrue;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import frc.robot.RobotState;
import frc.robot.auto.tempo.TempoRoutines;
SimSession sim = SimSession.get();
var routine = new TempoRoutines(
sim.drive(), sim.container().intake(), sim.container().superstructure())
.routines().get("Half: Straight Sprint");
try {
sim.teleport(new Pose2d(2.90, 1.30, Rotation2d.fromDegrees(90)));
sim.forceIntake(RobotState.IntakeActivity.INTAKING);
var result = sim.runAuto(routine, 12.0);
assertTrue(result.commandFinished());
assertTrue(sim.monitor().maxCommandPathMismatch() < 1e-6);
} finally {
sim.forceIntake(null);
sim.disable();
}Use one SimSession/RobotContainer per JVM, with each experiment in its own test
class and forkEvery = 1. runAuto enables autonomous, schedules the command,
and ticks until completion or the time cap. disable cancels commands and stops
the drive. The fixture loads the measured pack at
tests/fixtures/planning/fields/rebuilt2026Field.toml. Robot startup selects the
deploy pack or the artifact’s bundled default. The matching on-robot health
signals are TempoDiag/CommandPath/* and Diag/PhoenixSignalMaxAgeS.
Planner and collider differences
The planner uses a pack matching the field drawings. maple-sim uses the stock Arena2026Rebuilt collider, which has no public alignment API. The four recorded differences are:
- Field width 8.0693 m (planner) vs 8.052 m (collider).
- Red tower symmetric (planner) vs +279 mm asymmetric (collider).
- Red-far trench cap present (planner) vs omitted (collider).
- Bumps are crossable terrain to the planner, and RobotBumpSim owns their physics.