Skip to content

sim_world: opt-in internal base nav_stats collector + pycvc binding - #402

Merged
transfix merged 1 commit into
masterfrom
feat/sim-world-nav-stats-collector
Sep 22, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/sim-world-nav-stats-collector

Conversation

@transfix

Copy link
Copy Markdown
Owner

The native path (grl-snam NativeSimWorld, driving cvc::nav::sim_world torch-free, off-thread) had no base-stats collection — the C++ world owns the SDF/occupancy and its snapshot has no clearance column, so Python can't collect faithfully. This gives sim_world its own internal nav_stats_collector, so the native path gets the base episode record the same way the Python Swarm now does (grl-snam #84) — collecting in C++ on the sim thread rather than pulling snapshot+clearance over the pybind boundary every tick.

What

  • sim_world::begin_nav_stats(params, budget, scene, seed, ckpt) — arms the collector, capturing the current pose as the episode start (call before the first step()) and goals_world() as the goal. step() folds one tick at its tail (after drive + hard-de-overlap + reached), reusing the world snapshot arrays + a truth-occupancy sampler for penetration + min_clearance_world() → double metres for clearance. nav_stats() finishes → the episode_nav_stats. Opt-in; default off = byte-unchanged runs. Pure C++ in step(), so it's safe on the sim thread. No CMake change (nav_stats.cpp already linked).
  • pycvc_nav.i — nav_sim_world_begin_nav_stats (scalar args) + nav_sim_world_nav_stats (returns episode_nav_stats::to_json() as a str; Python does json.loads). Same PyObject idiom as nav_sim_world_retarget/_set_material.

Test (passes locally)

NavSimWorld.BaseNavStatsArmedCollectsSaneFields — arm, step 300× over the bordered-room-with-bar, assert sane world-metre fields (clearance measured + bounded, arrival within budget, penetration_pct in [0,100], min_sep finite), unarmed nav_stats() throws, and bit-identical to_json() for an identically-seeded/stepped world. The exact normalized→metres clearance conversion is separately pinned by the existing min_clearance_world assertion.

Follow-ups

  • PR-B (grl-snam): NativeSimWorld.begin_nav_stats()/episode_stats() → EpisodeStats via from_nav_stats — lands once this ships in the nightly pycvc (needs a pycvc recipe cvc_revision bump + publish).
  • Deferred: material_id sampler (no per-point palette on sim_world), set_identity (convoy/class/mass), and exact Swarm↔native bit parity (the collector has no active & ~parked gate — safe while parked agents brake to zero).

The native path (grl_snam NativeSimWorld, driving cvc::nav::sim_world torch-free
off-thread) had no base-stats collection — the C++ world owns the SDF/occupancy and its
snapshot has no clearance column, so Python can't collect faithfully. Give sim_world its
own internal nav_stats_collector so the native path gets the base episode record the same
way the Python Swarm now does.

- sim_world::begin_nav_stats(params, budget, scene, seed, ckpt): arm the collector,
  capturing the CURRENT pose as the episode start (call before the first step) and
  goals_world() as the goal. step() folds one tick at its tail (after drive + de-overlap +
  reached), reusing the world snapshot arrays + a truth-occupancy sampler for penetration +
  min_clearance_world()->double METRES for clearance. nav_stats() finishes -> the
  episode_nav_stats. Opt-in; default off = byte-unchanged runs. Pure C++ in step(), so it's
  safe on the sim thread (no Python per-tick pull). No CMake change (nav_stats.cpp already
  linked).
- pycvc_nav.i: nav_sim_world_begin_nav_stats (scalar args) + nav_sim_world_nav_stats
  (returns episode_nav_stats::to_json() as a str; Python does json.loads). Same PyObject
  idiom as nav_sim_world_retarget/_set_material; GIL held, no thread-release.
- Test NavSimWorld.BaseNavStatsArmedCollectsSaneFields: arm, step 300x over the
  bordered-room-with-bar, assert sane world-metre fields (clearance measured + bounded,
  arrival within budget, penetration_pct in [0,100], min_sep finite), unarmed throws, and
  bit-identical to_json() for an identically-seeded/stepped world. Passes locally.

Follow-up PR-B (grl-snam NativeSimWorld.begin_nav_stats/episode_stats -> from_nav_stats)
lands once this ships in the nightly pycvc (needs a pycvc recipe cvc_revision bump +
publish). Deferrals: material_id sampler (no per-point palette on sim_world), set_identity
(convoy/class/mass), exact Swarm<->native bit parity (no collectible gate; safe while parked
agents brake to zero).
@transfix
transfix merged commit 0e40dfa into master Sep 22, 2026
13 checks passed
@transfix
transfix deleted the feat/sim-world-nav-stats-collector branch September 22, 2026 20:52
transfix added a commit that referenced this pull request Sep 22, 2026
#402 added the sim_world internal base nav_stats collector + its pycvc bindings
(nav_sim_world_begin_nav_stats / nav_sim_world_nav_stats) to bindings/pycvc/pycvc_nav.i.
Bump the core pycvc column recipes so the resolver republishes/picks up the rebuilt
pycvc (3.4.0+cvc.2) that carries the new symbols — unblocking grl-snam PR #86
(NativeSimWorld base-stats collection), which gates on HAS_SIM_WORLD_NAVSTATS.

Core columns only (pycvc-cp311/312/313 + pycvc-cp311-cuda); the pycvc-gl columns wrap
cvcGL (CVC_BUILD_PYCVC_GL) and don't include pycvc_nav.i, so they're unchanged.
transfix added a commit to CVC-Lab/GRL-SNAM that referenced this pull request Sep 22, 2026
The native path (NativeSimWorld, driving the torch-free C++ cvc::nav::sim_world) gains
base-stats collection via the world's INTERNAL nav_stats collector (libcvc #402) — the
3rd grl-snam base-stats source after the pure-Python SdfNavigator and the vectorized
Swarm, so all three collect the same base row.

- NativeSimWorld.begin_nav_stats(...): arm the C++ collector (captures the current pose as
  the episode start; call before the first step). nav_stats(): json.loads the episode
  record. episode_stats(): map it into a scorecard EpisodeStats via from_nav_stats,
  mirroring Swarm.episode_stats — the C++ record already carries min_sep_m, per-vehicle
  veh_contacts and time_to_goal_s, so they come across for free.
- HAS_SIM_WORLD_NAVSTATS feature flag (hasattr nav_sim_world_begin_nav_stats) keeps the
  module import-safe on a pycvc built before the bindings shipped; the gated test in
  tests/test_sim_world_parity.py skips until then.

Depends on transfix/libcvc#402 (the sim_world internal collector + pycvc bindings). Runs
in CI once #402 is published in the nightly pycvc (pycvc recipe cvc_revision bump).
Deferred: material_time_share (no per-point palette on sim_world), set_identity, exact
Swarm<->native bit parity.
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