Skip to content

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/:

Shell
./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.

ScenarioPathVisionMeasures
S1 straight4.8 m straight leg down the neutral lane, x 6.00 -> 10.80 at y 4.03offclean 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 between15 Hzjunction behavior and multi-leg sequencing
S3 obstacle routeS1’s lane, with a 0.80 m radius avoid circle at (8.40, 4.03)15 Hzthe planner detouring and rejoining
S4 disturbanceS2’s path, with a 1.2 m lateral shove at 2.0 s15 Hzrecovery; asserts a tracking spike above 0.6 m and completion afterward
S5 odometry stressS2’s pathoffodometry drift with no vision correction
S6 dynamic obstaclestraight leg with an avoid zone injected mid-path15 Hzreplanning 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.

ScenarioTRACK_MAXDRIFT_MAXFINAL_POS_MAXFINAL_ROT_MAX
S1 straight0.030.130.040.02
S2 multi-segment0.050.060.19not asserted
S3 obstacle route0.270.060.15not asserted
S4 disturbance1.681.710.17not asserted
S5 odometry stress0.040.090.14not asserted
S6 dynamic obstaclenot assertednot asserted0.40not 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.

Java
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:

  1. Field width 8.0693 m (planner) vs 8.052 m (collider).
  2. Red tower symmetric (planner) vs +279 mm asymmetric (collider).
  3. Red-far trench cap present (planner) vs omitted (collider).
  4. Bumps are crossable terrain to the planner, and RobotBumpSim owns their physics.
esc

Loading search...