Skip to content

Relay 4a-4c: arisrv runs its document's world, sends its vehicles to clients, and they draw them - #1335

Merged
transfix merged 12 commits into
masterfrom
feat/relay-world
Nov 18, 2026
Merged

transfix merged 12 commits into
masterfrom
feat/relay-world

Conversation

@transfix

Copy link
Copy Markdown
Owner

First step of the relay hand-off for local worlds: a server document (arisrv --doc world.ari) now runs its scene's world headless, and a world can declare the vehicles it starts with.

Why

ServerDocument's load hook emptied the parsed scene, so arisrv's document runtime never built a SceneWorld. world: vehicles: parsed and nothing spawned. Separately, a document had no way to populate its world at load: init: runs before the world exists, and WorldVehicles ignores a spawn request that is already set when it starts (so a reload doesn't spawn again).

Change

  • The server document runs its world. The load hook keeps a copy of the scene for the relay to publish (room_world_from_scene, unchanged) and leaves the load's scene alone. The load then builds the scene's world the way any runtime without a scene adapter does: physics world and bodies, world sources, vehicles. It steps on the app's world clock at each step(). This physics world belongs to the document and is separate from the holon's. The entities' table stays under the document's prefix (ui.docs.arisrv), which the relay doesn't send yet; that's the next PR.
  • world: vehicles: start: lists the vehicles a world starts with. Each entry is archetype (required), count (1 to 256), the spawn's name (numbered per entry), team, controller, plant and policy, plus at/heading for a fixed start. They spawn when the world's vehicles are made (WorldVehicles::spawn_starts). Archetypes are checked against archetypes: whichever comes first. A gym's reset still clears them and spawns its own agents.
  • vehicles.spawn.count spawns that many at one request.
  • The room scene's physics warning now says where the physics runs.

Tests

  • ServerDocumentTest.RunsItsScenesWorldAndItsVehicles: five start vehicles drive under nav@1 on the relay's steps, and spawn.count adds two more. It replaces the old "kept but not simulated" test.
  • AriadneWorldVehicles.TheWorldStartsWithItsStartVehicles: parsing and its errors, and a headless runtime spawning the list.
  • Windows Release: 1,656/1,657 of the Ariadne/world/room/arisrv ctest set pass. The one failure was AriadneFrames.AR03b_ProvidersPostToTheirGroup, which passed 3/3 alone; it's a threading test this PR doesn't touch. Changed lines are clang-format clean.

Notes

…ts vehicles

ServerDocument no longer empties the parsed scene at load: it keeps a copy
for the relay to publish (room_world_from_scene) and lets the load build
the scene's world headless, as any runtime without a scene adapter does
(SceneWorld: the physics world and bodies, the world sources, the vehicles
of world: vehicles:), stepped on the app's world clock at each step().
That world is the document's, apart from the holon's; the entities' table
stays under the document's prefix until the relay sends it (4b).

A document's init: runs before its world is made, and WorldVehicles
ignores a spawn request already set when it starts, so a document could
not populate its world at load. world: vehicles: start: lists the
vehicles a world starts with (archetype, count up to 256, name numbered
per entry, team, controller, plant, policy, at and heading), spawned when
the world's vehicles are made (WorldVehicles::spawn_starts). And
vehicles.spawn.count spawns that many at one request.

Tests: ServerDocumentTest.RunsItsScenesWorldAndItsVehicles (five start
vehicles drive under nav@1 on the relay's steps; spawn.count adds two),
AriadneWorldVehicles.TheWorldStartsWithItsStartVehicles (parse and its
errors, and a headless runtime spawning them). The room scene's physics
warning now says where the physics runs.
…them

The relay now sends the vehicles its document runs to every client:

- Who they are: conference::room_entities writes each one's identity
  (name, archetype, plant, controller, team, colours, chassis size, the
  archetype's look with a file's name alone) as the room tree's entities
  section, conf.rooms.<room>.entities, a revisioned section rewritten
  when the vehicles change (WorldVehicles::revision); one that went stays
  with present 0, as the room's objects do.
- Where they are: their poses ride the pose stream beside the
  participants', under entity pids ("~e<id>": no participant's pid, a
  state name, starts with '~'). room_pose_relay::step takes them as extra
  subjects, each due at most every entity_interval_ticks (30 Hz), all in
  a keyframe; one no longer given is in the next snapshot's gone.
- arisrv: a room_entity_relay per room, stepped before the room's drain
  from the server document's SceneWorld vehicles.
- A client: entity_playout, a client holon without physics, so each
  entity is played out as a peer avatar is (the holon's peer playout,
  no body anywhere). apply_pose_snapshot and apply_pose_samples give it
  the entity pids' samples; its pump reads the section when its revision
  moves and drops the entities it no longer lists. arigl feeds and pumps
  one; drawing them is the next step.

Tests: RoomEntities.TheirPidsAreNoParticipants,
TheSectionCarriesThemAndMarksTheOnesThatWent and
TheRelaySendsThemAndAClientPlaysThemOut (relay to decoder to playout, the
30 Hz rate, an entity that goes); ServerDocumentTest's world test now
runs a room_entity_relay over its live vehicles (seven listed and posed,
rewritten only on a change, six after a removal).
room_view::update_entities draws each entity a client's playout shows
(entity_playout, 4b) as a vehicle: vehicle_view's box look (chassis,
cabin, four wheels), sized from its identity, in its two colours, posed
at its chassis's centre and heading, and named among the labels. Its
node is built again when its identity changes and removed when the room
drops it; the view's teardown removes them too. A model look is drawn as
its box for now: the relay's model files are its own, and the client
does not look for the model itself yet.

