Skip to content

pycvc: nav_sim_world_override, set_pose, plant_host and generate_world (your own commands, any plant, any world) - #1031

Merged
transfix merged 2 commits into
masterfrom
feat/pycvc-nav-override
Nov 7, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/pycvc-nav-override

Conversation

@transfix

@transfix transfix commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Why

The lab's researchers want to drive N Ackermann cars in Python with a controller of their own. They want it on any plant and any world, with the plant and the navigator's settings chosen from an Ariadne document. libcvc already has the pieces:

  • sim_world::override_command replaces the navigator's command for one step;
  • plant_host switches the plant by name, in code or from the state tree;
  • generate_world is terrain_lab's world.

pycvc reached none of them. This PR binds them. The template built on them is the PR stacked on this branch: pycvc_gl.cars.

What

Bindings only: no C++ change.

  • pycvc.nav_sim_world_override(sim, steer, accel)
    • Takes (N,) arrays: steer in rad, + left; accel in normalized / s². The command holds for the next step.
    • A NaN leaves that agent to the navigator.
    • It returns how many agents took a command.
    • On a plant it goes through the plant's own command, so a negative acceleration from rest backs a vehicle up.
  • pycvc.nav_sim_world_set_pose(sim, i, x, y, heading, speed=0) binds sim_world::set_pose.
    • Place the agents, then the plant attaches at their poses.
    • It returns False once a plant owns the poses.
  • pycvc.plant_host(...) binds cvc::physics::plant_host.
    • use(sim, name) takes a name: kinematic, humvee, roboracer, a comma list, dynamic[:presets] or dynamic4w[:presets].

    • pull(app, prefix, sim) reads <prefix>.nav_plant.vehicle live, along with the plant's own knobs.

    • set_geometry(world_geometry) takes a city's or a generated world's colliders, and starts the vehicles on its terrain.

      This sets plant_host_options::plant.ground_height, which nothing set before. Given a city with relief, vehicles spawned at ground_z, under the terrain.

    • kind, driving, limits(i), state(i), vehicle_state(i) and body(i) read the plant.

    • Lifetime: the host holds the sim_world it drives, and puts it back on the bicycle before it goes.

  • pycvc.generate_world(params, building_library="") binds cvc::world::generate_world.
    • params is a dict, by the generated_world node's world.* key names or the struct's.

    • It returns .world() (the world_geometry for physics and nav), .terrain(), .height(x, y) and .info().

    • It is a pure function of its params, so the same keys give the scene node's world.

      Timing: 0.05 s for a 300 m world, 0.15 s at the 600 m default.

  • The pycvc README has a short section on each.

Tests (local: Windows, MSVC 14.44, Jolt on)

test_pycvc_nav_override.py: 17 checks pass.

  • The overridden bicycle matches kinematic_step run in numpy, to 1e-5.
  • A NaN passes through to the navigator.
  • A command holds for one step.
  • The lock and the top speed are held.
  • Malformed arrays are errors.
  • set_pose works.
  • A Jolt Humvee attached at a set pose drives straight, then turns left.

test_pycvc_plant_host.py: 24 checks pass.

  • The generator is deterministic; its key and field names are the same param; unknown or ill-typed params are errors.
  • The presets and check().
  • Jolt Humvees report their limits in nav's frame.
  • A Humvee on a generated world starts on its terrain and drives on an override.
  • A live switch from the state tree goes to RoboRacers; an unknown name is ignored; it goes back to the bicycle, then on to the dynamic plant.
  • Both lifetimes: host first, and sim first.

The existing test_pycvc_gl_ariadne_host.py passes.

…mmands on any plant

sim_world::override_command takes a caller's (steer, accel) for one step in the
navigator's place, on nav's bicycle and on a plant (Jolt's nav_plant, the dynamic
vehicle). pycvc had no way to reach it, so a Python controller could not drive the
agents itself. nav_sim_world_override(sim, steer, accel) takes (N,) arrays (NaN leaves
that agent to the navigator) and returns how many took a command.
nav_sim_world_set_pose(sim, i, x, y, heading, speed=0) binds sim_world::set_pose, so
agents can start at chosen headings before a plant attaches at their poses.

