Skip to content

One simulation tick: 0.06 s by default everywhere, vehicle worlds on the 0.01 s clock, real time catching up 0.25 s - #1275

Merged
transfix merged 3 commits into
feat/world-gymfrom
feat/sim-tick
Nov 16, 2026
Merged

transfix merged 3 commits into
feat/world-gymfrom
feat/sim-tick

Conversation

@transfix

Copy link
Copy Markdown
Owner

Stacked on #1263 (base feat/gym-twin-exports), which is stacked on #1170.

Joe, 2026-11-14:

  • "the sim tick should be configurable, but everything should use the same default. Realtime should tick against world time at a sensible slice";
  • "0.06 s default, 0.25 s cap".

This is T1 of that plan, libcvc's part (CVC-DBG/cvcdbg#294 §7). demo3 (T2) and GRL-SNAM's hosts (T3) move in their own repositories.

One tick (cvc/core/sim_tick.h)

  • The constants:
    • kSimTick is 0.06 s, the navigator's trained veh.dt, which every shipped drive policy was trained at;
    • kSimQuantum is 0.01 s, the world-clock roadmap's suite quantum;
    • kSimCatchup is 0.25 s.
  • The helpers:
    • whole_steps(span, step) refuses a tick that is not a whole number of steps;
    • sim_clock_config(scale) is a host's live clock: the quantum, the speed, and a catch-up of 25 quanta (0.25 s) that grows with the speed (cap_scales_with_rate). A stalled frame's time beyond it is dropped and reported (dropped_steps, sim.dropped);
    • adopt_sim_clock(clock) moves a clock that has not ticked onto it, keeping its speed.
  • pycvc has SIM_TICK, SIM_QUANTUM and SIM_CATCHUP.

World documents with vehicles: the 0.01 s clock, physics at 100 Hz

The scenes' default quantum, 1/120 s, divides neither 0.06 s (7.2 quanta) nor 0.01 s. So a scene with world: vehicles: now puts app.world_clock() on sim_clock_config before its physics world is made (SceneWorld::use_vehicle_clock).

  • Both paths call it: SceneWorld::from_scene (headless) and cvcGL's realize_scene (drawn). The drawn-versus-headless state-hash test (cvcgl_ariadne_physics) caught the first version, which only from_scene called.
  • Physics then steps at 100 Hz instead of 120 Hz, and a tick is 6 steps.
  • A clock that has already ticked keeps its quantum (with a warning).
  • Scenes without vehicles keep 1/120 s.

The vehicles, the gym and the cars template

  • WorldVehicles ticks at kSimTick, replacing the constant kNavDt = 0.05. set_tick(s) sets another, which takes effect when the navigator is next built. A tick that is not whole physics steps is held to the nearest one, and the status says so.
  • WorldGym:
    • gym_options::tick (pycvc tick=; 0 means kSimTick);
    • dt() falls back to it;
    • max_steps defaults to 1,000 (60 s at 0.06 s; it was 1,200 at 0.05 s).
  • pycvc_gl.cars:
    • DT is SIM_TICK.
    • A drawn live window now ticks against world time. A clock at the quantum advances by each frame's wall time, catching up at most 0.25 s, and a clock_follower steps the cars the ticks it has passed. Before, it was one tick per frame. run.ticks is then the speed.
    • Headless and captured runs (--frames) stay lockstep, run.ticks ticks a frame, so their logs don't depend on the machine.

Not changed, on purpose

  • plant_log_scene and cvc plant-log's 0.02 s: the drift tooling's 50 Hz protocol, which the P8 fits were measured at.
  • nav::sim_thread's rate-paced constructor.

