Repository navigation
dyn_bike_plant: the contact's damper and friction implicit; contact substeps for fast impacts - #1004
Merged
Merged
Conversation
…ubsteps for fast impacts The compliant contact (#983) held its Hunt-Crossley damper and friction from the substep's start. Their coefficients grow with the penetration, so in a fast impact hdt R_c / m passes 2 at the default 0.01 s substep: pycvc's navigator driving the full-size preset into a wall in sim_world's field at 7.8 m/s reversed the vehicle within a tick to -3.24 m/s (the reverse clamp), the damper supplied 1.5e5 J (contact_dissipated < 0), the speed clamp took 2.4e5 J and the residual was 3.1e-2 of the flow. nav's grid SDF makes it worse: phi runs from +1 cell to -1 cell across the cell at a face, so there the barrier is 4x and the damper 8x as stiff per metre of approach as against an exact distance. The damper and the friction are now read implicitly (dyn_contact_implicit), at the twist the step reaches under the bodies' inertia, the barrier's push and themselves: (M + hdt R_c) v_d = M v0 + hdt W_c, W_d = -R_c v_d, with the friction's secants taken again at the slide v_d reaches. The bodies touching each other are solved together, so W_d stays equal and opposite between vehicles. The contact functions report each touching point's damped directions (dyn_contact_row) on request; their outputs are unchanged. The barrier stays explicit, so a step that carries a point far into it leaves that energy in the residual. dyn_bike_plant_options::contact_step_depth (0.1 m) cuts a substep in which a point would close further into equal pieces, held until nothing touches or closes, so a bounce runs at one step (finer steps for the approach alone leave the rebound's errors uncancelled). At the default it splits none of the existing 5 m/s cases. The contact lines' port work uses the step's own hdt, as dyn_plant_books' port does, so the books' identity holds in every piece. Measured (physics_dyn_contact_test, MSVC 19.44 Release): the navigator case at 0.01 s now dissipates 8.16e4 J, limiter 0, slowest -0.47 m/s, residual 1.3e-3 of the flow (at 0.00125 s: 8.19e4 J, -0.47 m/s). New tests DynContact.TheImplicitDamperOnlyDissipates and DynContactPlant.AFastImpactAtTheDefaultSubstep (fails on master); the existing gates pass and DynContact.Golden regenerates byte-identical.
DynContact.TheImplicitDamperOnlyDissipates checked M (v_d - v) = hdt (W_c + W_d) against M |v| + hdt (|W_c| + |W_d|). Stiff dampers (hdt to 1 s) leave v_d nearly across their directions, so W_d = -R_c v_d is far smaller than the terms the solve summed, and the check read the solve's rounding as 4.9e-10 on Windows and 1.26e-9 on Linux (CI failed it at 1e-9). It now divides by |A| |v_d| + |b|, R_c's entries bounded by each row's largest coefficient (a friction secant is at most coulomb / slide): 3.4e-16, gated at 1e-12.
transfix
enabled auto-merge (squash)
November 6, 2026 20:44
transfix
added a commit
that referenced
this pull request
Nov 7, 2026
…efault substep (#1038) pycvc.dyn_bike_plant(..., contact_step_depth=None) binds #1004's dyn_bike_plant_options::contact_step_depth (m; None keeps the plant's default, <= 0 never substeps), and options() reports it. test_pycvc_physics.py's contact case, the navigator driving into a wall from another sim_world's map at about 7.8 m/s, goes back to the default 0.01 s substep: #1002 ran it at 0.005 s because the damper overshot, and #1004's implicit damper and contact substeps fixed that. It now also checks the speed clamp takes nothing, and the new keyword's round trip, default and type. All 77 checks pass (Windows, MSVC 19.44 Release, Python 3.11, on master f94a9b2). At 0.01 s the contact dissipates 8.15e4 J, the limiter takes 0 and the residual is 1.33e-3 of the flow, as #1004's C++ fast-impact test has it.
transfix
added a commit
that referenced
this pull request
Nov 7, 2026
Bumps the project version and every recipe's upstream_version from 3.7.11 to 3.7.12. The v3.7.12 tag on this commit is the first release with the multi-car controller template (pycvc_gl.cars, #1031 #1035 #1040), the hidden-subtree fix in cvcGL (#1037), the discrete-gradient dyn_bike step (#978), semi-implicit Euler by default in the nav rollout (#981), the implicit contact damper (#1004, #1038), and generated_world's roads and water (#1032, #1034).
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.
The compliant contact from #983 overshoots fast impacts at the live plant's default 0.01 s substep. This PR fixes that in
dyn_bike_plantanddyn_contact.h.The problem
pycvc's navigator drove the full-size preset (
vehicle_desc::humvee()) at 7.8 m/s into a wall that the plant reads from sim_world's field. The scene ismake_sim's world fromtest_pycvc_physics.py, with a wall at x = 0..1 m taken from a second sim_world. At 0.01 s:contact_dissipatedwas −1.52e5 J, so the damper supplied energy;limiter);At 0.005 s and finer, none of this happens.
Cause 1: the damper is explicit. The Hunt-Crossley damper and the friction were held from the substep's start. Their coefficients grow with the penetration (c_k = c (s − d)/s). The friction's secant near zero slip is μ k (s − d)/slide. So h·R_c/m passes 2 at depth, and −R_c·v₀ flips the approach within a step.
Cause 2: nav's grid SDF is steep at a face. φ goes from +1 cell to −1 cell across the cell at an obstacle's face (its distances run between cell centres), so |∇φ| = 2 there. Against sim_world's field, the barrier is therefore 4× and the damper 8× as stiff per metre of approach as against an exact distance. The existing tests used an exact wall at 5 m/s and never got there.
The fix
1. Implicit damper and friction (
diff::dyn_contact_implicit).dyn_contact_fieldanddyn_contact_pairhand back each touching point's normal and tangent rows (dyn_contact_row) on request. Their outputs are unchanged.2. Contact substeps for fast impacts (
dyn_bike_plant_options::contact_step_depth, 0.1 m).dyn_contact_closinganddyn_contact_pair_closing).<= 0turns it off.The contact lines' port work now uses the step's own
hdt(float), asdyn_plant_books' port does. Otherwise the books' identity would miss by float(h/2)'s error in a piece.Numbers (physics_dyn_contact_test, Windows MSVC 19.44 Release)
pycvc's navigator into sim_world's wall (the probe above, written in C++):
From −30 m (8.0 m/s at impact), at 0.01 s:
Driven raw into sim_world's field, head on, at 0.01 s (the 0.00125 s result in brackets):
The existing 5 m/s gates (
TheBooksCloseToSecondOrder), master → this PR:ComparesWithJoltOnImpacts(5 m/s, 0.01 s):Tests
DynContact.TheImplicitDamperOnlyDissipates: 846 wall poses and 638 pair poses, at h = 0.01, 0.1 and 1 s, with and without the barrier.Wdto 7.9e-16.DynContactPlant.AFastImpactAtTheDefaultSubstep: the navigator case from −20 m and −30 m; raw drives into sim_world's field at 8.3, 10.3 and 12.3 m/s; a 30° impact on an exact wall; a parked Humvee at 10.3 m/s.contact_dissipated> 0, the clamp taking no more than at 0.00125 s, |Σres|/flow < 5e-3, the identity to 1e-8, and the rebound or slowest speed within 0.02 or 0.05 m/s of the 0.00125 s run.DynContact.Goldenregenerates byte-identical (git hash-object --no-filtersof the rewritten file is HEAD's blob a8d49445). The contact functions' outputs anddyn_plant_booksare untouched, so GRL-SNAM's torch twin fixtures stay valid.Cost
contact_step_depth, a fast or steep contact steps every agent in pieces (1 to 3 in the cases above) until nothing touches or closes. A vehicle left resting against what it hit keeps them. This is documented on the option.Not in this PR
contact_step_depth. The default applies there.