ENH: seed sensor measurement noise per instance#13
Merged
Conversation
c7ff674 to
18b9952
Compare
zuorenchen
approved these changes
Jun 27, 2026
zuorenchen
left a comment
Member
There was a problem hiding this comment.
Intresting, I've never checked this part and noticed that the sensor noise generation is not seeded
Member
Member
Author
Member
|
Issue opened in BPC to implement this. ARRC-Rocket/BalloonPoppingChallenge#52 |
Sensor noise (white noise and random-walk bias drift in InertialSensor and ScalarSensor, plus the GNSS position/velocity accuracy) was drawn from the global numpy RNG. That made it impossible to reproduce from a seed, and unsafe under multiprocess where workers share the global state. Add a seed argument to the sensor constructors and draw all noise from a per-instance numpy Generator. seed=None keeps the random-by-default behaviour but per instance, so it no longer touches the global RNG, matching how StochasticModel and MonteCarlo already seed. A freshly-constructed sensor replays the same sequence, so reproducibility lives at construction rather than in _reset. Adds tests/unit/sensors/test_sensor_seeding.py.
18b9952 to
15daf41
Compare
test_noisy_barometer asserts a barometer reading within rel=0.03 of the clean pressure, but the reading carries an unseeded Gaussian noise draw plus a +1000 Pa constant_bias the expected value omits, leaving only ~+2.42 sigma of headroom, so it already flaked at ~0.76% on develop (a 20k-trial check: develop 0.77%, this branch 0.75%). Passing a fixed seed makes it deterministic and also exercises the new sensor seed argument.
zuorenchen
reviewed
Jun 27, 2026
thc1006
added a commit
that referenced
this pull request
Jun 27, 2026
Following @zuorenchen's review note on #13, seed the remaining noisy sensor fixtures (noisy_rotated_accelerometer, noisy_rotated_gyroscope) the same way noisy_barometer already is, so the whole sensor suite is deterministic instead of relying on statistical tolerance bounds. Uses the seed argument added in #13.
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.


Sensor noise (white noise and random-walk drift in the inertial sensors, plus the GNSS position/velocity accuracy) was drawn from the global numpy RNG, so it couldn't be reproduced from a seed and was unsafe under
multiprocess, where workers share the global state.This routes every sensor's noise through a per-instance numpy
Generator, via a newseedargument on the sensor constructors.seed=Nonekeeps the random-by-default behaviour, but per instance, so it no longer touches the global RNG. Reproducibility lives at construction, since a freshly-seeded sensor replays the same sequence. That's the same approach the stochastic stack already uses (StochasticModel/MonteCarlo): seed once, draw sequentially.I've also raised this upstream at RocketPy-Team#1042 so we can pull it back once it lands there.
Tests: 6 new in
tests/unit/sensors/test_sensor_seeding.py(reproducible from a seed, decorrelated across sensors, independent of the global RNG, ideal/zero-noise unchanged) plus the existing 36 sensor unit tests pass.