Tests

  • world_clock_test, two new tests:
    • SimTickTest.TheTickIsWholeQuantaAndRealTimeCatchesUpAQuarterSecond: 6 quanta a tick; 1/120 s refused; a 1 s stall runs 25 quanta and reports the rest dropped; a frame runs the ticks world time passed;
    • SimTickTest.AdoptingTheSimulationClockKeepsTheSpeedAndSparesARunningClock.
  • ariadne_scene_world_test, AriadneWorldGym.TheTickIsLibcvcsOneSimulationTick: a vehicle world's clock and physics at 0.01 s with the 25-quantum cap; the gym's tick at 0.06 s (6 steps, and a step advances 0.06 s); tick = 0.05 gives 5 steps; 0.055 is held and noted; set_tick(0) is refused.
  • pycvc_gym: the constants, the default tick, and tick=0.05.
  • pycvc_gl_cars: two checks count ticks from C.DT rather than assuming 0.05 s ("1 m/s² for 1 s" becomes 20 ticks of DT; the predicted path is 3 s of ticks).
  • Locally, Linux Release with Jolt:
    • all 14 AriadneWorldGym tests pass;
    • world_clock_test passes, 51 of 51;
    • pycvc_gym, pycvc_gl_cars, cvcgl_ariadne_physics and pycvc_world_clock pass.
    • after a full build, the broad set passes, 1,687 of 1,687 (32 skipped): ctest -R "[Aa]riadne|[Nn]av|pycvc_world|pycvc_ari|pycvc_gym|pycvc_gl_cars|pycvc_plant|cvcgl_ariadne|SceneWorld|[Pp]hysics|[Oo]cean|[Pp]lant|[Dd]yn|arigl|WorldClock|ClockFollower|SimTick|arisrv".
  • The example, world_gym.py --world flat:
    • its own policy brings 4/4 home in 21.9 to 26.3 s (it was 22 to 26 s at 0.05 s);
    • --navigator gets 2/4 there in 60 s in two of three episodes, and 4/4 in 19 s in the third (it was 2/4 in 60 s).
  • clang-format 18 is clean on the changed lines.

Docs

  • WORLD-CLOCK-SYNC-ROADMAP.md: "One tick (2026-11-15)".
  • ARIADNE_WORLDS.md §14: the tick.
  • ARIADNE.md: the gym's step, and the intents' tick.
  • CARS.md: the tick and run.ticks in a live window.

Base automatically changed from feat/gym-twin-exports to feat/world-gym November 16, 2026 19:19
@transfix
transfix merged commit 47e5d70 into feat/world-gym Nov 16, 2026
7 checks passed
@transfix
transfix deleted the feat/sim-tick branch November 16, 2026 19:19
transfix added a commit that referenced this pull request Nov 17, 2026
#1258 wrote the arms run's retarget at 3 s as tick 60, a 0.05 s tick.
#1275 made the sim tick 0.06 s, so the leg starts at tick 50. The test
takes the tick as round(3.0 / cars.DT) for the legs, the goals and the
alone run it compares against.
transfix added a commit that referenced this pull request Nov 17, 2026
…it (#1170)

* Ariadne L4: the gym (WorldGym, pycvc.WorldGym), and pycvc_gl.cars on it

A world document driven headless by reset(seed), step(steer, accel) and
observe(), with a reward of the user's and an episode log: one app per gym,
its clock paused, every draw seeded. WorldVehicles gains per-tick commands,
held goals, reseeding and per-step contact counts; SceneWorld::restart hands
the vehicles the new ground bodies. GymCars and --gym run the cars template's
controllers in a world document; world_gym.ari/.py are the example.

* Gym follow-up: every plant in a scene world, buildings as obstacles, a world per episode

WorldVehicles runs jolt, kinematic, dynamic and dynamic4w entities, a navigator per plant (the
dynamic models' chassis in a world of their own holding the world's colliders); entity_spec and
vehicles.spawn.plant name it; across plants vehicles touch by their chassis boxes, and cvcGL draws a
vehicle with no chassis from its pose. A world's terrain alone is its ground
(SceneWorldBody::ground), so a building is an obstacle. WorldGym's regenerate makes a generated
world per episode from the reset's seed (SceneWorld::regenerate_world). GymCars and --gym take the
cars template's plant names; dyn_bike_plant and dyn_4w_plant gain add_desc.

* Vehicles start on a slope, not inside it

A vehicle in world_gym.ari's generated world (seed 1, agent 3 at about
(-51.7, 46.4)) fell straight down from its first step. The terrain
collider has no hole there: a raycast at every free grid cell hits the
ground. The spot is a slope of about 0.75, and nav_plant placed every
start level at one ground sample (the nearest 2 m grid cell under the
rear axle) plus its resting height. Facing uphill, the Humvee's origin
started under the ground at its own centre and its nose more than a
metre deep; a body that starts below a height field falls through it.

