Skip to content

nav: per-agent footprint radii (heterogeneous fleet) — veh_params rr_col/body_rr_col - #395

Merged
transfix merged 3 commits into
masterfrom
feat/nav-stats-per-agent-rr
Sep 22, 2026
Merged

transfix merged 3 commits into
masterfrom
feat/nav-stats-per-agent-rr

Conversation

@transfix

@transfix transfix commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

First step of pushing per-vehicle nav physics down into cvc::nav: let a mixed convoy drive with real per-vehicle footprints instead of one shared radius.

What

  • veh_params gains optional borrowed columns rr_col / body_rr_col ([n], normalized). Null (default) = every agent uses the scalar rr / body_rr — the same borrowed-pointer pattern as body_offsets/grip, so the homogeneous path is byte-identical and the CPU↔CUDA parity gates are unchanged.
  • rollout_impl reads rr_i / body_rr_i per agent (rr_col[i] ? : rr) at the disc-clearance, barrier, and governor sites; with a null column this is the same float as before, so no existing trajectory moves.
  • sim_world::set_vehicle_radii(rr, body_rr, n) / clear_vehicle_radii() own the columns and point cfg.veh at them (tail-padded with the scalar), so the runtime swarm can set them.
  • Only the CPU rollout reads the columns today; the CUDA twin falls back to the scalar (documented in drive.h) — wiring the device path is a follow-up.

Parity + test

nav_test.PerAgentRadiiOverrideFootprint: a uniform column set to the scalar rr is byte-identical to the scalar path (EXPECT_FLOAT_EQ on positions + min_clearance), and a bigger column actually changes the drive. Because the null/uniform column reproduces the scalar float exactly, existing behavior and the CPU/CUDA parity tests are preserved by construction.

Small and additive, designed to compose with concurrent cvc::nav work. Builds on #394 (min_clearance).

…col/body_rr_col

First step of pushing per-vehicle nav telemetry + physics down into cvc::nav (see
CVC-DBG/cvcdbg docs/nav-stats-design.md, PR 2): let a mixed convoy drive with real
per-vehicle footprints instead of one shared radius.

- veh_params gains optional borrowed columns rr_col / body_rr_col ([n], normalized).
  Null (default) = every agent uses the scalar rr / body_rr — the same borrowed-pointer
  pattern as body_offsets/grip, so the homogeneous path is byte-identical and the
  CPU<->CUDA parity gates are unchanged.
- rollout_impl reads rr_i / body_rr_i per agent (rr_col[i] ? : rr) at the disc-clearance,
  barrier and governor sites; when the column is null this is the same float as before,
  so no existing trajectory moves.
- sim_world::set_vehicle_radii(rr, body_rr, n) / clear_vehicle_radii() own the columns
  and point cfg.veh at them, so the runtime swarm can set them; tail-padded with the
  scalar to never read past a short column.
- Only the CPU rollout reads the columns today; the CUDA twin falls back to the scalar
  (documented in drive.h) — wiring the device path is a follow-up.

Test: nav_test PerAgentRadiiOverrideFootprint — a uniform column set to the scalar rr is
byte-identical to the scalar path (parity, EXPECT_FLOAT_EQ on positions + min_clearance),
and a bigger column actually changes the drive.
…umn set

Extends the per-agent footprint (rr_col/body_rr_col) with the rest of the per-vehicle
physics the heterogeneous-fleet design calls for:

- veh_params gains `mass` (kg) + `mass_col` ([n]). The kinematic bicycle has no dynamics
  so the drive does NOT read mass — it is carried for the fuel model (fuel = f(accel,
  mass, material)) + telemetry. Default 1 keeps mass-weighted terms inert; null column =
  the shared scalar (parity-safe).
- sim_world::set_vehicle_mass / vehicle_mass own + read back the per-agent mass column.
- sim_world::set_vehicle_dims_m(width_m, length_m) takes METRIC per-agent dimensions:
  width DERIVES the drive footprint (rr[i] = width_m[i]/2 in normalized units, via
  cfg.scale) so a wider vehicle keeps more clearance, and length is carried for
  corridor-fit / telemetry. vehicle_dims_m reads them back.

