Skip to content

nav_stats: the whole plant ledger on every plant, with vehicle contact and what does not apply - #876

Merged
transfix merged 1 commit into
masterfrom
feat/nav-ledger-every-leaf
Oct 29, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/nav-ledger-every-leaf

Conversation

@transfix

Copy link
Copy Markdown
Owner

Joe asked for demo3's UI to show the whole ledger of whichever vehicle plant runs, hiding nothing because of which plant was chosen. Today the plant ledger can't support that, for three reasons:

  • publish_nav_stats wrote 6 of the 15 sample items a vehicle had. roll_max_deg, pitch_max_deg, tilt_s, lift_s, wheels_up_s, steer_cmd_abs_mean, accel_cmd_mean, brake_share and plant_steps were reduced but never published.
  • Vehicle-to-vehicle contact was not in nav's ledger at all. veh_contacts is a distance proxy (ticks within min_gap).
  • The dynamic plants left most of plant_sample at its defaults: an upright body, no load transfer, every wheel down and no contacts. The ledger reported those defaults as measured zeros. On a single track ltr_max 0 is not a measurement.

This PR adds the CVC-side half; the demo's half is a cvcdbg PR built against this branch.

The change

plant_sample (plant_types.h) gains:

The plants

  • nav_plant (Jolt) fills vehicle_contact from vehicle_contact_step, and measures everything.
  • dyn_chassis now tells contacts apart: the other chassis box a box touched deepest, and the contacts it began with static geometry (a body without mass that is not the ground, as nav_plant counts them).
  • dyn_bike_plant and dyn_4w_plant gain static_contacts_step (so building_contacts is no longer always 0 on them), vehicle_contact_step, and the sample's contacts and vehicle_contact.
  • dyn_4w_plant samples its body's attitude and roll rate, the load transfer of its four wheels' loads, and a wheel off the ground while its spring is unloaded. It measures everything.
  • dyn_bike_plant samples the ground's attitude under it. It has no load transfer, roll rate or wheels off the ground, and says so in measured.
  • Without a physics world, neither dynamic plant measures contacts.

nav_stats

  • Reduces vehicle_contact to vehicle_hits (contacts begun: a tick touching a vehicle it was not touching the tick before) and vehicle_hit_s. The episode gets total_vehicle_hits and the scorecard mean_vehicle_hits.
  • Keeps plant_measured, the AND of the samples' bits.
  • An item reduced from a field the plant doesn't measure stays at its default, and is null in the JSON.
  • The scorecard's plant means are each over the runs that measured them (NaN/null over none). A Jolt-only corpus is unchanged.

cvc/nav/plant_ledger.h (new) lists every item of the ledger: 20 per vehicle (the three energy items and 17 sample items) and 5 per episode. Each entry has its key, unit, meaning, the bits it needs and a getter. plant_ledger_applies(item, record) says whether the item has a value. The JSON, the publisher, the tests and the demo all read this one table.

cvcGL publish_nav_stats

  • Writes every item, with kNavStatsNotApplicable ("n/a") where it does not apply.
  • New nav_stats_publish_params::emit_plant_ledger writes them on the kinematic plant too (all n/a). It is off by default, so kinematic-only scenes are unchanged.
  • An n/a leaf still has its comment and unit.

The kinematic record and its JSON are byte-unchanged. A plant's record gains vehicle_hits and vehicle_hit_s, and its episode gains total_vehicle_hits.

What each plant measures

item kinematic humvee / roboracer (Jolt) dynamic dynamic4w
energy_J, energy_per_km n/a yes yes yes
building_contacts, vehicle_hits, vehicle_hit_s n/a yes yes (with Jolt) yes (with Jolt)
rolled_over(_s), tilt, roll, pitch, tilt_s n/a yes yes (the ground's) yes
ltr_max, lift_s, wheels_up_s n/a yes n/a yes
a_lat, steering and command items, plant_steps n/a yes yes yes

Tests

Built with MSVC 19.44 against .deps/libcvc, with Jolt and cvcGL:

  • cvcgl_nav_stats_publish: OK. A new block puts three agents on each plant through plant_host (kinematic, humvee, dynamic, dynamic4w), runs 30 ticks of sim_world's own nav_stats, publishes with emit_plant_ledger, and checks that every item of plant_ledger_vehicle() for each vehicle and every item of plant_ledger_episode() is published, as n/a exactly where the table above says. Without Jolt the expectation adds the contact items on the dynamic plants, and humvee falls back to the bicycle. It also checks n/a leaves on a hand-built record.
  • nav_stats_test: 17/17. New: PlantLedgerNotApplicable, PlantLedgerVehicleHits and PlantLedgerItemsAreAllInTheJson. The existing byte-unchanged test still passes.
  • physics_dyn_bike_plant_test 8/8 and physics_dyn_4w_plant_test 7/7. New TellsTheBuildingsFromTheOtherVehicles in each: agent 0 drives into a wall and agents 1 and 2 head on into each other away from it. Agent 0 begins one static contact and touches no vehicle; agents 1 and 2 each touch only the other (144 ticks) and no wall. The 4w turning left at 9.2 m/s gives ltr -0.356, with the load on its right wheels.
  • physics_plant_host_test 5/5, physics_plant_log_test 13/13, nav_test 62/62.

clang-format 18 (cvcpkg) on the changed files.

…t and what does not apply

plant_sample gains vehicle_contact (the agent whose vehicle it touched over the tick, the deepest
contact's) and measured, the fields the plant's model has. The Jolt plant fills vehicle_contact
from vehicle_contact_step. The dynamic plants count their chassis boxes' contacts apart
(dyn_chassis: the other box touched deepest, the contacts begun with static geometry), report them
as static_contacts_step, vehicle_contact_step and the sample's contacts and vehicle_contact, and
sample their attitude: dyn_bike_plant the ground's under it, dyn_4w_plant its body's, roll rate,
load transfer and wheels on the ground. The single track leaves out what it has not got, and both
leave out the contacts without a world.

nav_stats reduces vehicle_contact to vehicle_hits and vehicle_hit_s (episode total_vehicle_hits,
scorecard mean_vehicle_hits) and keeps plant_measured. cvc/nav/plant_ledger.h lists every item of
the ledger with its key, unit, meaning and the fields it needs; plant_ledger_applies says whether
it has a value. An item that does not apply stays at its default, is null in the JSON, and the
scorecard's plant means are over the runs that measured them.

cvcGL's publish_nav_stats writes every item, n/a (kNavStatsNotApplicable) where it does not
apply, and with emit_plant_ledger the whole ledger on the kinematic plant too. It wrote 6 of the
15 sample items a vehicle had (besides the energy ones) and none of the new ones.
@transfix
transfix merged commit ea9c905 into master Oct 29, 2026
26 checks passed
@transfix
transfix deleted the feat/nav-ledger-every-leaf branch October 29, 2026 22:04
transfix added a commit that referenced this pull request Oct 29, 2026
The project version and the cvcpkg recipe family move to 3.7.4. Every recipe is at cvc_revision 1
already, so none restarts.

3.7.4 carries the whole plant ledger on every plant (#876): plant_sample's vehicle
contact and what each plant measures, the dynamic plants' building and vehicle contacts and
attitude, nav_stats' vehicle_hits, cvc/nav/plant_ledger.h, and publish_nav_stats writing every
item, n/a where a plant does not measure it. demo3's Ledger screen (CVC-DBG/cvcdbg#256) reads it.
It also carries SDL3 owning cvcGL's onscreen window (#829), state_exec's state-incr, state-cas and
state-swap (#860), and Ariadne's window fitting (#828) and room relay test counting (#867).
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