Repository navigation
Conversation
The SDK lets init() block, and libraries do: Pedro Pathing's Pinpoint localizer sleeps 500 ms in its constructor, which teams build in init(). Under forTeamClass such a wait was refused. It now holds init() for whole ticks of sim time, and init_loop() (or start(), if PLAY came first) runs on the tick after it returns. STOP does not interrupt it, as on the robot. Waits in init_loop(), start(), loop() and stop() are still refused.
getRuntime() read one tick short after resetRuntime() then a sleep in an iterative OpMode's init(): the reset was only noticed when the wait resumed on the next tick. Notice it when the wait starts instead.
Author
|
Needed because we build PinpointLocalizer in init() which sleeps 500ms |
saltyeg
added a commit
to Aragon-Robotics-Team/ftc-26-27-BIOBUZZ
that referenced
this pull request
Nov 4, 2026
…tPack's build of the init() fix setup-sim.bat installs JDK 17, Python (numpy, scipy, trimesh) and AdvantageScope, builds the sim field into AdvantageScope and the sim tests once (doc/sim-windows.md). simloop.gradle takes SimLoop from saltyeg/simloop at the fix for Horizon-36596/simloop#30, so nobody has to build it. replay_auto.py builds the field into the right folder on Windows and Linux (it always wrote the Mac's) and finds JDK 17 on Windows.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An iterative OpMode's
init()may now wait underforTeamClass. AThread.sleep(orTimeUnit.sleep,SystemClock.sleep) there holdsinit()forceil(ms / tick)ticks of sim time, soThread.sleep(500)takes exactly 25 ticks of 20 ms. Before, any wait in an iterative OpMode was refused and failed the run. Waits ininit_loop(),start(),loop()andstop()are still refused, and so are waits on threads the OpMode starts.No public API changes. Only the
SimClockSchedulerjavadoc changed, to describe the new case. This is a behaviour change: code that used to fail the run with a refusal now runs.Why
The SDK lets
init()block:OpMode.internalRunOpMode()calls it on the OpMode's own thread and startsinit_loop()only once it returns. Libraries rely on that. Pedro Pathing's Pinpoint localizer sleeps 500 ms in its constructor while the device calibrates, and teams build the follower ininit(). Such an OpMode works on the robot but could not run in SimLoop.While
init()waits, the sim matches the SDK:init()keeps turning. No other OpMode method runs.init_loop()starts on the tick afterinit()returns.init_loop()is skipped andstart()and the firstloop()run on the tick afterinit()returns.init()finishes,start()runs if PLAY had come, andstop()runs.timeare not updated during the wait, as the SDK updates them only before a call.getRuntime()follows the sim clock, including across aresetRuntime()made just before the wait.How I tested it
New
IterativeInitWaitTest(9 tests) pins each rule above. It covers the wait length and the tickinit_loop()starts on, PLAY and STOP during the wait, a Pedro-style localizer that sleeps in its constructor (withSimClockLoader.PEDRO_PATHINGin the team packages), the same telemetry on two runs,getRuntime()afterresetRuntime()and then a sleep, and refusals ininit_loop()and on a helper thread started ininit()../gradlew test,./gradlew :SimLoop:docsSiteandbash tools/leak-gate/leak-gate.shall pass../gradlew testpasses on my machineNew or changed behaviour has a test
If I touched docs or public javadoc:
./gradlew :SimLoop:docsSitepassesChecklist