ENH: seed the rocket sensors from the scenario seed (closes #52) - #54
Merged
Conversation
Thread the scenario seed into the gyroscope / accelerometer / GNSS sensors via the new ActiveRocketPy sensor seed argument (#13). Each sensor gets a decorrelated sub-stream from SeedSequence([np_random_seed, domain]).spawn(3), clear of the balloon Monte Carlo seed tree, so the noisy-sensor observations are reproducible from the announced scenario seed and independent of the global RNG. Bumps the ActiveRocketPy submodule to develop (e9ebff65), which carries the seed support; adds tests/test_sensor_determinism.py. Closes #52.
zuorenchen
approved these changes
Jul 18, 2026
zuorenchen
left a comment
Member
There was a problem hiding this comment.
LGTM, but let's wait for the changes in ActiveRocketPy on main then merge this
Member
|
thc1006
added a commit
that referenced
this pull request
Jul 27, 2026
A launched rocket currently cannot be packed for submission. pack_for_submission runs the flight through RocketPyEncoder, the flight carries the rocket, the rocket carries its sensors, and a sensor hands back the seed it was built with. Since #54 that seed is a SeedSequence, which the encoder cannot serialize, so packing raises TypeError: Object of type SeedSequence is not JSON serializable. Both scenarios are affected even though their sensors are noise free, because the object is stored regardless. Derive a plain 128-bit int from each spawned child instead. The domain separation and the per-sensor decorrelation are unchanged, and with noise-free sensors the trajectories and scores are identical, which both golden masters confirm. Also stop Gymnasium's unknown-seed marker from crashing the launch: np_random_seed is -1 when np_random was assigned directly, and SeedSequence rejects negative entropy. Draw the entropy from the generator in that case. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
This was referenced Jul 28, 2026
Merged
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.
Closes #52.
Now that the sensor
seedargument from ActiveRocketPy #13 is merged, this threads the scenario seed into the rocket's IMU and GNSS sensors, so the noisy readings come out the same for a given scenario seed and don't depend on the global RNG. Each sensor gets its own sub-stream fromSeedSequence([self.np_random_seed, domain]).spawn(3), with a domain tag that keeps it clear of the balloon Monte Carlo's seed tree so the two can't collide (even if the MC ever runs in parallel).Scenarios #0 and #1 use zero-noise sensors today, so none of the current baselines change. It starts to matter once a noisy-sensor scenario lands (the #2 line in #45).
One thing to check on the submodule: this moves the
ActiveRocketPypin from master (6f640a1) to develop (e9ebff65), since #13 lives on develop. Develop already has the actuator module, so the physics is unchanged, and I ran the full BPC suite (15 passed) plus the determinism tests against it. If you'd rather keep BPC on ARP master, we can release develop to master first and pin that instead. Either way BPCmaincan keep tracking ARP releases.Tests are in
tests/test_sensor_determinism.py: same seed reproduces the stream, different seeds differ, and the noise doesn't depend on the global RNG. Checked locally the way CI does (ruff check,ruff format --check,pytest tests/), all green on 3.14.