Repository navigation
Ariadne L4: the gym (WorldGym, pycvc.WorldGym), and pycvc_gl.cars on it - #1170
Merged
Merged
Conversation
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.
…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.
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).
… into feat/world-gym
Vehicles start on a slope, not inside it
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.
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.
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.
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.
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.
…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 # Conflicts: # docs/PHYSICS_API.md
…/world-gym # Conflicts: # bindings/pycvc/CMakeLists.txt
…/world-gym # Conflicts: # bindings/pycvc/pycvc.i
…/world-gym # Conflicts: # src/cvc/CMakeLists.txt
Terrain lab: an Edge picker for the generated world (world.edge)
Generated worlds: water by each cell's depth, and a choice of world edge (walls, shore, none)
Conflict in src/cvc/world/generated_world.cpp: master's #1203 made the terrain generators each app's own (generators(app), terrainFrom), and #1215 had put the shore edge (shore_terrain) in the old make_terrain. shore_terrain now sits beside terrainFrom, which wraps any app's generator in it, so make_terrain(app, p) and to_world_params(app, p) both get the shore. #1203 also broke code that only feat/world-gym has: its edge and gym tests call generate_world, make_terrain and load_string without an app. They make one first now. cvc-cli's cmd_trace and three ariadne_runtime_test rich-text tests do not build on master itself after #1203. This takes #1225's fix for them line for line, so that #1170 builds; the two merge cleanly either way.
…/world-gym # Conflicts: # src/cvc/CMakeLists.txt
Master's #1233 (entity intents) conflicts with this branch's plants, where each plant has its own group and navigator, not one sim. Intents now run per group: the drive's external force is each group's, sampled by its navigator's own agent indices. apply_intents overrides each entity's command on its group's sim and sets or clears each group's ext_force. An external entity's hold reads its speed from pose(), which every plant has. before_step reads and applies the intents, then a gym's one-tick command takes over (command.by "gym"), then each group steps. entity_info keeps this branch's fields and adds master's command_steer, command_accel and intent; the entity keeps both sides' members. ARIADNE.md and the header say each plant's drive has its own force-steering switch.
…/world-gym # Conflicts: # src/cvcGL/ariadne/vehicle_view.cpp
…:fields, WorldGym::plants)
This was referenced Nov 15, 2026
…/world-gym # Conflicts: # src/cvc/CMakeLists.txt
…the 0.01 s clock, real time catching up 0.25 s a frame
…it replays bit for bit
Master's #1235 runs every plant in a scene world's one physics world (fleets per plant; dynamic chassis boxes and kinematic boxes as bodies there; wheel poses). The gym's own plant groups (the dynamic models in a world of their own, the bicycle with no body, the markers that drew it) give way to it. Kept from L4 on master's fleets: a spawn's own plant (entity_spec::plant, vehicles.spawn.plant), the gym's API (reseed, set_wander, command, set_goal, tick_seconds, steps_per_tick, grid) and its per-tick command, the velocity, steer, goal and reach in entity_info, contacts counted from the world's events (a kinematic box's obstacles by its grid footprint, two kinematic boxes by overlap), the terrain's own heights under the vehicles, and world_reset with the new ground bodies.
…/world-gym # Conflicts: # src/cvc/tests/world_generated_test.cpp
…r 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.
…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
# Conflicts: # src/cvc/ariadne/world_vehicles.cpp
…/world-gym # Conflicts: # src/cvc/CMakeLists.txt
…/world-gym # Conflicts: # src/cvc/CMakeLists.txt
…ds (fields, plants) Ariadne gym: what a differentiable twin of the world reads (fields, plants)
…le worlds on the 0.01 s clock, real time catching up 0.25 s One simulation tick: 0.06 s by default everywhere, vehicle worlds on the 0.01 s clock, real time catching up 0.25 s
#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.
transfix
enabled auto-merge (squash)
November 17, 2026 07:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is L4 in ARIADNE_WORLDS.md (sections 14 and 15): the gym. It drives a world document headless with
reset,stepandobserve, a reward and an episode log, from C++ or from Python, andpycvc_gl.cars' controllers run on it.cvc::ariadne::WorldGym(world_gym.h), in core libcvc with no GL:step()steps the world.reset(seed)rebuilds the world as the document built it, with the clock back at tick 0. It seeds every draw (starts, goals, the spawn policy's random draw and round-robin turns) and spawns the agents:countof the first archetype with nav@1, or a list of specs. A seed and a list of commands give the same episode in any gym, which a test checks bit for bit.step(steer, accel)runs one navigator tick (0.05 s, a whole number of physics steps). Each agent's command replaces its controller's for that tick, held to the agent's envelope. A NaN leaves the agent to its controller, so nav@1 is the baseline in the same loop. Goals are held for the episode, andset_goalmoves one.out: off the grid, or 5 m below its ground;terminatedwhen every agent with a goal is at it, or when one agent is out. It istruncatedatmax_steps.step()as itself. The default reward is each agent's progress toward its goal, less 1 per tick it collides, plus 10 when it arrives.<prefix>.gym.*follow the episode.What it needed in the runtime:
WorldVehicles:command, applied at the navigator's tick throughsim_world::override_command;set_goal,set_wanderandreseed;after_step, which counts each physics step's contacts against the vehicles;entity_info: velocity, steering, goal and reach, contacts.WorldSpawns::reseed, andAppRuntime::pause_world.pycvc:
pycvc.WorldGym(pycvc_gym.i). It returns numpy observations and gymnasium's five-tuple fromstep. It also hasset_reward(fn),log(),save_log,set_goalandgrid(), and takes agents as dicts. The GIL is released while the world steps.pycvc_gl.carson the gym:GymCarsgives the template aCarsStateandstep/step_navigator/new_goalsover a gym, so a cars controller runs unchanged in a world document.world_from_gymis the gym's grid as aWorld, for rollouts and rasters.--gym DOCruns the template on it, headless.The template's own worlds and plants (kinematic, dynamic) stay on its
sim_worldandplant_host, because the gym runs Jolt vehicles only.The example:
examples/ariadne/python/world_gym.ariandworld_gym.py.scene.physics, so it runs headless and arigl draws the same document.--navigator.Fixed on the way:
SceneWorld::restartnow gives the vehicles the new ground bodies. A generated world's colliders come back from a restart with new body ids, and the vehicles kept the old list, so after a restart they counted the terrain as an obstacle. That affected nav_plant's contact counts as well as the gym's. The gym resets with a restart, which showed it: before the fix, nav@1 on the generated world logged 1,124 agent-ticks of contact in an episode, and after it 0.Found, not fixed here: on world_gym.ari's generated world (seed 5, half 150), a vehicle placed at about (−51.7, 46.4) falls straight through the ground from its first step. The grid says the ground there is 8 to 10 m up, and the start is a few metres from a building, so the generator's terrain mesh seems to have a hole there. The gym's
outflag ends such an episode (seed 1 ofworld_gym.py --world generated). Also, a generated world's buildings count as its ground, so touching one is not a contact.Docs
Tests (Windows Release)
ariadne_scene_world_test, 6 new tests (AriadneWorldGym.*):pycvc_gym(new): the numpy observation, the five-tuple, scalar and wrong-sized commands, determinism across gyms, a Python reward and its exception, the log, agents as dicts, and refusals.pycvc_gl_cars, section 8:GymCarswith the template's controller, the navigator baseline,new_goals, a rollout on the gym's world, and--gymheadless with its log.AriadneComponents.ShippedExamplesDeclareWhatTheyNeednow accepts a scene that requiresscene.physics(a world that runs headless) as well asgl.scene.[Aa]riadne|[Nn]av|pycvc_world|pycvc_ari|pycvc_gym|pycvc_gl_cars|cvcgl_ariadne|SceneWorld|[Pp]hysics|arigl|[Ww]orld[Rr]ules|room_rules|arisrv|[Jj]ob|plant).world_gym.pyon the flat and generated worlds, with its own policy and with--navigator, and anarigl snapshotofworld_gym.ari(the square, its spawn pads, the World and Physics panels).Also in this PR
Two follow-ups were merged into this branch (#1202 was merged here, not into master), so this PR now carries them too.
The gym follow-up (4a81d3d)
It fixes three of the limits listed above: the gym ran Jolt vehicles only, a generated world's buildings counted as ground, and every episode had the same world.
WorldVehiclesrunsjolt,kinematic,dynamicanddynamic4wentities. The entities on each plant have a navigator of their own.joltisnav_plantin the scene's physics world, as before.kinematicis nav's bicycle, with no body.dynamicanddynamic4waredyn_bike_plantanddyn_4w_plant. Each has its chassis in a physics world of its own that holds the world's colliders.entity_spec::plantorvehicles.spawn.plant; the L2 refusal of non-Jolt plants is gone.GymCarsand--gymtake the cars template's plant names (kinematic,dynamic:roboracer).SceneWorldBody::ground). A vehicle touching a building ishit_obstacle.gym_options::regenerate(regenerate=Truein pycvc), each reset makes the generated world again from its seed (SceneWorld::regenerate_world). Another seed gives another world; the same seed gives the same world back.AriadneWorldGym.EveryPlantDrivesInTheWorld,VehiclesOnOtherPlantsAndTheBicycleTouchandEachEpisodeCanHaveAWorldOfItsOwn.cvcgl_ariadne_physics).pycvc_gymon four plants withregenerate=True.GymCarsonkinematic,dynamic:humveeanddynamic4w.world_gym.pyon each plant: 4 of 4 agents reach their goals on the flat square.Vehicles start on a slope, not inside it (5624aad, #1202)
There was no hole in the generated world's terrain. A Humvee facing uphill on a slope of about 0.75 started with its nose more than a metre below the ground and fell through. Now a start is tilted onto the plane under its chassis and lifted clear of the ground under it. Every plant reads the terrain's own heights, or interpolates the grid bilinearly where there are none. Details and tests are in #1202.
After the merges
The branch also carries master, including #1181, the sea-surface fix for the singleton scan. After a full build at da11281 (Windows Release), 1,382 of 1,382 related ctest passed (
[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).