Test: nav_test PerAgentMassAndDims — mass round-trips (and clears back to the scalar), and
a wider fleet's derived footprint changes the drive (positions differ from the baseline).
Parity: mass/mass_col are unread by the drive and the dims path only sets rr_col, so a
fleet with no columns set is byte-identical to before.
@transfix

Copy link
Copy Markdown
Owner Author

Extended: this PR now covers the full per-agent physics column set — footprint (rr_col/body_rr_col), mass (mass_col; drive-agnostic metadata for the fuel model), and dimensions (set_vehicle_dims_m — width derives the footprint, length carried for corridor-fit). New test PerAgentMassAndDims. All null-column paths remain byte-identical (parity).

Completes the per-agent physics column set: a slow heavy truck and a nimble scout can
now carry different top speed, longitudinal accel and wheelbase.

- veh_params gains vmax_col / a_max_col / L_col (borrowed [n]); null = the shared scalar.
- rollout_impl computes vmax/a_max/L PER AGENT inside the lambda and SHADOWS the names the
  loop body already uses, so every use site (the L-derived dmax/tan_dmax/v_creep_cap, the
  vmax-derived sp_min, the curvature and speed limits) picks up the per-agent value with no
  per-site edits. A null column reproduces v.vmax/v.a_max/v.L, and the L-derived thresholds
  recompute to the same float (same inputs, no fast-math), so the homogeneous path and the
  CPU<->CUDA parity gate are byte-identical. Only the CPU rollout reads the columns; the
  CUDA twin falls back to the scalar (documented) — a follow-up.
- sim_world::set_vehicle_kinematics(vmax, a_max, L, n) / vehicle_kinematics own + read back
  the columns (any of the three may be null to keep that param scalar).

Test: nav_test PerAgentKinematics — vmax/a_max/L round-trip (and clear to the scalar), and
a lower per-agent vmax caps the fleet's peak speed below the fast baseline and below its
own vmax/scale.
@transfix

Copy link
Copy Markdown
Owner Author

Added per-agent kinematics (vmax_col/a_max_col/L_col) — the drive computes them per agent by shadowing the names the loop body uses, so all L-derived thresholds follow with byte-identical results on the null path. New test PerAgentKinematics. This PR now covers the complete per-agent physics set: footprint + mass + dimensions + kinematics.

@transfix
transfix merged commit f60098d into master Sep 22, 2026
13 checks passed
@transfix
transfix deleted the feat/nav-stats-per-agent-rr branch September 22, 2026 08:09
transfix added a commit that referenced this pull request Sep 22, 2026
Wire the per-agent columns (rr/body_rr/vmax/a_max/L) into the GPU drive so a
heterogeneous fleet runs on CUDA too, matching the CPU rollout.

- dev_veh gains the 5 borrowed device column pointers (null = the scalar, so the
  homogeneous path is bit-for-bit the legacy kernel). Mass is not here — the kinematic
  drive never reads it.
- d_veh_for(v, i) substitutes the columns into a per-thread copy before d_bicycle, so
  every use site (incl. the L-derived dmax/tan_dmax/v_creep_cap and the vmax-derived
  sp_min) becomes per-agent with no change to d_bicycle — the device mirror of the CPU
  loop's shadowing.
- upload_cols copies each set host column [n] to the device in both batch entry points
  (bicycle_rollout_cuda / drive_step_cuda) and frees them after. The persistent
  sim_world_cuda path keeps the scalar for now (a follow-up).

Test: nav_drive_refinements_test CudaMatchesCpuWithPerAgentColumns — a heterogeneous
fleet (distinct rr/vmax/a_max/L per agent) matches the CPU bicycle_rollout within the
~1e-5 float-equivalence contract. Verified on a GTX 1650 (both this and the existing
scalar-path CUDA parity test pass); the null-column path leaves the CPU/CUDA parity gate
byte-identical.
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