Rename dynamics/geometry fields for clarity (accel_*, *_size) + consolidate corner/coef code#486
Merged
Merged
Conversation
- Renamed `idm_lane_segment_length` to `idm_lane_segment_size` for consistency. - Updated references to `segment_length` to `segment_size` across multiple files to reflect the new naming convention. - Changed agent acceleration variables from `a_long` and `a_lat` to `accel_long` and `accel_lat` for clarity. - Adjusted traffic control state checks from `state_length` to `state_size` to maintain consistency. - Updated visualization code to use the new variable names for agent dynamics.
There was a problem hiding this comment.
Pull request overview
This PR performs a behavior-preserving refactor across the Drive C simulator and its Python/viz consumers to improve naming clarity (accel_*, *_size) and consolidate duplicated geometry/dynamics helper code.
Changes:
- Renames dynamics fields (
a_long/a_lat→accel_long/accel_lat) and various length/count fields (*_length→*_size) across C, bindings, viz, and notebooks. - Consolidates duplicated math/utilities (shared
compute_agent_corners, shared velocity/accel/jerk zeroing, table-driven reward coefficient sampling). - Tightens/renames stop-line related macros and updates stop-line / traffic-light logic call sites.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pufferlib/viz.py | Updates observation decoding/labels to accel_long/accel_lat. |
| pufferlib/ocean/env_binding.h | Updates HTML-frame observation export to use renamed accel fields and state_size. |
| pufferlib/ocean/drive/visualize.c | Updates trajectory loop to use trajectory_size. |
| pufferlib/ocean/drive/render.h | Updates road/traffic loops and variable naming to use *_size. |
| pufferlib/ocean/drive/idm.h | Switches IDM corner computation to shared helper; renames segment/state fields; updates stop-line macros. |
| pufferlib/ocean/drive/drive.h | Main refactor/renames, consolidations, macro updates, map load error handling changes. |
| pufferlib/ocean/drive/datatypes.h | Renames struct fields (trajectory_size, segment_size, state_size), adds Agent.id, updates comments/macros. |
| pufferlib/ocean/drive/binding.c | Updates Python dict export keys/fields to renamed *_size and accel fields. |
| notebooks/notebook_utils.py | Updates feature name lists to accel naming. |
| notebooks/05_inference.py | Updates labels/comments and plot indices for accel naming. |
| notebooks/01_observations.py | Updates feature lists, titles, and comments for accel naming. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eugenevinitsky
approved these changes
Jun 15, 2026
eugenevinitsky
left a comment
There was a problem hiding this comment.
This is a good PR! Left some comments
…d update references
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.
What
Naming cleanup + small consolidations in the C sim, with matching updates in notebooks and viz. No behavioral change — pure refactor.
Renames
a_long/a_lat→accel_long/accel_lat(struct field, obs, rewards, comfort metric, IDM, binding, html-frame, notebooks,viz.py).trajectory_length→trajectory_size,segment_length→segment_size,state_length→state_sizeonAgent/RoadMapElement/TrafficControlElement, with all consumers updated.TRAFFIC_LIGHT_DISTANCE_THRESHOLD→STOP_LINE_DIST_SQ(now pre-squared10*10),RED_LIGHT_HEADING_THRESHOLD→STOP_LINE_HEADING_THRESHOLD.idm_lane_segment_length→idm_lane_segment_size; loop vartraffic→tcin load/check/generate paths.Agent.id(read from the map binary instead of a throwaway local).Consolidations (behavior-preserving)
check_obb_collisionand IDM now use the sharedcompute_agent_cornersinstead of inlined box math (SAT is corner-order independent → identical result). Drops the duplicateidm_agent_corners.zero_agent_velocity_state(agent)for the repeated velocity/accel/jerk zeroing ininvalidate_agentand the stopped-agent branch ofmove_dynamics.generate_reward_coefs: the uniform-sampled coefficients now loop over an index table instead of 12 copy-pasted calls.init()now checksload_map_binary's return and bails with an explicit error instead of ignoring it.Removed
compute_lane_length(one-line wrapper) — callers uselane->lengthdirectly.num_target_waypointsupper-bound recheck incompute_goals(already clamped at the config boundary indrive.pyandbinding.c).Why
Consistent, unit-bearing names (
accel_*,*_size) and removal of duplicated corner/coef code; macro names now reflect that the check is about stop lines, not just traffic lights.Testing
python setup.py build_ext --inplace --forcebuilds clean (only a pre-existingfscanfwarning in untouched load code).🤖 Generated with Claude Code