room_entity carries its wheels (wheelbase, track, a wheel's radius) from
its vehicle, so the box look's wheels sit where the plant's do.

arigl (and ariglx and the web client, which are arigl) calls it each
frame after the room view's update.

Test: cvcgl_room_view's entities section (no node before a first sample,
posed at its centre, a box look with wheels, rebuilt on a new colour,
removed when dropped, drawn again on return, torn down with the view).
…m end to end

- cvc://worlds/traffic.ari: a stock server world (arisrv --doc): a 160 m
  ground, twelve blocks on a grid of streets, and eighteen vehicles it
  starts with (world: vehicles: start:) driving under nav@1. The blocks
  are plain boxes, so the room publishes them and clients draw them.
- arisrv --doc takes a cvc:// URI (the file libcvc installs), and says
  how many vehicles its document's world runs.
- RoomRelayLoopbackTest.AClientSeesTheServerWorldsVehiclesMove: the
  loopback relay runs the pose stream with the room's entities as arisrv
  does (relay_options::pose_stream), and a client applying its snapshots
  with an entity_playout sees the server document's six vehicles listed,
  posed and moving, within 3 m of where the relay has them.
- ServerDocumentTest.TheStockTrafficWorldRuns (all eighteen placed, most
  driving) and the arisrv_doc_vehicles ctest.
- ARIADNE_WORLDS.md: WD3 started; §14 "On the relay", the start: list,
  the corrected "do not steer around each other" note, and the stale
  "boats drawn as hulls" note replaced (#1316 drew them).
The boat node's tests (AriadneBoatNode.FloatsSteersFromItsKeysAndNavTakesItToItsGoal and
NavTakesTerrainLabsLaunchAcrossTheLake) took 156 and 77 s in master's Debug package job before
#1318's inertial fluid, and ran past ctest's 300 s in #1335's, which builds on it; the crate
drifting in the scene's wind timed out once there too. The binary's tests get 900 s, as the
segmentation action test has.
…its default look

Clients watching a server world drew every entity as its box look. Now a
room entity's model look (a file's name: Humvee.glb, TacticalBoat.glb)
is drawn from the client's own copy, which find_vehicle_model finds in
its cvcpkg packages, fitted to the chassis and set on the ground under
it; one it has not installed is drawn as its box.

- vehicle_view: make_vehicle_model_cache() and attach_vehicle_model(),
  the fitted-model path vehicle_view already uses, for other views (the
  lsystem_coast session's boat node adds the same two, byte for byte).
- room_entity.base_z: the ground under the chassis's centre, relative to
  it, where a fitted model's base goes.
- room_view: each entity's model look resolved locally, the box when it
  is not there or does not read; its own model cache.
- find_vehicle_model: a name without an extension is its .glb
  (TacticalBoat: TacticalBoat.glb, as the vehicle-tactical-boat package
  installs it beside Humvee.glb).
- resolve_vehicle_looks: a boat on the "tactical" preset (which the
  lsystem_coast session's PR adds) defaults to the TacticalBoat model,
  fitted, as a humvee defaults to Humvee.glb.

Tests: LooksAreFoundWhereTheyAre (TacticalBoat by its name and its
file's, the tactical preset's default look); cvcgl_room_view (a model
look the host has not installed is drawn as its box).
transfix added a commit that referenced this pull request Nov 18, 2026
The boat node's tests (AriadneBoatNode.FloatsSteersFromItsKeysAndNavTakesItToItsGoal and
NavTakesTerrainLabsLaunchAcrossTheLake) took 156 and 77 s in master's Debug package job before
#1318's inertial fluid, and ran past ctest's 300 s in #1335's, which builds on it; the crate
drifting in the scene's wind timed out once there too. The binary's tests get 900 s, as the
segmentation action test has.

(cherry picked from commit dc5fff6)
transfix added a commit that referenced this pull request Nov 18, 2026
The boat node's tests (AriadneBoatNode.FloatsSteersFromItsKeysAndNavTakesItToItsGoal and
NavTakesTerrainLabsLaunchAcrossTheLake) took 156 and 77 s in master's Debug package job before
#1318's inertial fluid, and ran past ctest's 300 s in #1335's, which builds on it; the crate
drifting in the scene's wind timed out once there too. The binary's tests get 900 s, as the
segmentation action test has.

