Repository navigation
CoPH's cars take a new goal after arriving, and run on world documents (C6 part 2b) - #1517
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).
transfix
enabled auto-merge (squash)
November 24, 2026 02:41
# 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
# Conflicts: # 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
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.
Fixes the two limits of #1516's
--controller coph. Stacked on #1516 (and #1504). Until those merge, this diff includes them; this PR's own commit is the last one.1. A car takes a new goal after it arrives
Before, a CoPH car that reached its goal stayed parked, even with
run.regoalon.coph_fleet::resume(agent): an agent that finished at its goal (success, not a hit) runs again from the next boundary.coph_drivercalls it when the sim moves a done car's goal, as GRL-SNAM's cars controller (T4) clears a car's done.NavCophFleet.resume()exposes it to Python.2.
--gymand--world-docrun CoPHThose cars are a world document's, not a
sim_world, so the native driver can't reach them.pycvc_gl.cars.CophControlruns the same fleet overNavCophFleetfrom any cars'CarsState, as a controller:steer, accel, info = ctl(s). It iscoph_driver's twin:risk(x, y)it is given;nav_coph_allocateevery tick, braking when done, andresumeon a new goal.The template uses it for
GymCarsandHostCars.Carskeeps the native driver, which reads the grid and the material layer.docs/CARS.mdand the roadmap drop both limits. What remains is noted:CophControlsees obstacles only along the rays, and a constant risk unless given one.Checked on Windows (MSVC 19.44 Release, pycvc core with Python 3.11)
nav_coph_fleet_testpasses 9, including the newCophFleet.ResumesOnlyAnAgentAtItsGoal.nav_coph_driver_testpasses 6. The newCophDriver.ACarTakesANewGoalAfterArrivingdrives a car to (8, 6), then (14, 6), in 386 ticks.test_pycvc_nav_coph.pypasses 1291 checks. A driven car given a new goal after arriving reaches it in 264 more ticks, while the other car stays parked.Carsloaded fromcars.py's source, two Humvee-sized cars crossing 60 m:CophControl: both arrive in the same 649 ticks with no contact, and a new goal runs car 1 again.Not run locally:
test_pycvc_gl_cars.py, which adds the same checks plusCophControlonGymCarsand a headless--gym --controller cophrun. CI runs it; this box has no cvcGL.