nav_plant: with ground_height set, a start is tilted onto the plane
fitted to the ground under its chassis, its origin its resting height
above that plane, then lifted clear of the highest ground under the
chassis and the wheels at full reach. Level ground and a constant
ground_z keep the pose they had.

WorldVehicles: every plant's ground height (and height_at) is the world's
terrain where it has one, the physics collider's own heights, else the
grid bilinear between its samples, not the nearest sample.

Tests: a downward raycast at every free cell of the generated world finds
the ground at the grid's height; twelve Humvees placed on its slopes
(1 in 3 to 1 in 1, up and across) start above the ground and are on it
3 s later (two fell to z -27 before).

* Generated world: a cell's water class is its own depth

Each terrain cell took its material from one raster sample, its NE corner where the raster and
the mesh share samples. On a steep shore that corner can be dry or shallow while the cell is
metres deep, so the navigator and the physics took deep water for drivable ground: 151 cells
deeper than 0.5 m on world_gym.ari's generated world, the deepest at -1.91 m.

The materials stage now classes each cell's water by the mean of its corners against the sea,
with derived_class's depths (deep below sea - 0.5, shallow below sea, sand for a dry cell the
raster called water). A prop's footprint keeps its own material.

Test: WorldGenerated.ACellsWaterIsTheMeshsDepth checks every ungraded cell's class against its
mean height.

* Terrain edge walls: nothing leaves a world over its edge

add_world_geometry adds four static boxes around the rectangle the collide height fields cover
(world_bodies::edges): 2 m thick, 1 cm outside the edge, from 20 m below the lowest height to
20 m above the highest. They are not items and not ground, so a vehicle touching one has hit an
obstacle. SceneWorld keeps them as the terrain node's bodies, so they go and come with it.

world_gym.ari's generated world, seed 1: from agent 1's start (-122.9, -72.6) toward its goal on
the west shore, the vehicle slid down the slippery underwater slope and off the west edge in 14
of 18 runs (3 masses x 3 top speeds x nav@1 and world_gym.py's policy). Now 0 of 18; seeds 1-20
under both controllers have no agent out.

Tests: PhysicsWorldGeometry.NothingLeavesTheTerrainOverItsEdge (a box sliding at 15 m/s down a
mu 0.1 slope stops at the wall; rays down on the edge still meet the terrain) and
AriadneWorldGym.AGeneratedWorldsEdgeHoldsAVehicleIn (Humvees flat out at each edge stay in). The
body counts of generated and data worlds include the 4 walls.

* World edge modes: walls, a shore and the sea, or nothing

What is at a generated world's edge is now a choice (generated_world_params::edge, world_edge):

- wall (the default): the invisible walls of the previous commit.
- shore: a band at the rim (15 % of half, 40-250 m) becomes coast. From the band's inner end the
  ground eases down to a beach sloping 1 in 50 to the waterline, then under the sea to the island
  preset's shelf depth at the edge. Ground already lower keeps its bed. It wraps any terrain
  generator (fbm, dem, registered), lots stay off the shore, and the sea goes on past the world:
  outer_sea() is a ring at the waterline out 6 km, which cvcGL draws under <id>_water. No walls.
- none: the edge is open.

world_geometry::edge_walls() says whether add_world_geometry adds the walls; a generated world sets
it from its edge (only wall), and every other world_geometry keeps them on.

Ariadne: a generated_world node's `edge: wall | shore | none`. pycvc: generate_world's "edge"
param, and info()["edge"]. docs/ARIADNE.md describes it.

Tests: WorldGenerated.AShoreEdgeLinesTheWorldWithABeachAndTheSea (deep water all round the rim, a
sand beach inside it, the relief untouched past the band, the outer sea ring),
PhysicsWorldGeometry.TheEdgeWallsCanBeLeftOut, AriadneSceneWorld.AGeneratedWorldsEdgeCanBeAShore,
cvcgl_ariadne_realize (the drawn outer sea), test_pycvc_plant_host.py.

* Shore edge: a wider coast and a wandering coastline

Rendered, the shore's blend from the relief to the beach was short enough (about 11 m on a 300 m
world) that high ground met the coast as a rock cliff, and the coastline ran dead straight. The
band is now 20 % of half (50-300 m), the blend takes its inner half (sea floor to waterline by
25 %, beach to 50 %), and the coastline lies up to 15 % of the band further in by a smooth wobble
the seed sets. The edge stays the sea floor and the relief past the band is untouched.

