Skip to content

add static obstacle support to the aviary#99

Open
evanofficial wants to merge 1 commit into
jjshoots:masterfrom
evanofficial:feat-static-obstacles
Open

add static obstacle support to the aviary#99
evanofficial wants to merge 1 commit into
jjshoots:masterfrom
evanofficial:feat-static-obstacles

Conversation

@evanofficial
Copy link
Copy Markdown

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 around loadURDF with useFixedBase=True, takes a position/orientation/scale and exposes the PyBullet body Id.
  • Aviary.add_obstacle(urdf, position, orientation=None, scale=1.0) — registers the obstacle with the aviary, calls register_all_new_bodies() so collisions get tracked, and remembers the spec so it gets respawned on reset().
  • 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.

Adds an Obstacle abstraction and an Aviary.add_obstacle() helper for
spawning static URDF objects (built-in cube/cylinder/sphere primitives,
or arbitrary URDF paths) that drones can collide with. Obstacles are
remembered by the aviary and respawned across reset().
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.

1 participant