test_pycvc_nav_override.py checks the overridden bicycle against libcvc's
kinematic_step in numpy to float precision, NaN pass-through, one-step scope, the lock
and top-speed holds, malformed arrays, set_pose, and a Jolt Humvee attached at a set
pose driving straight then turning left on a positive steer.
pycvc.plant_host binds cvc::physics::plant_host: the plant a sim_world drives on,
chosen by name (kinematic, humvee, roboracer, a comma list, dynamic[:presets],
dynamic4w[:presets]), in code (use) or live from the state tree (pull reads
<prefix>.nav_plant.vehicle and the plant's own knobs). set_geometry takes a
world_geometry (a city bundle's data_world, a generated world) as the colliders and
starts the vehicles on its terrain (plant_host_options' ground_height, which nothing set
before, so vehicles spawned at ground_z under a city's relief). kind, driving, limits,
state, vehicle_state and body read the active plant. The host holds the sim_world it
drives and puts it back on the bicycle before it goes.

pycvc.generate_world binds cvc::world::generate_world on a dict of its params (the
generated_world node's world.* key names or the struct's) and an optional building
library: world() for physics and nav, terrain(), height(), info(). It is a pure
function of its params, so Python gets the scene node's world from the same keys.

test_pycvc_plant_host.py: 24 checks (generator determinism and errors; the presets;
Jolt Humvees and their limits; a Humvee started on a generated world's terrain and
driven by an override; a live switch from the state tree to RoboRacers, an unknown name
ignored, back to the bicycle and on to the dynamic plant; both lifetimes).
@transfix transfix changed the title pycvc: nav_sim_world_override and nav_sim_world_set_pose (your own commands on any plant) pycvc: nav_sim_world_override, set_pose, plant_host and generate_world (your own commands, any plant, any world) Nov 6, 2026
@transfix
transfix merged commit ba81382 into master Nov 7, 2026
26 of 28 checks passed
@transfix
transfix deleted the feat/pycvc-nav-override branch November 7, 2026 01:07
transfix added a commit to CVC-Lab/GRL-SNAM that referenced this pull request Nov 7, 2026
… GRL-SNAM's policy as a baseline (#155)

* Ariadne: a cars template for your own multi-car controller, on kinematic or Jolt physics

grl-snam ariadne cars runs N Ackermann cars that a controller of the user's own
drives: controller(s, p) at the top of a copyable cars.py gets every car's state
(pose, speed, wheel angle, goal, range rays, collisions, limits) as numpy arrays each
tick and returns (steer, accel) per car, bypassing the navigator. --copy DIR writes
cars.py and cars.ari to edit. The document's sliders feed the controller's parameters
(ctl.*), New goals / Reset call back into Python, and the panels show a row per car
and two plots. --headless --frames N --log run.npz|csv runs without GL and records
every tick's states and commands.

grl_snam.cars is the library under it: plants kinematic (nav's bicycle), jolt
(roboracer, humvee, or a comma list cycled over the cars) and dynamic; worlds flat,
blocks (scaled to the cars) and austin. With a pycvc that has nav_sim_world_override
(transfix/libcvc#1031) every plant runs in libcvc's sim_world with the command in its
navigator's place; with an older pycvc, kinematic runs the same bicycle in numpy and
jolt drives physics_world.drive (no reverse). navigator=True runs libcvc's navigator
as a baseline.

The README, the quickstart and PLANTS.md link the Ariadne ports and the template;
grl_snam/ariadne/README.md gains a 'Write your own multi-car controller' section:
the state, the panels, why the plant is the host's choice and not the document's,
what kinematic vs Jolt means for a controller (steering rate, the driver model, tire
slip, measured), and batch runs. tests/test_cars.py: 23 tests (3 need the override
binding and skip without it; none needs torch).

* cars: Austin with its aerial image, loaded once through the document's data store

--world austin drew the city with load_geometry_bundle, which paints the terrain one
colour, so the aerial image never showed. cars.ari now has the city node live.ari has
(source: data city, shown only on the Austin world), and cars.py loads Austin into the
data store at data.city: an installed bundle when there is one, else
scene-austin-south-small from cvcpkg.org, downloaded once and cached. The terrain is
drawn with satellite.png draped, and grl_snam.cars builds its occupancy and terrain
from the same loaded objects (austin_world(city=...)), so the bundle is read once.
A headless test runs the port on Austin when a bundle is installed.

* cars: run libcvc's multi-car template; GRL-SNAM's policy as the navigator baseline

The template moved to libcvc as pycvc_gl.cars (transfix/libcvc#1035, on #1031's
bindings): general rather than GRL-SNAM specific, with the plant and the navigator's
settings in the document's state tree, Austin from the data: block by default, the
terrain generator as an alternative, rasters and coefficient panels, and the same
run headless. GRL-SNAM keeps a thin entry: grl-snam ariadne cars runs it (or --copy),
and --grl-policy gives libcvc's navigator the published grl-snam-weights policy,
exported to .cvcnav and run in its trained frame (--nav-scale). With a pycvc_gl
before 3.7.12 the entry says what to install.

grl_snam/cars.py and the template copy are gone. The README, the quickstart, PLANTS.md
and grl_snam/ariadne/README.md link to libcvc's docs/CARS.md.
tests/test_ariadne_cars.py: 5 tests (the entry, its message without the template, a
headless run, --copy, the navigator on GRL-SNAM's policy).
transfix added a commit that referenced this pull request Nov 7, 2026
Bumps the project version and every recipe's upstream_version from 3.7.11 to 3.7.12. The v3.7.12 tag on this commit is the first release with the multi-car controller template (pycvc_gl.cars, #1031 #1035 #1040), the hidden-subtree fix in cvcGL (#1037), the discrete-gradient dyn_bike step (#978), semi-implicit Euler by default in the nav rollout (#981), the implicit contact damper (#1004, #1038), and generated_world's roads and water (#1032, #1034).
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