Repository navigation
CoPH's crossing demo, natively and in the browser (C6 part 3) - #1519
Merged
Merged
Conversation
bindings/pycvc/pycvc_nav_coph.i puts cvc::nav's CoPH in pycvc. It only marshals between Python
values and the library.
- Kernels: nav_coph_flow, nav_coph_balance, nav_coph_risk, nav_coph_potential,
nav_coph_grad_potential, nav_coph_command, nav_coph_shaping and nav_coph_allocate. A packet's
bytes are NavCophPacket.bytes(), its json()'s length (D9).
- Configurations are dicts over the demos' profile, keyed by coph_config's field names. An unknown
key is an error, and validate() runs on the result. nav_coph_profile() and
nav_coph_communication_profile() return the whole of each.
- NavCophAgent is one learner, a crossing one or a car's (network="none"): observe, advance,
action, last_control, update, export_to (a NavCophPacket) and assimilate.
- NavCophFleet is the runner's fleet:
- run_crossing() on the crossing world, with the GIL released; the sensor noise may be a Python
callable, which takes the GIL back for each call;
- boundary() for a world of the caller's;
- samples, controls, updates, events and the energy accounts.
test_pycvc_nav_coph.py (ctest pycvc_nav_coph) checks:
- G2, G3 and G11 from coph_golden.json at its tier;
- the configuration dicts;
- a learner driven on the plant kernel exporting a packet that a second learner assimilates;
- a car's learner;
- the fleet on G12's crossing world and noise, as CophFleet.TheEnergyAccountStaysAtRoundOffOverALongRun
runs it: both agents reach their goals, in 767 and 784 steps, with residuals at 7e-15.
…ion-local static pycvc-linux's writable-data scan (tools/singleton_scan) flagged config_fields()' static std::map and its guard variable as new process-wide state in pycvcPYTHON_wrap.cxx. The table is now a constexpr array of names and plain function pointers, which the compiler places in read-only data (.data.rel.ro under PIC) with nothing initialised at run time; a lookup walks it. Behaviour is unchanged: test_pycvc_nav_coph.py still passes its 1278 checks, as do test_pycvc_ph.py and test_pycvc_nav_lab.py.
…ely (C6 part 2)
pycvc.NavCophDriver binds C5's coph_driver to a nav_sim_world_create handle. It holds a
reference to the handle while it lives, and its methods are attach, apply, ticks_per_step, steps,
done, account, controls and events. pycvc_gl.cars uses it:
- Cars(..., coph={...}) attaches every car, and step_coph() runs the driver's apply before the
world's step. coph_froude() gives the Froude scale: the car's length over a RoboRacer's (D3, D4).
coph_coeffs() gives each car's account for the coefficient plots and the log.
- The template takes --controller coph and --coph-scale, and the Run panel gains a CoPH choice.
--gym and --world-doc refuse it, since the driver runs on a sim_world.
- docs/CARS.md documents it, including its limit: a CoPH car that arrives brakes and stays,
taking no new goal.
The fleet's controls and events now share one converter between NavCophFleet and NavCophDriver.
Checked on Windows (pycvc core; this box has no cvcGL):
- test_pycvc_nav_coph.py: 1288 checks.
- A driver with nothing attached leaves the run bit for bit.
- Two RoboRacer-sized cars cross in 485 ticks, as CophDriver.TwoCarsCrossTheField does.
- Cars(coph=...) loaded from cars.py's source: two Humvee-sized cars on nav's bicycle cross 60 m
of the flat world and both arrive in 37.9 s, with no contact, at s = 9.05.
- test_pycvc_gl_cars.py gains the same Cars check and a headless --controller coph run. CI runs
it.
…s (C6 part 2b) #1516 had two limits; this fixes both. 1. A car that arrived stayed parked even when given a new goal. coph_fleet::resume(agent) now lets an agent that finished at its goal run again from the next boundary, its learner keeping what it learned. That boundary observes without a transition and records an activation. Refused when the agent is running, or was ended by a hit or by the run's steps. coph_driver calls it when the sim moves a done car's goal, as GRL-SNAM's cars controller clears a car's done. NavCophFleet.resume() binds it. 2. --gym and --world-doc refused --controller coph, because the driver needs a sim_world. pycvc_gl.cars.CophControl runs the same fleet over NavCophFleet from any cars' CarsState, the twin of coph_driver: - Froude frames and CoPH's cadence; - the local goal; - the 21 lattice readings of a constant risk, or a risk(x, y) it is given; - the rays' hits within the scaled sensor radius as disks; - nav_coph_allocate every tick; - braking when done, and resume on a new goal. The template uses it for GymCars and HostCars. Cars keeps the native driver. docs/CARS.md and the roadmap drop the two limits. What remains: CophControl sees obstacles only along the rays, and a constant risk unless given one. Checked on Windows: - nav_coph_fleet_test (9, with CophFleet.ResumesOnlyAnAgentAtItsGoal) passes. - nav_coph_driver_test (6) passes. CophDriver.ACarTakesANewGoalAfterArriving reaches (8, 6), then (14, 6), in 386 ticks. - test_pycvc_nav_coph.py passes 1291 checks. A driven car given a new goal reaches it in 264 more ticks, while the other stays parked. - Cars loaded from source: native, both cars cross and car 0 reaches a new goal. With CophControl both arrive in the same 649 ticks with no contact, and a new goal runs car 1 again. - test_pycvc_gl_cars.py adds the same checks plus CophControl on GymCars and a headless --gym --controller coph run. CI runs it (no cvcGL here).
examples/ariadne/python/coph.py and coph.ari run the crossing demo on pycvc's NavCophFleet, libcvc's C++ CoPH with no torch. - It runs a few CoPH ticks a frame and shows a top-down picture of the maze, the doors, the agents' trails and sensors, and a flash when a packet arrives. - It shows each agent's stage, version, policy and energy account, and its distance to goal. - A Packets switch turns communication on or off, the demos' two arms. - It has no scene:, so it runs headless, in a window, and in a browser on ariglx-web (?src=coph.py, with coph.ari preloaded). To run a few ticks a frame: - coph_fleet::run(world, ticks) runs at most that many ticks from where the last call stopped, and tick() gives the next. run(world) is now run(world, -1). - NavCophFleet.run_crossing(world, ticks) keeps its world between calls, and returns whether every agent is done. Checks: - src/arigl/web/test/python/coph.ari, a new case in ariglx-web's browser smoke, runs the crossing's first 120 CoPH ticks in the page, 40 at a time, on the page's own pycvc. It reports the packets and each agent's version and energy residual. - CophFleet.RunsAFewTicksAtATime: the crossing run 15 ticks at a time is the one run whole, bit for bit. - test_pycvc_nav_coph.py checks the same, 300 ticks at a time. - test_pycvc_gl_ariadne_host.py runs the example offscreen. - ARIADNE.md's example table and CVCGL_WASM.md's list of smoke cases name them. Checked on Windows: - nav_coph_fleet_test (10) and nav_coph_driver_test (6) pass; test_pycvc_nav_coph.py passes 1293 checks. - coph.py --headless --frames 300: both agents reach their goals, at 92.2 s and 94.2 s, with 192 packets sent, delivered and accepted, and residuals at 7e-15. - coph.ari's python block, run natively, prints the line the smoke's regex expects: 121 ticks, 30 packets sent and delivered, in 635 ms. - The browser case and the offscreen example run are CI's (ariglx-web job, pycvc_gl): this box has no cvcGL.
# Conflicts: # bindings/pycvc/pycvc_nav_coph.i # bindings/pycvc/test_pycvc_nav_coph.py # docs/roadmap/NAV-COPH-ROADMAP.md # src/cvc/tests/nav_coph_driver_test.cpp
…eports The crossing runs ticks 0 to 120 (tick 0 activates the agents, 120 steps follow), so NavCophFleet.tick() is 121 when every agent is done. The regex asked for 120 and would never have matched.
Every document under examples/ariadne/ has a requires: block (AriadneComponents.ShippedExamplesDeclareWhatTheyNeed, ARIADNE.md 5.7). The crossing picture shows in real pixels where the host has raster.bitmap and as half-block cells elsewhere, so it is optional; Restart's on: is a bare event coph.py handles, not a function, so it is not listed.
# Conflicts: # bindings/pycvc/pycvc_nav_coph.i # bindings/pycvc/pymod_gl/cars.py # bindings/pycvc/test_pycvc_gl_cars.py # bindings/pycvc/test_pycvc_nav_coph.py # docs/CARS.md # docs/roadmap/NAV-COPH-ROADMAP.md
# Conflicts: # docs/roadmap/NAV-COPH-ROADMAP.md # src/cvc/nav/coph_fleet.cpp # src/cvc/tests/nav_coph_fleet_test.cpp
This was referenced Nov 25, 2026
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.
C6 part 3 of
docs/roadmap/NAV-COPH-ROADMAP.md(§4.6): CoPH's crossing demo on pycvc'sNavCophFleet, libcvc's C++ CoPH with no torch. It runs natively and in the browser on ariglx-web.Parts 1, 2 and 2b (#1504, #1516, #1517) have merged, and master is merged in (bb1885c), so this diff is part 3 alone.
Since the master merge (862a685):
nav_coph_driver_test.cppkeeps nav: the CoPH ledger's items in the episode record (C5 part 2c) #1502's two ledger tests next to part 2b's regoal test.examples/ariadne/python/coph.arihas arequires:block (af3b86c):raster.bitmap, optional.AriadneComponents.ShippedExamplesDeclareWhatTheyNeedrequires one in every example, and its absence failed every package and recipe job.arigl_web_smoke.mjs's CoPH case now expects 121 ticks (b4061c0), the count the run reports: tick 0 activates the agents, then 120 steps follow.What it adds
examples/ariadne/python/coph.pyandcoph.ari. They run the crossing a few CoPH ticks a frame.crossingpicture is a top-down view of the maze, the doors, the agents' trails, sensors and goals, with a flash when a packet arrives.scene:, so the demo runs headless, in a window, and in a browser on ariglx-web (?src=coph.py, withcoph.aripreloaded).coph_fleet::run(world, ticks)runs at most that many ticks from where the last call stopped, andtick()gives the next.run(world)is nowrun(world, -1).NavCophFleet.run_crossing(world, ticks)keeps its world between calls and returns whether every agent is done.src/arigl/web/test/python/coph.ariis a new case in ariglx-web's smoke (arigl_web_smoke.mjs). It runs the crossing's first 120 CoPH ticks in the page, 40 at a time, on the page's own pycvc. It reports the packets and each agent's version and energy residual. CI's ariglx-web job builds the module from this PR and runs it in headless Chrome.ARIADNE.md's example table,CVCGL_WASM.md's list of smoke cases, and the roadmap.Checked on Windows (MSVC 19.44 Release, pycvc core with Python 3.11)
nav_coph_driver_test8,nav_stats_test18. The newcoph.arifiles andcars.ariare valid against Ariadne: a closed .ari schema every load checks, and ari validate #1464'sari.v1.schema.json(checked with Python's jsonschema; the local build has no validator).nav_coph_fleet_testpasses 10, including the newCophFleet.RunsAFewTicksAtATime: the crossing run 15 ticks at a time is the one run whole, bit for bit.nav_coph_driver_testpasses 6.test_pycvc_nav_coph.pypasses 1293 checks, including the same check throughrun_crossing(ticks=300).coph.py --headless --frames 300: both agents reach their goals, at 92.2 s and 94.2 s. 192 packets were sent, and all were delivered and accepted; the residuals are 7e-15.coph.ari's python block, run natively, prints the line the smoke's regex expects: 121 ticks, 30 packets sent and delivered, in 635 ms.Left to CI (this box has no cvcGL): the browser case and the offscreen example run in
pycvc_gl_ariadne_host.Next
A public page, once a libcvc release carries the bindings. GRL-SNAM's pages pin a release (v4.0.0) and build ariglx-web from it.