Skip to content

sim_world::set_truth, and the fog-of-war surface in pycvc - #986

Merged
transfix merged 1 commit into
masterfrom
feat/sim-world-truth-edits
Nov 3, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/sim-world-truth-edits

Conversation

@transfix

@transfix transfix commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

What

sim_world::set_truth(const uint8_t *truth) replaces the world as it is: a wall raised or taken down, or a moving vehicle's footprint each tick.

  • truth() reads it back at once.
  • The agents learn it the way they learn the constructor's truth: by sensing, from the next sense tick, where a ray reaches it. Under freeze_sense they never learn it.
  • What was derived from the truth before keeps it. That means the material gate surface: call set_material again to refresh it.

pycvc gains the fog-of-war read and write surface:

  • nav_sim_world_truth(h) and nav_sim_world_set_truth(h, truth);
  • the fog tiers nav_sim_world_ever_seen(h, m) and nav_sim_world_last_visible(h, m), as (H, W) uint8;
  • nav_sim_world_add_obstacle(h, r0, r1, c0, c1): the decaying marks, which sim_world had and pycvc did not bind;
  • nav_sim_world_dynamic_stamps(h, m): when each cell was last marked, (H, W) float64, -inf for never.

Why

GRL-SNAM's grl-snam fog record --plant ... puts the fog-of-war stories on a vehicle plant through the native world. The stories change the world mid-run:

  • blocker raises a wall;
  • unit drops decaying marks;
  • traffic moves two vehicles.

The recorder also writes the fog tiers and the truth into the trace the renderer replays. None of that was reachable from Python, and the world's truth was fixed at construction. CVC-Lab/GRL-SNAM#145 is that PR.

Tests

  • C++: NavSimWorld.SetTruthIsSensedFromTheNextSenseTick. A wall raised east of an agent in an open field reads back from truth() at once. It is not believed before a sense tick, and it is believed after one. Once taken down, the belief clears.
  • Python: test_pycvc_nav_fog.py, registered with the other pycvc tests, 15 checks:
    • the fog tiers reach out to the sensor's 30 m range and not past it;
    • a wall is raised and taken down;
    • a mark is stamped with the sim time, believed, and expired after ttl_s;
    • argument checks.

Local run: Windows, MSVC 14.44 Release, Jolt on. nav_sim_world_test passes 4/4, test_pycvc_nav_fog.py passes 15 checks, and test_pycvc_physics.py still passes. clang-format 18 is clean on the changed lines.

sim_world::set_truth replaces the world as it is (a wall raised or taken down,
a moving vehicle's footprint each tick). truth() reads it back at once; the
agents learn it by sensing, from the next sense tick, where a ray reaches it.
What was derived from the truth before keeps it (the material gate surface).

pycvc gains the read and write surface a fog-of-war story needs:
nav_sim_world_truth / set_truth, the fog tiers nav_sim_world_ever_seen and
last_visible, nav_sim_world_add_obstacle (the decaying marks) and
nav_sim_world_dynamic_stamps (when each cell was last marked).

Tests: NavSimWorld.SetTruthIsSensedFromTheNextSenseTick (a wall raised east of
an agent in an open field is believed after a sense tick and not before, and
clears once taken down); test_pycvc_nav_fog.py (the fog tiers out to the
sensor's range, a wall raised and taken down, a mark believed then expired,
argument checks).
transfix added a commit to CVC-Lab/GRL-SNAM that referenced this pull request Nov 3, 2026
grl-snam fog record|all --plant kinematic|dynamic[:preset]|jolt[:preset] runs
a story's one agent on libcvc's sim_world (tools/fog_plant.record_on_plant) and
writes the same trace the Python scenario does. It keeps the native world honest
to the story: a wall raised mid-run goes into the truth (sim_world::set_truth,
transfix/libcvc#986) and, on a physics plant, the physics world; a unit's marks
are the world's decaying marks; moving vehicles join the truth each tick and are
kinematic boxes; a moving target is retargeted. All six stories record (the fog
CLI now takes city, traffic and pursuit too). record()'s trace writing moved
into _write_trace so both paths share it.

grl-snam material-demo --plant runs both stories on the native world with the
material's forces and witness gate (NativeSimWorld.set_material_grid);
Squad(plant=..., material=...) and sim_world_from_swarm(material=...) attach it
too, where Squad used to refuse it. PlantNavigator gains a prior map, the
sensing schedule, the unknown policy, the marks' ttl, a material grid and
track_goal; both plants gain add_box / move_box for walls and movers.

docs/PLANTS.md documents both, with what they measure; tests/test_fog_plant.py
covers the CLI and, with the bindings, a raised wall, decaying marks, traffic,
a moving goal, a squad with material and the material demo on a plant.
@transfix
transfix merged commit f23b832 into master Nov 3, 2026
27 of 28 checks passed
@transfix
transfix deleted the feat/sim-world-truth-edits branch November 3, 2026 08:16
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