Skip to content

Ariadne gym: what a differentiable twin of the world reads (fields, plants) - #1263

Merged
transfix merged 3 commits into
feat/world-gymfrom
feat/gym-twin-exports
Nov 16, 2026
Merged

transfix merged 3 commits into
feat/world-gymfrom
feat/gym-twin-exports

Conversation

@transfix

@transfix transfix commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #1170 (base feat/world-gym), as #1202 was.

The gym's world isn't differentiated: Jolt isn't, and neither is the physics world the dynamic plants' chassis collide in. So a trainer has to step a model of the gym and let the gym judge the result. libcvc's P8 did this for the Jolt vehicle. This PR exports what such a twin of the gym's world reads. The torch twin built on it is GRL-SNAM's grl_snam.gym_twin (separate PR).

WorldGym::fields()

The world as the agents drive in it now (gym_fields):

  • the navigator's grid (occupancy), its height, and the ground's grip mu;
    • mu is double, as the plants sample it, so a twin's ground matches theirs to the last bit;
    • it is one value today, the dynamic plants';
  • the navigator's own signed distance sdf (WorldVehicles::sdf, cvc::nav::signed_distance), and its gradient sdf_dx, sdf_dy (central differences);
  • the bounds and the cell;
  • the navigator's settings (navigator_params): nav's scale, its tick, the arrival radius, and its vehicle in normalized units.

WorldGym::plants() and WorldVehicles::plants()

Each agent's plant as a cvc::nav::diff model in SI (entity_plant), in the observation's order:

  • dynamic4w: the plant's own dyn4_plant, with its parameters, step limits, substeps, ground reference, state and grip.
    • It also gives nav's last command and what the model took of it in each substep after the driver (applied_accel).
    • Away from a collision, replaying the model from the state before a tick with that command gives the state after it, bit for bit.
  • dynamic: the single-track model the same way, with each step's grade (applied_grade).
  • jolt: the four-wheel model with the vehicle's own numbers (nav_plant::dyn4_si_of), its pose and twist read back from the chassis as dyn_4w_plant reads a collision back (exact false).
  • kinematic: nav's bicycle, with its rear axle, heading and speed, and its limits in metres.

To support the replay, dyn_4w_plant and dyn_bike_plant gain steer_command(i), accel_command(i) and applied_accel(i) (and applied_grade(i) on the single-track plant). They record what the model took each step. Nothing else in either plant changes.

pycvc

  • WorldGym.fields() returns a dict of numpy arrays: occupancy uint8; height, sdf and gradient float32; mu float64.
  • WorldGym.plants() returns a list of dicts: the parameters by their C++ field names, which are also GRL-SNAM's torch twins' names; the state as a numpy array; the limits, the commands and the applied accelerations.

Tests

  • ariadne_scene_world_test:
    • AriadneWorldGym.TheFieldsAreTheNavigatorsGrid: the fields are the navigator's grid, and its signed distance bit for bit; the sign of the SDF and the direction of its gradient at the walls; the navigator's settings.
    • AriadneWorldGym.ThePlantsAreModelsATwinReplays: four agents on four plants. The models and their order are checked. A Jolt state's heading and speed match the observation. On dynamic4w a tick is replayed with diff::dyn4_plant_books from the exported state and command, and equals the plant's next state in all 14 entries (EXPECT_EQ).
  • pycvc_gym: 15 new checks (63 in all) on fields() and plants().
  • Checked locally on this branch (Linux Release, GCC 13, Jolt from deps-jolt-ph):
    • all 13 AriadneWorldGym tests pass;
    • ctest -R "PhysicsDyn4wPlant|PhysicsDynBikePlant|DynContact|PlantHost|NavSimWorldAgents|NavPlant|AriadneWorldGym|AriadneSceneWorld|SceneWorld|pycvc_gym$|pycvc_plant_host|pycvc_world_entities": 98 of 98 pass (5 opt-in NavPlantConvergence benches skip).
  • recipe / macos-latest / Release failed ThePlantsAreModelsATwinReplays in the last bits: arm64 AppleClang contracts the test's inline copy of the model into FMAs. ariadne_scene_world_test.cpp is now built with -ffp-contract=off (/fp:precise on MSVC), as the plant is (b85777d). Checked with clang 18's IR for this file: 387 fmuladd without the flag, 0 with it.
  • clang-format 18 (the cvcpkg build) is clean on the changed lines.

Docs

  • ARIADNE.md, the gym: "A differentiable twin".
  • ARIADNE_WORLDS.md §14: "As built (L4's twin)", with what is not twinned yet:
    • the driver (dyn_driver);
    • contact on the four-wheel model, and its grade_force;
    • grip per cell;
    • a C++ twin rollout.

…in-exports

# Conflicts:
#	src/cvc/physics/dyn_4w_plant.cpp
#	src/cvc/physics/dyn_bike_plant.cpp
#	src/cvc/tests/ariadne_scene_world_test.cpp
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