goal_on_lane knob — scatter goals within waypoint-spacing range#463
Open
eugenevinitsky wants to merge 6 commits into
Open
goal_on_lane knob — scatter goals within waypoint-spacing range#463eugenevinitsky wants to merge 6 commits into
eugenevinitsky wants to merge 6 commits into
Conversation
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 |
60bd5ab to
93cd69b
Compare
40ecbcc to
f5e3f27
Compare
e6249d2 to
38e5cc4
Compare
…e_agent yaml
wandb.init() previously did not set name=, so wandb assigned random names
like "flowing-wind-34". Adds a --run-name CLI flag (top-level config key)
that pufferl's WandbLogger renders against {date} (launch-time YYYY-MM-DD)
and {seed} (args.train.seed) placeholders before passing to wandb.init.
Default is None — wandb auto-name preserved. The single-agent speed-run
yaml opts in by setting run_name: "{date}_seed{seed}", giving identifiable
runs like 2026-05-31_seed0 without per-seed launcher logic.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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>
38e5cc4 to
0f5f922
Compare
ce47759 to
a7cec72
Compare
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
New
goal_on_laneenv knob, defaults toTrue(existing behavior — goals placed along the agent's precomputed route).When
False, each goal is placed at a random drivable point on the map whose Euclidean distance from the previous anchor lies in[min_waypoint_spacing, max_waypoint_spacing]. Anchor is the agent for goal 0, and the previous goal for subsequent goals whennum_target_waypoints > 1.Sampler
pick_random_drivable_position(env, ref_x, ref_y, min_dist, max_dist, *out)does a bounded grid-cell scan around the reference position rather than global rejection sampling:max_dist + half-cell-diagonal.t ∈ [0, 1]along it (segments stored as(start_vertex, end_vertex); the grid stores them in the cell containing the segment midpoint).O(bbox cells)work,O(1)extra memory.Continuous-along-segment sampling avoids quantizing candidate positions to lane polyline vertices.