WIP: drive: add goal_mode and goal_on_lane knobs#463
Open
eugenevinitsky wants to merge 1 commit into
Open
Conversation
Two orthogonal knobs covering goal placement and episode-end semantics on
goal reach, both defaulting to current behavior:
goal_on_lane=True (default) / False
True -> existing route-based placement (on lane, in front of agent).
False -> each goal at a uniformly random drivable point anywhere on the
map, via the new pick_random_drivable_position helper (mirrors
spawn_agent's lane+geometry pick, sans collision check).
goal_mode="continue" (default) / "terminate"
continue -> existing behavior: reaching a goal advances current_goal_idx;
episode keeps running until scenario_length or the inactive
threshold trips.
terminate -> reaching the goal sets terminals[i]=1 for that agent (no
truncation flag, so PPO does not bootstrap V); env then
add_log + c_reset to advance to the next scenario.
target_type is unchanged -- it still controls obs format (static/dynamic) and
is orthogonal to both new knobs. compute_goals's existing route path is
untouched when goal_on_lane=True.
Files: drive.h struct + defines + compute_goals branch + c_step terminate
hook, env_binding.h exposes GOAL_MODE_* constants, binding.c unpacks both
new kwargs, drive.py validates strings + plumbs through _env_init_kwargs,
drive.ini gives the defaults.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds two orthogonal Drive env knobs: goal_mode (continue default vs terminate, controlling episode-end on goal reach) and goal_on_lane (True default vs False, controlling whether goals are placed along the agent's route or scattered at uniformly random drivable points). Both default to the existing behavior.
Changes:
- Define
GOAL_MODE_CONTINUE/GOAL_MODE_TERMINATE, add fields to theDrivestruct, branchcompute_goalsongoal_on_lane, and end episode on first reached goal when in terminate mode. - Plumb the two new kwargs from Python through
binding.cand export the new int constants fromenv_binding.h. - Validate the new string values in
Drive.__init__and add documented defaults todrive.ini.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pufferlib/ocean/drive/drive.h | New mode constants, struct fields, pick_random_drivable_position, scattered branch in compute_goals, and terminate-on-reach block in c_step. |
| pufferlib/ocean/drive/binding.c | Unpacks goal_mode and goal_on_lane kwargs into the env. |
| pufferlib/ocean/env_binding.h | Exports GOAL_MODE_CONTINUE/GOAL_MODE_TERMINATE to Python. |
| pufferlib/ocean/drive/drive.py | New constructor args with validation; passed through _env_init_kwargs. |
| pufferlib/config/ocean/drive.ini | Adds goal_mode and goal_on_lane defaults under [env]. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+79
to
+84
| ; Episode end on goal reach - options: "continue" (default), "terminate" | ||
| goal_mode = "continue" | ||
| ; True: place goals along the agent's route (existing behavior, on-lane and | ||
| ; in front of the agent). False: scatter each goal at a uniformly random | ||
| ; drivable point anywhere on the map. | ||
| goal_on_lane = True |
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.
Summary
Two orthogonal knobs covering goal placement and episode-end semantics on goal reach. Both default to current behavior — no existing run changes.
These compose with the existing `target_type` (`static`/`dynamic`), which is unchanged — it still controls only obs format.
What's untouched
When `goal_on_lane=True` (default), `compute_goals` falls through past the new branch and runs the existing `compute_new_route` + path-based placement exactly as before. When `goal_mode="continue"` (default), `c_step`'s termination block is identical to today.
Why not extend `target_type` to a third value?
Earlier draft had `target_type="terminate"` but `target_type` is purely an obs-format knob (3-float position vs 5-float position+heading). Stuffing episode-end semantics into it conflates orthogonal concerns. Splitting into `goal_mode` keeps each knob doing one thing.
Files
Phase-1 scope (worth knowing for review)
Test plan
🤖 Generated with Claude Code