add static obstacle support to the aviary
Re #60. Scoped to static obstacles for this round — the issue mentions lidar/depth as a natural follow-up but those felt like a much bigger conversation about the action/observation space, so this PR keeps things minimal and additive. Happy to take a swing at sensors in a follow-up once this lands and the API shape feels right.
What this adds
PyFlyt.core.abstractions.Obstacle— thin wrapper aroundloadURDFwithuseFixedBase=True, takes a position/orientation/scale and exposes the PyBullet bodyId.Aviary.add_obstacle(urdf, position, orientation=None, scale=1.0)— registers the obstacle with the aviary, callsregister_all_new_bodies()so collisions get tracked, and remembers the spec so it gets respawned onreset().- Three built-in primitive URDFs under
PyFlyt/models/obstacles/:cube,cylinder,sphere. Loadable by name; arbitrary URDF paths also work.
Usage
env = Aviary(start_pos=..., start_orn=..., drone_type="quadx")
env.add_obstacle("cube", position=np.array([2.0, 0.0, 0.5]))
env.add_obstacle("/path/to/wall.urdf", position=np.array([4.0, 0.0, 1.0]))
Collisions show up in env.contact_array the same way drone-drone collisions do.
Tests
tests/test_obstacles.py covers:
- spawning each built-in primitive
- pose round-tripping through PyBullet
- static-under-gravity behaviour
- loading a custom URDF path
- bad-name and bad-shape error paths
- obstacles persisting across
Aviary.reset() - drone↔obstacle collision actually populating
contact_array Obstacle.builtin_obstacles()listing
All 11 obstacle tests pass locally on Python 3.12 / PyBullet 3.2.7. The existing tests/test_gym_envs.py suite (136 tests) still passes — no regressions.
Docs
Added docs_source/documentation/core/abstractions/obstacle.md and hooked it into the abstractions toctree, matching the existing pattern (autoclass + a usage example).
Follow-ups (not in this PR)
- Dynamic / movable obstacles (mass > 0, no fixed base, optional scripted trajectories)
- Range / depth sensors with obstacle-aware observation spaces
Open to any naming / API tweaks before this gets cleaned up.