Make the narrow-phase contact prediction distance configurable - #28
Closed
haixuanTao wants to merge 2 commits into
Closed
Make the narrow-phase contact prediction distance configurable#28haixuanTao wants to merge 2 commits into
haixuanTao wants to merge 2 commits into
Conversation
The narrow-phase used a hardcoded 2mm PREDICTION constant (its TODO asked for this). RbdSimParams already carries normalized_prediction_distance; plumb prediction_distance() into the narrow-phase kernels as a scalar uniform. Default behavior unchanged. A wider margin matters for articulated statics: with the solver holding equilibrium penetration near zero, a 2mm window drops a box foot\x27s far-edge corners at ~0.5 deg of tilt — the manifold collapses to one edge (zero pitch moment capacity) and the foot rocks. PhysX ships ~2cm contactOffset for the same reason. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B7NC7U2wDx2tSmT9mkeF9h
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
|
This will be merged as part of #36 |
sebcrozet
added a commit
that referenced
this pull request
Aug 29, 2026
* fix(rbd): apply the per-batch stride to collider_parent reads in the narrow phase Replaces #21 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@outlook.com> * feat: per-environment collision-pair capacity override Replaces #24 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@outlook.com> * feat(rbd): make the narrow-phase contact prediction distance configurable Replaces #28 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@outlook.com> * fix(rbd): thread the configurable prediction distance through the brute-force broad phase Completes #28 * feat(python): per-environment MJCF insertion Replaces #16 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@outlook.com> * fix(python): drop the duplicated collisions-capacity setter and pass the RbdCoupling to insert_rigid_body_in Completes #16 * feat(python): per-step MJCF actuator control + multibody state readback Replaces #12 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@1ms.ai> * fix(python): gate multibody control/readback on dim3, add the missing PyArray2 import Replaces #12 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@outlook.com> * fix(rbd): decode the SoA link workspace for the multibody readback and drop the stale set_gravity copy Completes #12 * perf(rbd): dedupe shared TriMesh uploads in from_rapier Replaces #19 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@outlook.com> * perf(rbd): optional GPU contact reduction, merging per-pair manifolds to <=4 points Replaces #17 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@outlook.com> * fix(rbd): pass the prediction distance to manifold_reduction in the contact-reduction kernel Completes #17 * perf(rbd): flat 1-D narrow-phase dispatch, packing warps across batches Replaces #21 Co-Authored-By: Haixuan Xavier Tao <tao.xavier@outlook.com> * fix(rbd): restore the contacts capacity binding and import atomic_load_u32 for the flat dispatch Completes #21 * fix(rbd): drop the stale 2mm PREDICTION constant reintroduced by the flat-dispatch port Completes #21 * fix mpm feature-gating * feat(rbd): expose dof_state_mut, links_static, joint_constraints and link_of_body * feat(rbd): env-reset primitives, GPU motor scatter, contact sensors, actuator delay, encoded step, substep-refresh cadence and per-DoF armature/frictionloss * fix(rbd): guard against implicit-coriolis drifting from the batch_indices uniform * feat(rbd): cluster contact manifolds by normal, matching rapier, with a tunable threshold * feat(rbd): model multibody joint frictionloss as a constraint instead of a force * feat(rbd): seed per-DoF joint friction from rapier's Multibody::frictions * refactor(rbd): read the contact prediction distance from RbdSimParams instead of a dedicated uniform * chore: cargo fmt * refactor(rbd): move the contact merge cosine into RbdSimParams * refactor: move read_multibody_links onto NexusState and drive every env from control_multibody_motors * test(rbd): add a headless many-small-environments step-timing harness * revert(rbd): drop the flat 1-D narrow-phase dispatch Measured 7-21% slower on Metal. * chore: cleanup comments * fix: gate control_multibody_motors on dim3 so the 2D build still compiles * fix instability in joint-ball3 demo * chore: remove debug test files * chore: cleanups * fix(rbd): build the bench harness without the metal feature and only in 3D * fix(rbd): silence the clippy needless-borrow and unnecessary-mut lints * fix(rbd): split the joint-constraint back-solve into its own dispatch to fit 8 storage buffers * test(rbd): keep the bench harness under wgpu's default buffer-size limit * fix(rbd): split the batched env reset into pose and DoF passes to fit 8 storage buffers * chore: switch to the published rapier version * fix: make all envs share the same RbdSimParams * chore: clippy fixes --------- Co-authored-by: Haixuan Xavier Tao <tao.xavier@outlook.com> Co-authored-by: Haixuan Xavier Tao <tao.xavier@1ms.ai>
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.
Resolves the narrow-phase
TODO: make the prediction configurable— the 2 mmPREDICTIONconstant becomes a scalar uniform fed from the existingRbdSimParams::prediction_distance()(which was previously unused by these kernels). Default behavior is unchanged (the param already defaults to 0.002).Why it matters
With the solver holding equilibrium penetration near zero, a 2 mm speculative window drops a box foot's far-edge corners at ~0.5° of tilt: the contact manifold collapses from a 4-point face to a single edge — zero pitch moment capacity — and an articulated robot's foot rocks between edges instead of resting flat (verified on a G1 humanoid via a contact-constraint readback: 2 points per foot flip-flopping front/back edge, becoming a stable 4-point face once the margin covers the tilt). Speculative rows exert no force until touch, so a wider margin only adds manifold points. PhysX ships ~2 cm
contactOffsetfor the same reason; with this change users can pick the margin per scene instead of inheriting the game-tuned 2 mm.42 insertions / 11 deletions across the three narrow-phase kernels (scalar uniform), the dispatch wrapper, and the state builders.
cargo checkclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01B7NC7U2wDx2tSmT9mkeF9h