Repository navigation
nav: generic external force channel (ext_force) for the drive - #351
Merged
Merged
Conversation
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.
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.
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 repulsionF_repand the material force (and, whenext->steer, into the steering bias too, exactly the both-couplings treatmentmaterial_drivegets).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::navknows only "a force field evaluated at a pose"; it has no vocabulary for what the force means. The consumer builds anext_forcewhoseusercarries its state and whosesamplecomputes its physics, then callsdrive_step_ext.Changes
inc/cvc/nav/drive.h:struct ext_force { sample callback; user; steer }+ entry pointsbicycle_rollout_ext/drive_step_ext, 1:1 with the_materialentries.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_implgainsconst ext_force* ext; the force is sampled after the material block and summed intoFx/Fy, and (whensteer) into the steer bias. The branch is structured so the plain and_materialpaths keep the exact pre-ext expressions ⇒ byte-identical.nav_material_test.cpp):NavExtForce.NullExtIsByteIdentical,FusedDriveStepNullExtMatchesPlainDriveStep,ExtForceChangesTheTrajectory.Contract
A null
ext.samplemakesdrive_step_ext/bicycle_rollout_extbyte-identical todrive_step/bicycle_rollout— thematerial_drivenull-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=noneagainst the shared deps prefix:nav_material_test(incl. 3 newNavExtForce)nav_testnav_drive_refinements_test