Skip to content

Rename dynamics/geometry fields for clarity (accel_*, *_size) + consolidate corner/coef code#486

Merged
vcharraut merged 4 commits into
emerge/temp_trainingfrom
vcha-emerge/rename-variable
Jun 15, 2026
Merged

Rename dynamics/geometry fields for clarity (accel_*, *_size) + consolidate corner/coef code#486
vcharraut merged 4 commits into
emerge/temp_trainingfrom
vcha-emerge/rename-variable

Conversation

@vcharraut

Copy link
Copy Markdown
Collaborator

What

Naming cleanup + small consolidations in the C sim, with matching updates in notebooks and viz. No behavioral change — pure refactor.

Renames

  • Acceleration: a_long / a_lataccel_long / accel_lat (struct field, obs, rewards, comfort metric, IDM, binding, html-frame, notebooks, viz.py).
  • Array sizes: trajectory_lengthtrajectory_size, segment_lengthsegment_size, state_lengthstate_size on Agent / RoadMapElement / TrafficControlElement, with all consumers updated.
  • Stop-line macros: TRAFFIC_LIGHT_DISTANCE_THRESHOLDSTOP_LINE_DIST_SQ (now pre-squared 10*10), RED_LIGHT_HEADING_THRESHOLDSTOP_LINE_HEADING_THRESHOLD.
  • idm_lane_segment_lengthidm_lane_segment_size; loop var traffictc in load/check/generate paths.
  • Added Agent.id (read from the map binary instead of a throwaway local).

Consolidations (behavior-preserving)

  • check_obb_collision and IDM now use the shared compute_agent_corners instead of inlined box math (SAT is corner-order independent → identical result). Drops the duplicate idm_agent_corners.
  • Extracted zero_agent_velocity_state(agent) for the repeated velocity/accel/jerk zeroing in invalidate_agent and the stopped-agent branch of move_dynamics.
  • generate_reward_coefs: the uniform-sampled coefficients now loop over an index table instead of 12 copy-pasted calls.
  • init() now checks load_map_binary's return and bails with an explicit error instead of ignoring it.

Removed

  • compute_lane_length (one-line wrapper) — callers use lane->length directly.
  • Redundant in-hot-path num_target_waypoints upper-bound recheck in compute_goals (already clamped at the config boundary in drive.py and binding.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 --force builds clean (only a pre-existing fscanf warning in untouched load code).

🤖 Generated with Claude Code

- 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.
Copilot AI review requested due to automatic review settings June 15, 2026 10:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_lataccel_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.

Comment thread pufferlib/ocean/drive/drive.h
Comment thread pufferlib/ocean/drive/drive.h
Comment thread pufferlib/ocean/drive/drive.h
Comment thread pufferlib/ocean/drive/drive.h
Comment thread pufferlib/ocean/drive/drive.h
Comment thread pufferlib/ocean/drive/drive.h Outdated
Comment thread pufferlib/ocean/drive/drive.h
Comment thread pufferlib/ocean/drive/drive.h Outdated
Comment thread pufferlib/ocean/drive/drive.h
Comment thread pufferlib/ocean/drive/drive.h
Comment thread pufferlib/ocean/drive/drive.h

@eugenevinitsky eugenevinitsky left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good PR! Left some comments

@vcharraut vcharraut merged commit 91774df into emerge/temp_training Jun 15, 2026
12 checks passed
@vcharraut vcharraut deleted the vcha-emerge/rename-variable branch June 15, 2026 18:27
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.

3 participants