Repository navigation
Torch twins of the dynamic plant's wheel spin, compliant contact and full (q, p) pH form - #146
Merged
Merged
Conversation
… and four wheels
dyn_bike: dyn_spin_plant (the state plus om_f, om_r), dyn_spin_ph_parts_at, dyn_spin_ph_rates_at,
dyn_spin_ph_hamiltonian and dyn_spin_plant_books, twins of libcvc's opt-in wheel spin
(dyn_spin_*), with DynBikeParams' r_w, J_f, J_r, B_x, C_x. dyn_plant and dyn_ph_parts_at share
the step and the lateral parts with them, split as libcvc's dyn_plant_core and
dyn_ph_parts_lateral are; their arithmetic is unchanged.
dyn4: dyn4_spin_plant (the state plus the four wheels' speeds), dyn4_spin_ph_parts_at,
dyn4_spin_ph_rates_at, dyn4_spin_ph_hamiltonian (and dyn4_ph_hamiltonian) and
dyn4_spin_plant_books on any ground. Dyn4Params gains the wheels' r_w, J_f, J_r, B_x, C_x and
libcvc's drive_gain, brake_gain, resist_comp (the drive's target, a_cmd itself at the defaults)
and grade_force, which is not twinned: a plant that sets it raises.
Parity against libcvc's dyn_spin_ph_golden.json and dyn4_spin_ph_golden.json (copied from libcvc
6215e6ae), DOUBLE contract, 1e-9 relative. Measured worst |torch - libcvc| / max(1, |torch|,
|libcvc|):
single track four wheels
parts/wheels 4.5e-15 1.2e-16
rates 4.9e-16 1.4e-16
next 0 2.1e-16
free 0 5.6e-17
books 0 7.3e-16
gradients 4.4e-14 7.2e-13
The books' step is the plant's to the last bit in every case.
…external port dyn_contact (new): the twin of libcvc's dyn_contact.h. dyn_footprint_points samples the outline about the centre of gravity; dyn_contact_field gives each point within the skin of a field a barrier energy 1/2 k (s - d)^2, a Hunt-Crossley damper on its normal velocity and smoothed Coulomb friction along the obstacle, as the barrier's and the damper's body wrenches (Wc, Wd), the energy, the dissipation and the points touching; dyn_rounded_box_sdf and dyn_contact_pair do the same between two vehicles, both ways. A body is a (..., 6) tensor and a field a callable (phi, gx, gy), with the golden's analytic wall and pillar; autograd differentiates it all. dyn_bike: dyn_plant and dyn_spin_plant take an optional keyword wrench, the external port held over the step (joining the resistances along the body and the lateral solve's force and moment, as libcvc's dyn_plant_core does); dyn_plant_books and dyn_spin_plant_books book its energy as a port line (dyn_ph_port_work) and leave the residual net of it. Without a wrench nothing changes. Parity against libcvc's dyn_contact_golden.json (copied from libcvc b64921cb), DOUBLE contract, 1e-9 relative: the footprint points, the five field cases, the three pair cases, and the plant step's next state, books (port included) and free twist all agree exactly (worst difference 0). The step's plant is DynBikePH.Golden's Humvee, whose parameters the golden does not repeat; they come from dyn_bike_ph_golden.json. Structural gates in torch: the barrier's wrench is minus autograd's gradient of its energy in the pose to 2.8e-16 over 153 poses in the skin of a wall and a pillar; between vehicles the world forces and moments cancel, and the barrier matches the pair's energy's gradient to 2.0e-15 over 254 touching pairs; the damper's power is minus its dissipation.
… corner radius held The contact golden is libcvc 7b862ca0's: every field case now has points in the skin (touching 4, 1, 1, 1, 2 against the wall and the pillar, where the wall's were all out of reach), and the plant step records its vehicle's parameters, so the test reads them there rather than from dyn_bike_ph_golden.json. dyn_rounded_box_sdf holds the corner radius to [0, min(half width, half length)], as libcvc's now does; no golden value depends on it, and a test pins it. Parity, DOUBLE contract, 1e-9 relative: the footprint points, the field and pair cases, and the step's next state, books (port included) and free twist agree exactly (worst difference 0). The barrier is minus autograd's gradient of its energy to 2.8e-16 over 157 poses in the skin, and a pair's barrier to 2.0e-15 over 254 touching pairs.
libcvc's dyn_ph_T, dyn_ph_rhs_full, the ground overloads (the slopes, the potential m g h at the centre of gravity, dV/dq, the rates) and dyn_plant_ground / dyn_plant_books_ground: with the pose in the state, q' = T(q) v and p' = -T(q)^T dV/dq + (J(p) - R) v + G u + f_eps, gravity in H on a ground and the books' grade line -dV. dyn_plant takes the optional slope across the heading (`side`), and dyn_ph_rhs the momentum-only field. tests/test_dyn_ph_full_parity.py holds them to libcvc's dyn_ph_full_golden.json (libcvc 9dda6dd3, DynPHFull.Golden: the Humvee on a hillside at six states) to 1e-9, the books' gradient by autograd through the ground; and checks, in torch alone, that the structure is skew and Poisson (Jacobi by autograd), that the pose update is q1 = q0 + hdt T(q1) v1, and that side-slope books close to second order with gravity in H while the momentum-only books leave the lateral component's work unbooked.
Contributor
Author
|
I ran the whole suite on Windows (Python 3.12, torch CPU), on the branch rebased onto main 2cf3230: 639 passed, 61 skipped, 7 failed. None of the failures touches this PR's files. Each comes from this machine's environment:
The parity files ( |
transfix
added a commit
that referenced
this pull request
Nov 3, 2026
…e slope, and compliant contact (#151) * docs(vehicle-ph-plant): wheel spin, the full (q, p) form with the side slope, and compliant contact A new section covers libcvc #982 (wheel spin: the wheels' momenta in the state, a (wheel torque, wheel speed) port, the longitudinal slip's secants in R), #987 (the full form with gravity in H, tangents not sines, the four-wheel full form) and #983 (a barrier energy in H, the damper and friction in R, through the external port; against the rigid-body world; contact windows in the logs), with three validation tables measured on libcvc master 3d5c15c6. The learned plant gains the potential's form (#982). The review gaps now describe actuation and collisions as built, and Proposition 1's pose update has its own test. GRL-SNAM #146's twins get their own table, and the twins' parity tests move to a table of their own. At the default substep a 7.8 m/s impact overshoots the contact's damper; the paper says so. Three passes of pdflatex: no warnings, 48 pages. * docs(vehicle-ph-plant): cite libcvc #1002 for the pycvc binding of the new options
transfix
added a commit
that referenced
this pull request
Nov 7, 2026
* release: 0.3.0 95 commits since v0.2.1 (PRs #66 to #158), with new features, so the pre-1.0 minor version goes up. The main changes: - Ariadne hosts: GRL-SNAM's demos run as Python hosts of Ariadne documents (#147, #149, #153). `grl-snam ariadne cars` runs libcvc's multi-car template (#155), and fleet and live take its settings, worlds, plants, panels and log (#157). These need pycvc-gl 3.7.12. - Vehicle plants: capture, the demos, the fog-of-war stories and training run on kinematic, dynamic and Jolt plants (#119, #130, #143, #145, #154). - Torch twins of libcvc, held to its goldens: the material rollout (#118), terrain (#120), dyn_bike and dyn4 (#121, #123, #134-#136), the external force (#122, #124), the material trainer (#125), belief material (#128, #129, #131), U_nav (#133), and the port-Hamiltonian form, its energy books, wheel spin and compliant contact (#138, #139, #146). - The vehicle-plant port-Hamiltonian whitepaper (#137 to #158). - Training and evaluation: the base scorecard and selection (#82-#98), `grl-snam coef-train` (#102), the learned lam head and .cvcnav v2 (#94, #105), and the 2026-10 audit fixes (#113). - Data: grl-snam-weights, plus the Austin scene and Humvee as runtime dependencies, so `grl-snam demo` runs from a bare install (#72-#77). - The research core moves under grl_snam/ (#103). The world clock is shared with libcvc's (#116, #117). The version lives in pyproject.toml. The three cvcpkg columns mirror it in upstream_version and in the package.files dist-info path. cvc_revision goes back to 1 for the new upstream version. The publish job asks the server for the next revision in any case. * material_train_native: pass semi_implicit=False explicitly (libcvc #981) libcvc #981 (in 3.7.12) changed nav_material_trainer_create's ms_semi_implicit default from 0 to 1. MaterialTrainer left the L_multi sampling args out for the legacy single start, so on pycvc-gl 3.7.12 semi_implicit=False quietly ran semi-implicit Euler. #159's CI was the first run on 3.7.12, and four tests failed on cp311, cp312 and cp313: - test_sampled_multi_start_args: "semi_implicit did not reach the rollout", because the default and semi_implicit=True were now the same rollout; - test_live_native_trainer_agrees[legacy] and [legacy+ext], and test_live_native_trainer_agrees_on_the_belief_net[surrogate]: the explicit torch trainer and the native one differed by 1.3e-3 to 1.5e-3 (tolerance 1e-5). Now a binding that takes the args always gets them, so the integrator is the one asked for on any pycvc. An older binding still gets the legacy start through the old signature. GRL-SNAM's default stays explicit Euler. tests/test_material_train_native_args.py checks both bindings. Its new case fails without this change.
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
Torch twins of three opt-in additions to libcvc's dynamic vehicle plants. Each is held to a libcvc golden by a parity test, under the DOUBLE contract at 1e-9 relative, with gradients by autograd against libcvc's forward-mode duals:
Nothing changes without the new options or functions: the existing parity files pass unchanged.
The goldens come from those libcvc branches. Their libcvc PRs are open, so this one should merge after them, in case review changes a golden.
1. Wheel spin (
grl_snam.dyn_bike,grl_snam.dyn4)dyn_spin_plant: the state plusom_f, om_r;dyn_spin_ph_parts_at,dyn_spin_ph_rates_at,dyn_spin_ph_hamiltonian,dyn_spin_plant_books;DynBikeParamsgainsr_w,J_f,J_r,B_x,C_x.dyn4_spin_plantand its form and books, on any ground;Dyn4Paramsgains the wheels and libcvc'sdrive_gain,brake_gain,resist_comp;grade_forceis recorded but not twinned: a plant that sets it raises.tests/test_dyn_spin_ph_parity.pyandtests/test_dyn4_spin_ph_parity.py.2. Compliant contact (
grl_snam.dyn_contact, new)dyn_footprint_pointssamples the outline about the centre of gravity;dyn_contact_fieldgives each point within a field's skin:These come out as the barrier's and the damper's body wrenches, the energy, the dissipation and the points touching.
dyn_rounded_box_sdfanddyn_contact_pairdo the same, both ways.dyn_plant/dyn_spin_planttake an optionalwrench, the external port held over the step. Their books gain aportline,dyn_ph_port_work.tests/test_dyn_contact_parity.py), worst difference 0 in every group:3. The full (q, p) form and the side slope (
grl_snam.dyn_bike)dyn_ph_T;dyn_ph_rhs, the momentum-only field;dyn_ph_rhs_full: the slopes as data,f_g, orground=with gravity in H.ground(x, y) -> height:dyn_ph_slope,dyn_ph_potential,dyn_ph_grad_q;dyn_ph_hamiltonian_ground,dyn_ph_rates_ground.dyn_plant(..., side=)takes the slope across the heading;dyn_plant_groundanddyn_plant_books_groundapply gravity along and across the heading. The books' grade line is −ΔV.tests/test_dyn_ph_full_parity.py, againstdyn_ph_full_golden.json: the Humvee on a hillside at six states):[[0, T], [-T^T, J(p)]]is skew, moves no energy, and satisfies Jacobi by autograd (defect below 1e-12);q1 = q0 + hdt T(q1) v1to 1e-13 m, on the ground and flat;Tests
pytest tests/test_dyn_*parity.py tests/test_dyn4_*parity.py: 113 passed.The goldens are byte-identical to libcvc's:
dyn_spin_ph,dyn4_spin_phanddyn_contactfrom 7b862ca0;dyn_ph_fullfrom 9dda6dd3.