Skip to content

[Feature]: Per-env domain randomization of geom contact solver params #2964

Description

@KraHsu

Hi team — first, thanks for Genesis, it's been great to work with for large-batch RL.

I'm using Genesis for sim-to-real on a contact-rich in-hand manipulation task (a dexterous hand reorienting a cube), and ran into one gap in the per-environment domain-randomization surface that I wanted to raise — and offer to help with.

What already works nicely (per-env DR)

Genesis exposes several per-environment randomization knobs, which is exactly what sim2real needs:

  • State-level, always per-env (RigidSolverState, shape (_B, ...)): friction_ratio, mass_shift, i_pos_shift → per-env friction / mass / COM.
  • Model-level, opt-in via flags: batch_dofs_info / batch_links_info / batch_joints_info → per-env kp/kv, armature, frictionloss, damping, link inertia, and joint sol_params.

These cover most of the usual DR ranges and work well.

What seems to be missing

Per-env geom contact compliance (sol_params = [timeconst, dampratio, dmin, dmax, width, mid, power], i.e. the MuJoCo solref/solimp analog) does not appear to be randomizable per environment:

  • In RigidSolver.set_sol_params(...), the geom branch hardcodes batched = False (only joints_idx/eqs_idx can be batched), so passing a (n_envs, ...) tensor with envs_idx for geoms raises "Expecting at most 1D tensor".
  • There is no batch_geoms_info option (only batch_dofs_info / batch_links_info / batch_joints_info).
  • RigidSolverState has friction_ratio per geom/env, but no analogous per-env field for sol_params — geom sol_params lives only in the shared geoms_info.

So contact stiffness/damping can only be set globally (shared across the whole batch), whereas friction can already vary per env.

(Version: genesis==1.0.0.)

Why it matters

For contact-rich manipulation, randomizing contact compliance per env (alongside friction) is one of the more important levers for closing the sim2real gap — it's a standard part of DR recipes elsewhere (e.g. MuJoCo solref/solimp randomization). Per-env friction alone covers tangential grip but not normal-direction stiffness/restitution, so the policy can overfit to the simulator's exact contact response.

Possible directions

A couple of options that would mirror existing patterns:

  1. Add a per-env sol_params_ratio (or full per-env sol_params) field in geoms_state, mirroring how friction_ratio works, and have the contact constraint kernel read the per-env value — then expose it via a set_geoms_sol_params / envs_idx-aware setter.
  2. Or add a batch_geoms_info option (parallel to batch_dofs_info) that makes geoms_info.sol_params per-env.

Is per-env geom sol_params something you'd consider supporting, or is there an existing path I've missed? Happy to help test, and I'd be glad to contribute a PR (option 1 looks like the smaller change since friction_ratio is a good template) if that'd be welcome.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions