feat(rl): Gymnasium QuadcopterEnv with modular action/obs/reward/task system#5
Merged
Conversation
… system Adds drones_sim.rl package — a standard gymnasium.Env wrapper around QuadcopterDynamics. The design is fully modular: Actions (drones_sim/rl/actions.py) - MotorSpeedAction — raw 4-motor speeds [0, 4000] rad/s - ThrustBodyRatesAction — [thrust_N, wx, wy, wz] (recommended default) Observations (drones_sim/rl/observations.py) - RelativeStateObs — 17-D: [pos_err, vel, quat, omega, prev_action] Reward (drones_sim/rl/reward.py) - RewardConfig dataclass with per-term weights - reward() function — dense pos tracking + sparse reach bonus Tasks (drones_sim/rl/tasks.py) - HoverTask — fixed target position - WaypointTask — sequential waypoints with auto-advance - TrackingTask — trajectory reference follower Env (drones_sim/rl/env.py) - QuadcopterEnv(gym.Env) — reset/step/render/close - Motor lag pre-fill in reset() to prevent first-step altitude dip - Crash detection: ground contact, excessive tilt, out-of-bounds - Optional viser live rendering Tests (5 new in tests/test_rl_env.py) - gymnasium Env contract (shapes, dtypes, finiteness) - Reward bounds at near-hover (±20) - Hover baseline no-crash (ThrustBodyRatesAction) - Determinism with seed (obs + trajectory) - All tests skipped gracefully if gymnasium not installed Dependency: gymnasium is an optional extra (pip install gymnasium). The package imports gracefully fall back if gymnasium is absent.
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.
M2a — RL Gymnasium Environment
New package
drones_sim.rl— fully modular RL environmentFiles:
env.pyQuadcopterEnv(gym.Env)— wrapsQuadcopterDynamicsactions.pyMotorSpeedAction,ThrustBodyRatesAction(default)observations.pyRelativeStateObs(17-D)reward.pyRewardConfig+reward()— dense pos + sparse reachtasks.pyHoverTask,WaypointTask,TrackingTaskDesign highlights:
reset()prevents first-step altitude dip crashpip install gymnasium)np.random(SensorNoiseModel compat) and isolateddefault_rngTests — 5 new:
@pytest.mark.skipifwhen gymnasium absentDependency: gymnasium is NOT required for the core package — added as a test-time dep via
pip install gymnasium.Next: PR6 — training scripts + smoke-train (PPO) 🚀