Skip to content

[FETURE] Comfree solver#2872

Draft
Kashu7100 wants to merge 2 commits into
Genesis-Embodied-AI:mainfrom
Kashu7100:comfree-solver
Draft

[FETURE] Comfree solver#2872
Kashu7100 wants to merge 2 commits into
Genesis-Embodied-AI:mainfrom
Kashu7100:comfree-solver

Conversation

@Kashu7100
Copy link
Copy Markdown
Collaborator

Summary

  • Adds the ComFree (complementarity-free) constraint solver, an analytical single-pass alternative to the iterative Newton/CG constraint resolution.
  • Parallelizes the resolution over the GPU: instead of one serial thread per env, the kernel runs a fixed sequence of fully data-parallel passes (efc_forceqfrc_constraintforceqacc → publish/warmstart).
  • Uses the batched func_solve_mass for the M^{-1} @ qfrc_total solve and respects the transposed constraint layout so adjacent lanes vary along the coalesced axis.

Notes

  • The no-constraint case needs no special handling: with zero constraint force the mass solve reduces to qacc = M^{-1} qf_smooth = acc_smooth.

Motivation and Context

How Has This Been / Can This Be Tested?

Screenshots (if appropriate):

Checklist:

  • I read the CONTRIBUTING document.
  • I followed the Submitting Code Changes section of CONTRIBUTING document.
  • I tagged the title correctly (including BUG FIX/FEATURE/MISC/BREAKING)
  • I updated the documentation accordingly or no change is needed.
  • I tested my changes and added instructions on how to test it for reviewers.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Kashu7100 and others added 2 commits May 30, 2026 22:21
Port the ComFree analytical contact solver (arXiv:2603.12185, reference
impl asu-iris/comfree_warp) into Genesis as a third constraint_solver
option alongside CG and Newton.

Instead of an iterative complementarity solve, ComFree resolves contacts
in a single pass via an impedance-style prediction/correction update:

    v_pred  = v + acc_smooth * dt
    efc_vel = J_c @ v_pred
    efc_pen = efc_vel * dt + efc_dist
    force   = max(efc_mass * (-d*efc_vel - k*efc_pen), 0)
    qacc    = M^{-1} (qf_smooth + J^T force)

with k, d the user stiffness/damping scaled by 1/dt.

Changes:
- constants: add constraint_solver.ComFree
- options.RigidOptions: comfree_stiffness (0.2), comfree_damping (0.001)
- array_class.ConstraintState: add efc_dist, efc_mass (layout-flippable)
- geom: add comfree_imp (hardcoded width=0.01 impedance) and
  comfree_efc_mass (single efc_mass formula shared by all constraint types,
  mirroring reference constraint.py _efc_row:125)
- constraint/solver: populate efc_dist/efc_mass for contacts (both per-contact
  and per-friction layout paths), equality connect/joint/weld, joint limits,
  and frictionloss
- rigid solver: instantiate ComFreeSolver when selected
- new genesis/engine/solvers/rigid/comfree package (ComFreeSolver + kernels)
- tests/test_comfree.py: instantiation, stepping, analytic free-fall,
  contact settling, 4-env batched, two-box stacking

Validated on CPU: all unit tests pass; a Franka arm scene (joint limits +
actuation + contacts) runs stably with no NaN.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the per-env serial resolution loop with a fixed sequence of
fully data-parallel passes (efc_force, qfrc_constraint, force, qacc,
publish), so the GPU is no longer left idle running one thread per env.
Switch from func_solve_mass_batch to the batched func_solve_mass and
respect the transposed constraint layout for coalesced memory access.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Kashu7100 Kashu7100 mentioned this pull request Jun 1, 2026
7 tasks
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