Repository navigation
nav: per-plane raster_version; gate nav-stats raster publishing on it - #581
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
sim_world::plane_version(m)only counts log-odds sign flips: it bumps once per sensing agent whose update flips a cell's sign. A plane's published rasters can change without it bumping:belief_occ(m)changes on a planning-threshold crossing that isn't a sign flip.add_obstacle()marks appear in the composited occupancy and later expire by TTL.ever_seen(m)grows andlast_visible(m)moves whenever a field of view moves over open ground.The reverse also happens: a flip on the occupied side of the threshold bumps
plane_versionwhile no raster changes. #503 corrected the header comment, butpublish_nav_rastersstill documented its per-planeversions[]gate asplane_version(m). So the fog and belief layers went stale in cases (a)–(c).Change
sense_batch:belief_planesgains an optionalfov_changed[K]output. When set, each plane gets 1 iff the call changed any byte of itsever_seenorlast_visible. When the result would be byte-identical, thelast_visibleblank-and-restamp is skipped. Callers that don't pass it, including pycvc, run the old code path unchanged.sim_world::raster_version(m)is new. It bumps exactly once per sense tick on which any byte of plane m'sbelief_occ/ever_seen/last_visiblechanged, and never otherwise.belief_occis the composited occupancy, so threshold crossings and obstacle marks/expiry count. The occupancy half reuses the per-plane change detection the rebuild trigger already does, so it adds no extra pass.plane_version(m)keeps its belief-flip meaning for existing callers. Both are documented, and each points to the other.publish_nav_rasters(app, pub, prefix, const sim_world&, st)is a new overload. It reads dims, bounds and rasters from the world and gates each plane onraster_version(m). The array overload's doc now says to passraster_version(m), notplane_version(m).Tests
src/cvc/tests/nav_test.cpp:NavSense.FovChangedIsExactAndContentNeutralsenses into twin stacks, one withfov_changedand one without. The stacks must stay byte-identical, andfov_changed[p]must equal "plane p's FoV bytes differ". It runs in the private, clustered and shared layouts, plus an empty plane. The rounds are: first sense, identical re-sense (0 changes), 20 half-cell translations, an agent going off the grid, and stray non-canonical bytes. The translations move a plane's last-agent FoV to a different cell set of the same size, which is the case the skip shortcut must not mistake for "unchanged".NavSimWorld.RasterVersionBumpsOncePerRasterChangeuses the stationary one-ray phantom scenario from the existing flip test, so every event lands on a known tick. Each case causes exactly one bump: an ever_seen-only growth (tick 0, no flip), a threshold crossing without a sign flip (tick 6), anadd_obstaclemark appearing (first sense after the call), and its TTL expiry (5 ticks later). Unchanged ticks, and the flip that changes no raster (tick 5), bump nothing.NavSimWorld.RasterVersionEverSeenOnlyGrowth: two agents share a plane. The first drives into new ground while the plane's last agent, whose FoV islast_visible, stays parked.ever_seengrows withlast_visibleand occupancy unchanged, and each such tick bumps exactly once.NavSimWorld.RasterVersionStillUnderFreezeSense: underfreeze_sense, including after anadd_obstacle, nothing changes and nothing bumps.NavSimWorld.RasterVersionMatchesRasterDiffOracleruns live fog-of-war in the private (pooled), clustered and shared layouts, sensing every other tick, with obstacle marks mid-run. Every tick and every plane, theraster_versiondelta must equal "did a raster byte change". Non-sense ticks must change nothing. The run must include occupancy changes without a flip, FoV-only changes and quiet sense ticks.PooledRebuildMatchesSerialBitExactnow also checks thatraster_versionmatches between serial and pooled runs.src/cvcGL/test/cvcgl_nav_stats_publish.cppruns the same phantom scenario through the new overload every tick. It detects a republish by the stored belief volume's buffer identity, while holding the previous handle. It checks that exactly the 4 expected ticks republish, that the publishedbelief/ever_seen/last_visiblevolumes always equal the world's current rasters, and that.versiontracksraster_version.What ran locally
This box can't configure libcvc (no Boost/VTK/CGAL). The nav core is stdlib-only, though, so I built
nav_test.cppagainst the real nav sources. I used a minimal gtest stand-in and a brute-force stand-in for the CGAL neighbour search (neighbors_within_radius).nav_testtests pass (51 existing + 5 new).belief_occ/ever_seen/last_visibleplanes, the SDF field,field_versionand everyplane_version. It is identical betweenorigin/masterand this branch.raster_versionto the flip count, always bump, drop the ever_seen growth flag, ignorelast_visiblechanges, skip the nonzero count, skip the per-cell FoV check, and treat a non-canonicalever_seenbyte as already seen.last_visibleskip shortcut untested; a mutant that breaks bit-identity survived the original tests. The second was a non-canonicalever_seenbyte that was only exercised in 2 of 6 runs.The cvcGL code and its test were not compiled locally. CI is their only build gate.
Downstream
cvcdbg's demo3 sim worker (
demos/demo3_sim_worker.cpp) gates its belief-buffer copy onplane_versionand passesplane_versiontopublish_nav_rasters. Once it builds against a libcvc with this change, it should switch both toraster_version. That's a separate cvcdbg change.