(cherry picked from commit dc5fff6)
Relay 4c: clients draw the room's entities
Relay 4b: the room's entities on the wire, and a client's playout of them
@transfix transfix changed the title Relay 4a: arisrv runs its document's world, and a world starts with its vehicles Relay 4a-4c: arisrv runs its document's world, sends its vehicles to clients, and they draw them Nov 18, 2026
@transfix

Copy link
Copy Markdown
Owner Author

This PR now also carries #1336 (4b: the room's entities on the wire and a client's playout) and #1337 (4c: clients draw them), merged into its branch on Joe's ask, so all three land with this squash. #1338 and #1343 stay stacked on top.

transfix added a commit that referenced this pull request Nov 18, 2026
#1339)

* World vehicles steer around each other, on one plant and across plants

The world runtime turned on none of the navigator's inter-agent steering,
so vehicles met only physically: two kinematic boxes drove through each
other, and a kinematic box shoved a dynamic chassis back the way it came.

- cvc::nav::sim_world::set_foreign_agents: points outside the world
  (another fleet's vehicles) that the separation steers each agent away
  from as from a peer; nothing moves them, and min_gap and yielding do not
  see them. Empty by default: runs are byte-unchanged.
- sim_world::config::sep_side and sep_side_radius: passing on the right.
  A peer ahead, within sep_side_radius and no further than sep_radius off
  the agent's line, turns its carrot right by sep_side times the peer's
  weight times the carrot's distance, so two that meet head on both swing
  right and pass, where the push along the line between them only slowed
  them. Default 0 = off. set_separation_side sets them.
- WorldVehicles: on by default (set_avoid, the vehicles.avoid key): every
  navigator's separation at 5 vehicle radii and 1.5 radii of strength, the
  turn at 0.6 with a 20-radius look-ahead, and before each fleet steps the
  other plants' vehicles as its foreign agents. Turning it off changes the
  navigators in place.

Test: AriadneWorldVehicles.VehiclesSteerAroundEachOtherOnOneAndManyPlants
(head on, 0.5 m off one line: two kinematic cars pass 2.40 m apart
instead of 0.50 m; a kinematic car and a dynamic one pass 2.68 m apart
and both get past, where without it the car shoved the other 52 m back;
the key turns it off).

* tests: ariadne_scene_world_test gets 900 s on slow Debug runners

The boat node's tests (AriadneBoatNode.FloatsSteersFromItsKeysAndNavTakesItToItsGoal and
NavTakesTerrainLabsLaunchAcrossTheLake) took 156 and 77 s in master's Debug package job before
#1318's inertial fluid, and ran past ctest's 300 s in #1335's, which builds on it; the crate
drifting in the scene's wind timed out once there too. The binary's tests get 900 s, as the
segmentation action test has.

(cherry picked from commit dc5fff6)
Relay 4d: a stock server world with vehicles, and a client seeing them end to end
Clients draw a room entity's model; the tactical boat's model is its default look
transfix added a commit that referenced this pull request Nov 18, 2026
#1341)

* pycvc_gl.cars.HostCars: the cars template's cars in a host's own world

The cars template ran its cars on worlds of its own (cars.py's builders)
or, with --gym, headless in pycvc.WorldGym's own app, which a drawn host
cannot show. HostCars runs them in the world the host's own document
runs, so a drawn host shows them as that document draws its world, with
the interface Cars and GymCars have (state, step, step_navigator,
new_goals, reset, world): a controller's (steer, accel) goes to each car
as its intent (a replace command until the next call; a NaN leaves the
car to nav@1), step_navigator clears them, and the rays are cast on the
world's grid.

pycvc.WorldEntities gains what that needs: set_goal(id, x, y),
set_wander(on), grid() (as pycvc.WorldGym.grid gives it), and in each
list() entry the entity's velocity, steering, goal, reach, reached,
collided and its body (length, width, wheelbase and its limits).

Test: test_pycvc_gl_host_cars (four cars spawned in a headless host's
world, a CarsState with rays, nav@1 drives them toward their goals, the
controller's command takes over and a NaN gives them back, new goals,
reset); test_pycvc_world_entities and test_pycvc_gl_cars still pass.

* tests: ariadne_scene_world_test gets 900 s on slow Debug runners

The boat node's tests (AriadneBoatNode.FloatsSteersFromItsKeysAndNavTakesItToItsGoal and
NavTakesTerrainLabsLaunchAcrossTheLake) took 156 and 77 s in master's Debug package job before
#1318's inertial fluid, and ran past ctest's 300 s in #1335's, which builds on it; the crate
drifting in the scene's wind timed out once there too. The binary's tests get 900 s, as the
segmentation action test has.

(cherry picked from commit dc5fff6)
@transfix
transfix merged commit d90e34a into master Nov 18, 2026
29 checks passed
@transfix
transfix deleted the feat/relay-world branch November 18, 2026 09:56
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