* Shore edge: rounded corners, bays and headlands

The shore's coast followed the world's square outline, corners and all. It now follows a rounded
square, |x|^4 + |y|^4 = half^4 (world_shore_roundness), so the corners curve away into the sea,
and its wobble is up to 35 % of the band on longer waves (2.5 and 0.8 bands), for bays and
headlands. The square's edge is still the sea floor everywhere and the relief past the band is
untouched; the test measures the band from the rounded edge.

* Terrain lab: the world's edge is a live setting (world.edge, an Edge picker)

A generated_world node's edge was only its authored `edge:` key, so the terrain lab's World panel
could not change it. It is now a world.* key like the preset: world.edge (0 wall, 1 shore, 2 none),
seeded from the node, read on Regenerate, and part of the world's signature, so an edit marks the
world pending until Regenerate. world_controls.ari has an Edge combo (Wall, Shore, None) after
Water level. The walls follow the new world's colliders, and cvcGL draws or empties the outer sea
on the swap. pycvc_gl.cars logs it with the other world keys.

Tests: AriadneSceneWorld.TheWorldsEdgeIsALiveSetting (seeded 0; 1 waits, then Regenerate makes a
shore world with no walls; 0 brings them back) and the loader's world_controls check for the
Edge picker. Checked drawn too: an offscreen host switched a walled world to Shore and
regenerated it. 711/711 related ctest.

* world_gym.h: clang-format a comment's spacing

* Ariadne gym: what a differentiable twin of the world reads (WorldGym::fields, WorldGym::plants)

* One simulation tick: 0.06 s by default everywhere, vehicle worlds on the 0.01 s clock, real time catching up 0.25 s a frame

* ariadne_scene_world_test: built with -ffp-contract=off, as the plant it replays bit for bit

* Generated world: the cells round a lowered waterline sliver take their water class again

Master's #1271 lowers the terrain mesh's waterline slivers at the end of the grade stage, after
the materials stage classed each cell's water by its corners' mean height. A cell round a lowered
sample kept the class of the ground before it (sand, or shallow water over half a metre deep), so
WorldGenerated.ACellsWaterIsTheMeshsDepth failed. The materials stage's rule is now cell_class(),
and the cells touching a lowered sample are classed by it again from the lowered mesh.

* python_engine: the bridge ops pass self to server_link

#1276 made server_link take the module object (self) so it finds the
link on its own host, and #1302 landed after it with five calls that
pass nothing: room, bridge_presence, bridge_absent, bridge_post and
listen_chat. Master's pycvc-linux build fails on them. Name self in
those five functions and pass it.

* test_pycvc_gl_nav_lab: the retarget's tick from the sim tick

#1258 wrote the arms run's retarget at 3 s as tick 60, a 0.05 s tick.
#1275 made the sim tick 0.06 s, so the leg starts at tick 50. The test
takes the tick as round(3.0 / cars.DT) for the legs, the goals and the
alone run it compares against.
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