Skip to content

ENH: seed the rocket sensors from the scenario seed (closes #52) - #54

Merged
zuorenchen merged 2 commits into
developfrom
enh/sensor-seed-bpc
Jul 26, 2026
Merged

ENH: seed the rocket sensors from the scenario seed (closes #52)#54
zuorenchen merged 2 commits into
developfrom
enh/sensor-seed-bpc

Conversation

@thc1006

@thc1006 thc1006 commented Jun 27, 2026

Copy link
Copy Markdown
Member

Closes #52.

Now that the sensor seed argument 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 from SeedSequence([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 ActiveRocketPy pin 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 BPC main can 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.

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 zuorenchen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but let's wait for the changes in ActiveRocketPy on main then merge this

@zuorenchen

zuorenchen commented Jul 19, 2026

Copy link
Copy Markdown
Member

LGTM, but let's wait for the changes in ActiveRocketPy on main then merge this

Copilot AI review requested due to automatic review settings July 26, 2026 23:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@zuorenchen
zuorenchen merged commit 7939909 into develop Jul 26, 2026
2 checks passed
@zuorenchen zuorenchen linked an issue Jul 26, 2026 that may be closed by this pull request
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] Implement sensor noise random seed from ActiveRocketPy

3 participants