Skip to content

nav: generic external force channel (ext_force) for the drive - #351

Merged
transfix merged 1 commit into
masterfrom
feat/nav-ext-force
Sep 8, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/nav-ext-force

Conversation

@transfix

@transfix transfix commented Sep 8, 2026 •

Copy link
Copy Markdown
Owner

What

Adds a physics-agnostic external force port to cvc::nav's drive so a caller can add an extra per-agent force to the dynamics — summed into the same force accumulator that already carries the wall repulsion F_rep and the material force (and, when ext->steer, into the steering bias too, exactly the both-couplings treatment material_drive gets).

Why

It lets an application-specific force be a genuine force term in the one real integrator — not a carrot displacement — without putting that force's physics in the open core. cvc::nav knows only "a force field evaluated at a pose"; it has no vocabulary for what the force means. The consumer builds an ext_force whose user carries its state and whose sample computes its physics, then calls drive_step_ext.

Changes

  • inc/cvc/nav/drive.h: struct ext_force { sample callback; user; steer } + entry points bicycle_rollout_ext / drive_step_ext, 1:1 with the _material entries. sample() receives the agent's normalized pose (the native drive frame material sampling uses) and writes a force in that frame; invoked per agent per substep across worker threads → must be reentrant.
  • src/cvc/nav/drive.cpp: rollout_impl gains const ext_force* ext; the force is sampled after the material block and summed into Fx/Fy, and (when steer) into the steer bias. The branch is structured so the plain and _material paths keep the exact pre-ext expressions ⇒ byte-identical.
  • tests (nav_material_test.cpp): NavExtForce.NullExtIsByteIdentical, FusedDriveStepNullExtMatchesPlainDriveStep, ExtForceChangesTheTrajectory.

Contract

A null ext.sample makes drive_step_ext / bicycle_rollout_ext byte-identical to drive_step / bicycle_rollout — the material_drive null-pointer default-off house pattern. Not exposed to SWIG or the CUDA path: a per-substep C callback is a C++-only ABI seam consumed by downstream force providers.

Verification

Built with -DCVC_BUILD_CVCGL=OFF -DCVC_BUILD_PYCVC=OFF -DCVC_ENABLE_CUDA=OFF -DCVC_FFT_PROVIDER=none against the shared deps prefix:

Test Result
nav_material_test (incl. 3 new NavExtForce) 9/9
nav_test 38/38
nav_drive_refinements_test 11/11

Add a physics-agnostic external-force port to cvc::nav's drive so a caller can
add an extra per-agent force to the dynamics, summed into the SAME force
accumulator that already carries the wall repulsion F_rep and the material
force (and, when ext->steer, into the steering bias too) — exactly the
both-couplings treatment material_drive gets.

The point is to keep RF/comms physics OUT of the open core while still letting
a private force be a GENUINE force term (not a carrot displacement). cvc::nav
knows only "a force field evaluated at a pose"; it has no vocabulary for what
the force means. A private consumer (cvc::dbg's RF/comms force) builds an
ext_force whose `user` carries its state and whose `sample` computes its
physics, then calls drive_step_ext — so the core never grows an RF/comm concept.

- inc/cvc/nav/drive.h: struct ext_force { sample callback, user, steer } + the
  two entry points bicycle_rollout_ext / drive_step_ext (1:1 with the _material
  entries). sample() receives the agent's NORMALIZED pose (the native drive
  frame material sampling uses) and writes a force in that frame; it runs per
  agent per substep across worker threads, so it must be reentrant.
- src/cvc/nav/drive.cpp: rollout_impl gains `const ext_force* ext`; the force is
  sampled after the material block and summed into Fx/Fy, and (when steer) into
  the steer bias. The null path is structured so the plain and _material code
  paths keep the EXACT pre-ext expressions -> byte-identical.
- tests (nav_material_test.cpp): NavExtForce.NullExtIsByteIdentical,
  FusedDriveStepNullExtMatchesPlainDriveStep, ExtForceChangesTheTrajectory
  (a live force bends the trajectory; a zero force is byte-identical).

A null ext.sample makes drive_step_ext / bicycle_rollout_ext byte-identical to
drive_step / bicycle_rollout — the material null-pointer default-off house
pattern. Not exposed to SWIG/CUDA: a per-substep C callback is a C++-only ABI
seam consumed by private force providers.

Verified: nav_material_test 9/9 (incl. the 3 new), nav_test 38/38,
nav_drive_refinements_test 11/11.
@transfix
transfix merged commit f2b4a26 into master Sep 8, 2026
13 checks passed
@transfix
transfix deleted the feat/nav-ext-force branch September 8, 2026 22:14
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