Skip to content

nav_native, squad: a physics plant option (libcvc P6) - #119

Merged
transfix merged 1 commit into
mainfrom
feat/nav-native-plant
Oct 19, 2026
Merged

transfix merged 1 commit into
mainfrom
feat/nav-native-plant

Conversation

@transfix

@transfix transfix commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

The GRL-SNAM part of libcvc's P6 (the vehicle physics roadmap): a physics plant option on the native path. A native sim_world's agents drive cvc::physics vehicles on Jolt instead of nav's kinematic bicycle, and Squad(plant=...) runs a squad that way.

Draft until libcvc's P6 is released. It needs a pycvc carrying P6's physics bindings: transfix/libcvc feat/pycvc-physics, which opens after P3–P5 merge. Until then nav_native.HAS_PLANT is False everywhere, the new tests skip, and nothing else changes.

What it adds

  • nav_native.JoltPlant: a physics world plus a nav_plant over its vehicles.

    • The world is a flat ground (ground_mu, rolling_resistance). The truth grid's occupied cells become static boxes, merged into rectangles by obstacle_boxes. A vehicle that leaves the plan meets the building it would have met.
    • Vehicles: "roboracer" (the default; the UT-AV lab's 1/10 car, the size of GRL-SNAM's 0.7 m bodies), "humvee", or a pycvc.vehicle_desc.
    • It reads back vehicle_state(i) (wheels, pedals and the energy ledger), energy_J(i), drift_summary() (the plant against nav's bicycle, binned by lateral g) and terrain_config_of.
  • NativeSimWorld gains:

    • set_plant / plant_kind;
    • the P5 terrain calls (set_terrain, terrain_settings, infeasible_entries);
    • pull / publish (sim_world's settings in the state tree);
    • tick.

    sim_world_from_swarm takes plant=.

  • Squad(plant=...) runs the squad in libcvc's C++ sim_world, one private belief plane per agent.

    • The plant is "jolt", a preset name, a JoltPlant, or "kinematic" (nav's C++ bicycle).
    • It keeps step, run, done, the per-agent records and SquadResult, which gains energy_J. Moving goals and FollowGoal work; the latter now reads Squad.position_of.
    • It does not keep the Python path's route spine. The C++ world drives its own carrot, and peers meet as bodies rather than as stamps in each other's truth.
    • It refuses per-agent vmax and sensor overrides, material grids, and (on a plant) a start inside an occupied cell, where a physics vehicle would be wedged.
  • Limits on a plant. GRL-SNAM's limits are in the trained metric: a_lat_max 1.0 normalized is about 2 g. On a plant the navigator plans with the vehicle's limits instead, never more than the story's: 0.8 × max_accel and a_lat_g g (0.5 by default). Found while testing: with the trained metric's 2 g corner cap, a RoboRacer slid at 11–16× its tires' peak slip. It then sat nosed into a corner for 350 ticks.

  • The Python path stays the default, and stays kinematic, since it is what trains.

Measured

City story, 96 cells, known map, two agents crossing (Windows, local libcvc P6 pycvc):

Runtime Ticks Arrived Penetration Wall time
Python 583 both 0 4.6 s
Native kinematic 441 both 0 0.3 s
Jolt RoboRacers 842 both 0 0.7 s

On the plant the agents drew 3.3 and 3.7 kJ from their batteries. A Humvee doesn't fit the city story's streets, as expected.

Tests

  • tests/test_squad_plant.py, 9 tests, all passing against the local build:
    • the boxes cover exactly the occupied cells;
    • a squad on the Jolt plant arrives with no penetration and a few kJ drawn, with its drift summary;
    • determinism on both runtimes;
    • the refused start;
    • a follower tracking its leader;
    • plant selection on a native world;
    • the vehicles' terrain limits;
    • the refused overrides.
  • The rest of the suite: 522 passed, 12 skipped. The 6 failures also fail on main on this box: imageio is not installed (5), and one math.sin result is a ULP off on Windows (1).
  • black --check and ruff check . (ruff 0.16.0, from cvcpkg) are clean.

With a pycvc carrying libcvc's P6 physics bindings, a native sim_world's
agents can drive cvc::physics vehicles on Jolt instead of nav's
kinematic bicycle:

- nav_native.JoltPlant: a physics world (flat ground; the truth grid's
  occupied cells as static boxes, merged by obstacle_boxes) and a
  nav_plant over its vehicles ("roboracer" by default, the size of
  GRL-SNAM's 0.7 m bodies; "humvee"; or a pycvc.vehicle_desc), with
  the vehicle state and energy ledger, the drift summary and
  terrain_config_of.
- NativeSimWorld gains set_plant / plant_kind, the P5 terrain calls,
  pull / publish (sim_world's settings in the state tree) and tick;
  sim_world_from_swarm takes plant=.
- Squad(plant=...) runs the squad in the C++ sim_world, one private
  belief plane per agent, on the plant ("jolt", a preset, a JoltPlant)
  or nav's C++ bicycle ("kinematic"). It keeps step, run, done, the
  records and SquadResult (now with energy_J), and moving goals and
  FollowGoal. On a plant the navigator plans with the vehicle's limits
  (0.8 x max_accel, a_lat_g g), not the trained metric's 2 g. A start
  inside an occupied cell is refused there. The Python path stays the
  default and stays kinematic.

On the city story (96 cells, two agents crossing): Python 583 ticks,
native kinematic 441, Jolt RoboRacers 842 with 3.3 and 3.7 kJ drawn;
all arrive with no penetration. tests/test_squad_plant.py (9) passes
against a local libcvc P6 pycvc and skips without it.
@transfix
transfix marked this pull request as ready for review October 19, 2026 16:26
@transfix
transfix merged commit 3b1b308 into main Oct 19, 2026
5 checks passed
transfix added a commit that referenced this pull request Nov 7, 2026
* release: 0.3.0

95 commits since v0.2.1 (PRs #66 to #158), with new features, so the
pre-1.0 minor version goes up. The main changes:

- Ariadne hosts: GRL-SNAM's demos run as Python hosts of Ariadne documents
  (#147, #149, #153). `grl-snam ariadne cars` runs libcvc's multi-car
  template (#155), and fleet and live take its settings, worlds, plants,
  panels and log (#157). These need pycvc-gl 3.7.12.
- Vehicle plants: capture, the demos, the fog-of-war stories and training
  run on kinematic, dynamic and Jolt plants (#119, #130, #143, #145, #154).
- Torch twins of libcvc, held to its goldens: the material rollout (#118),
  terrain (#120), dyn_bike and dyn4 (#121, #123, #134-#136), the external
  force (#122, #124), the material trainer (#125), belief material
  (#128, #129, #131), U_nav (#133), and the port-Hamiltonian form, its
  energy books, wheel spin and compliant contact (#138, #139, #146).
- The vehicle-plant port-Hamiltonian whitepaper (#137 to #158).
- Training and evaluation: the base scorecard and selection (#82-#98),
  `grl-snam coef-train` (#102), the learned lam head and .cvcnav v2
  (#94, #105), and the 2026-10 audit fixes (#113).
- Data: grl-snam-weights, plus the Austin scene and Humvee as runtime
  dependencies, so `grl-snam demo` runs from a bare install (#72-#77).
- The research core moves under grl_snam/ (#103). The world clock is
  shared with libcvc's (#116, #117).

The version lives in pyproject.toml. The three cvcpkg columns mirror it in
upstream_version and in the package.files dist-info path. cvc_revision goes
back to 1 for the new upstream version. The publish job asks the server for
the next revision in any case.

* material_train_native: pass semi_implicit=False explicitly (libcvc #981)

libcvc #981 (in 3.7.12) changed nav_material_trainer_create's
ms_semi_implicit default from 0 to 1. MaterialTrainer left the L_multi
sampling args out for the legacy single start, so on pycvc-gl 3.7.12
semi_implicit=False quietly ran semi-implicit Euler. #159's CI was the
first run on 3.7.12, and four tests failed on cp311, cp312 and cp313:

- test_sampled_multi_start_args: "semi_implicit did not reach the
  rollout", because the default and semi_implicit=True were now the same
  rollout;
- test_live_native_trainer_agrees[legacy] and [legacy+ext], and
  test_live_native_trainer_agrees_on_the_belief_net[surrogate]: the
  explicit torch trainer and the native one differed by 1.3e-3 to 1.5e-3
  (tolerance 1e-5).

Now a binding that takes the args always gets them, so the integrator is
the one asked for on any pycvc. An older binding still gets the legacy
start through the old signature. GRL-SNAM's default stays explicit Euler.

tests/test_material_train_native_args.py checks both bindings. Its new
case fails without this change.
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