Skip to content

Conference: an energy budget for avatar movement, set by the relay, the same for everyone - #956

Merged
transfix merged 9 commits into
masterfrom
feat/conf-avatar-energy
Nov 1, 2026
Merged

transfix merged 9 commits into
masterfrom
feat/conf-avatar-energy

Conversation

@transfix

@transfix transfix commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #955 (avatar looks); its diff against feat/conf-avatar-looks is this change only.

The frame (ARIADNE_CONFERENCE_ROADMAP.md §5k)

An avatar is four parts: a look, a body, a controller (what turns intent into forces on the body) and energy (what the controller may spend).

  • Today the server supplies all four.
  • Later a participant picks a server controller (a full Jolt vehicle, like the DBG demo3-csma Humvee), then brings their own vehicle or controller.

What stays fixed throughout:

  • The relay simulates everything; a participant only asks.
  • The server sets the policy: size limits, the energy budget, and what an empty reserve means.
  • Every controller is deterministic and pays from the same reserve.

This PR makes the walker the first controller and gives it the budget.

What changes

Push. The walker pushes with at most force_max, 840 N, whatever the mass.

  • That is the old 12 m/s² at 70 kg; a 140 kg body now accelerates at 6.
  • Before, every mass accelerated alike, so a heavier avatar hit harder.

Cost. Each drive pays for:

  • the positive work it does on the body (slowing down is free);
  • carrying the body along, at 0.2 m g |v|.

Reserve.

  • At most 1.2 kW, from a 30 kJ reserve refilled at 300 W.
  • A 70 kg walker holds 4 m/s for about two minutes, and sustains about 2.2 m/s on resting power.

Server policy.

  • arisrv --avatar-energy on|off.
  • --avatar-empty rest|stop: an empty reserve leaves resting power, or holds the avatar until a quarter has refilled.
  • The policy is written to conf.rooms.<room>.avatars.policy. Both pumps read it into their holons, so the relay simulates and each client predicts with identical numbers.

Reserve replication. The relay publishes each avatar's reserve beside its pose.

  • The path is participants.<pid>.energy; the write gate now makes energy relay-owned.
  • The owner's client corrects its prediction by how far it was off at that server tick.
  • A reconcile replay restores the reserve it started from, so no step is charged twice.

Stamina. (room-avatar HANDLE) also returns stamina, and the My Avatar window shows it.

Testing

  • holon_test HolonEnergyTest (6): a heavier body accelerates at half the rate; a fast walk drains the reserve (549 W against 300 W) and standing refills it; rest settles at 2.18 m/s; stop holds until a quarter refills; the budget off; the prediction matches the server and takes a correction once.
  • The whole holon_test (37) passes, including the earlier push and re-mass tests.
  • holon_sync_test (18): the policy reaches both holons, and the published reserve tracks the authority.
  • room_avatar_test (6): the policy and a reserve round-trip; the gate refuses a client writing its reserve.
  • End to end: a local arisrv logged avatar energy: on, 840 N, 1.2 kW, 30 kJ refilled at 300 W; empty rests. A client walking at 4 m/s read its stamina as 100, then 96, 91 and 86% (about 250 W net).
  • The changed core files compile under emcc. Not run in a browser.

The Avatar window (user: "a window that shows the user's avatar settings and energy budget and ledger", like demo3-csma's)

My Avatar becomes Avatar, modelled on demo3's Ledger & stats screen:

  • Look: the pickers.
  • Body and controller.
  • Energy budget: the reserve as a bar, "spending, 412 W at 3.00 m/s", and the relay's policy line by line.
  • Ledger: started with, refilled, work, carried, overflow, unpaid, relay corrections, now; a residual that shows the lines balance; bars for each spending line's share; distance, time, kJ/km, peak and time exhausted.
  • History: graphs of the reserve and the power over the last minute.

The books. avatar_ledger (in avatar_energy) records every line as the walker spends. reserve = start + refilled - work - carried - overflow + unpaid + corrections, and a relay correction or a policy change is a line of its own.

avatar_panel (new, no GL) is the window's model.

  • update() reads the client holon and the room tree, and keeps 60 s of history.
  • publish() writes text and numbers under <doc>.self.avatar.*.
  • arigl calls both after client_pump and publishes four times a second, so every host shows the same.

A plot: widget for Ariadne: a line graph of comma-separated numbers at a state path, with an optional range, caption and height.

  • ImGui draws PlotLines, which reads out the value under the mouse.
  • Other backends get a text sparkline.
  • Documented in docs/ARIADNE.md.

Picker fix (also on #955, merged in here).

  • Bug: a widget's expression may only call pure functions, so the combos' options: (room-avatar-options ...) never evaluated, and the lists were empty.
  • Fix: on_tick now publishes the labels and the combos split them.
  • Rows: the window's rows are grids of plain state binds, for the same reason (no str-concat in a widget).

Checked:

  • holon_test 37: the books balance after a walk, a rest and a correction.
  • room_avatar_test 7: the panel publishes the look, body, policy, state, balanced books and a capped history.
  • ariadne_loader_test 210: plot: parses, and the shipped examples still declare what they need.
  • Native snapshot of a walking avatar: Teal + Cap; 22.3 kJ of 30.0; ledger +14.5 kJ refilled, −3.2 work, −19.3 carried, −81 J overflow, +280 J corrections, "balances (residual 0.000 J)"; 141 m in 48 s; both plots drawn; no document warnings.

Deploying

This changes how far people can run in the room, so it deploys only on the user's go-ahead, with #955: a new relay and a new page together.

… from the relay's catalog

A client used to draw its own avatar gold and everyone else in a hue derived from their pid, so
nobody saw themselves as others saw them. Every avatar is now drawn from the room tree, the
viewer's own included, and the look can be picked.

- room_avatar.h: the relay seeds conf.rooms.<room>.avatars, a catalog of what avatars may look
  like:
  - colours: Automatic (the pid's hue, the default) and ten named ones;
  - accessories: None (the default), Cap, Top hat, Antenna, Crest, Halo, Backpack, each a few box
    or sphere parts posed from the feet and tinted like the body, the visor, or a fixed colour.
- A participant writes its pick to its own participant.<pid>.avatar.{color, accessory}. The write
  gate already allows that path and nothing else may write it; only the relay writes the catalog.
- resolve_avatar_look turns a pick into what is drawn. A pick the catalog does not offer draws as
  the default. Parts reaching outside an envelope (the 0.5 x 0.5 x 1.7 m body grown 0.15 m
  sideways and 0.3 m up), and parts past six, are dropped: what an avatar wears is cosmetic, and
  the physics body is the same for everyone.
- room_view resolves every pid's look the same way, re-reads choices a few times a second (as it
  does names), and rebuilds a marker when its look changes. avatar_look() reports what a marker
  was built with.
- New verbs: (room-avatar-options ROOM KIND), (room-avatar HANDLE) and
  (room-set-avatar HANDLE COLOR ACCESSORY), the last refusing what the catalog lacks.
- conference_roster.ari: a My Avatar window (Colour and Wear pickers, also on the View menu). Its
  on_tick shows the current look once the catalog arrives and writes a changed pick.
- arisrv seeds the catalog beside the scene.

Tests:
- room_avatar_test: the catalog round trip, seeding once, resolution, the envelope, replication
  across three nodes, and the write gate.
- cvcgl_room_view: two viewers draw A identically before and after A picks; the hat sits on the
  body and goes when taken off.
…he same for everyone

Frame for avatars as look, body, controller and energy (ARIADNE_CONFERENCE_ROADMAP.md §5k). The
server supplies every part today. Later a participant picks a server controller (a Jolt vehicle
among them) or brings their own body or controller, under the same authority and policy. This
change makes the walker the first controller and gives it an energy budget.

- avatar_world: the walker pushes with at most force_max (840 N) whatever the mass. That equals
  the old 12 m/s^2 at the default 70 kg, and a 140 kg body now accelerates at 6.
- What each drive costs: the positive work it does on the body, plus carrying the body along at
  0.2 m g |v|. Slowing down is free.
- The reserve: at most 1.2 kW, from a 30 kJ reserve refilled at 300 W.
- What that gives: a 70 kg walker holds 4 m/s for about two minutes on its reserve, and
  sustains about 2.2 m/s on resting power.
- The relay sets what an empty reserve means: rest (only resting power) or stop (no speeding up
  until a quarter has refilled).
- Policy: arisrv --avatar-energy on|off and --avatar-empty rest|stop. It is written to
  conf.rooms.<room>.avatars.policy, and both pumps read it into their holons, so the relay
  simulates and each client predicts under the same numbers.
- Reserve: the relay publishes each avatar's reserve beside its pose
  (participants.<pid>.energy, relay-owned in the write gate). The owner's client corrects its
  prediction by how far it was off at that server tick. A reconcile replay restores the reserve
  it began from, so no step is paid for twice.
- (room-avatar HANDLE) also returns stamina, and the My Avatar window shows it.

Tests:
- holon_test HolonEnergyTest (6): a heavier body accelerates at half the rate; a fast walk
  drains the reserve (549 W against 300 W) and standing refills it; rest settles at 2.18 m/s;
  stop holds until a quarter refills; the budget off; prediction matches the server and takes a
  correction once.
- holon_sync_test: the policy reaches both holons and the published reserve tracks the
  authority.
- room_avatar_test: the policy and a reserve round-trip; the gate refuses a client's write to
  its reserve.
…r and history

demo3-csma's Ledger & stats screen, for an avatar. The My Avatar window becomes Avatar:
- Look: the colour and wear pickers.
- Body and controller.
- Energy budget: the reserve as a bar, the state ("spending: 549 W at 4.00 m/s") and the
  relay's policy line by line (push, power, reserve, carrying, the speed resting power sustains,
  what an empty reserve means).
- Ledger: where the reserve went since joining (started with, refilled, work, carried, overflow,
  unpaid, corrections, now), the residual that shows the lines balance, bars for each spending
  line's share, and distance, time, kJ/km, peak power and time exhausted.
- History: graphs of the reserve and the power over the last minute.

How it works:
- avatar_physics books every line (avatar_ledger in avatar_energy). It balances:
  reserve = start + refilled - work - carried - overflow + unpaid + corrections. A relay
  correction or a policy change is a line of its own.
- avatar_panel (new) is the window's model, with no GL. update() reads the client holon and the
  room tree and keeps the history, a sample every 0.25 s for 60 s. publish() writes text and
  numbers under <doc>.self.avatar.*. arigl calls both after client_pump, publishing four times a
  second, so every host shows the same.
- A plot: widget for Ariadne: a line graph of comma-separated numbers at a state path, its range
  given or fitted, with a caption and a height. ImGui draws PlotLines, which reads out the value
  under the mouse; other backends get a text sparkline.

Fixes the pickers, too: a widget's expression may only call pure functions, so the combos' options
(room-avatar-options) never evaluated and the lists were empty. on_tick now publishes the
catalog's labels newline-joined, and the combos split them, as the device pickers do.

Tests:
- holon_test: the books balance after walking and resting, and after a correction (which is its
  own line).
- room_avatar_test: the panel publishes the look, body, policy, a spending state, balanced books
  and a capped history.
- ariadne_loader_test: plot: parses its range, height and caption.
A widget's expression may only call pure functions, so the combos' options
(room-avatar-options) never evaluated and the Colour and Wear lists were empty; the earlier test
picked through on_tick and did not see it. on_tick now publishes the catalog's labels
newline-joined (avatar.colors, avatar.accessories) and the combos split them, as the device
pickers do; each picker shows once its list has arrived.
# Conflicts:
#	examples/ariadne/documents/conference_roster.ari
on_tick rewrote avatar.colors and avatar.accessories every tick. A list rewritten each tick is
re-read every frame, and a picker that drops out for a frame closes its open popup: in the
browser the Colour and Wear popups did not open, while the device pickers, written once, did.
Compare and write on change, which also spares the per-tick write.
# Conflicts:
#	examples/ariadne/documents/conference_roster.ari
@transfix
transfix changed the base branch from feat/conf-avatar-looks to master November 1, 2026 06:33
#955 landed as a squash, so this branch's copy of it (through 4f3731d) is merged with master taking
4f3731d as the base: master brings #953 and #954, and the branch keeps the energy budget and the
Avatar window on top.
@transfix
transfix enabled auto-merge (squash) November 1, 2026 09:20
@transfix
transfix merged commit 6450cdc into master Nov 1, 2026
27 checks passed
@transfix
transfix deleted the feat/conf-avatar-energy branch November 1, 2026 09:57
transfix added a commit that referenced this pull request Nov 1, 2026
Both sides kept: arisrv takes the --lane-* and --avatar-* flags, the
CMake list gains avatar_panel.cpp beside the pose stream sources, and
server_pump keeps #956's policy sync and reserve writes with #951's
write_poses switch.

The reserve now goes out every step rather than with the tree poses: the
relay writes those only once a second when it streams snapshots, and no
snapshot carries a reserve. write_reserve already thins it (half a
percent of the reserve, or a 5 s heartbeat).
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