Genesis-Embodied-AI/genesis-world · error · ValueError

Cannot handle soft material {material_soft}

Error message

Cannot handle soft material {material_soft}

What it means

When a hybrid entity sets up its soft part with explicit (non-default) coupling functions, the soft material attached to the soft particle system must be one of the recognized soft material classes (the branch handling `part_soft.init_particles`, e.g. Particle or similar MSM/soft materials). If `material_soft` is of any other type, the else branch raises this ValueError, echoing the material in the message.

Source

Thrown at genesis/engine/entities/hybrid_entity.py:152

            if isinstance(material_soft, gs.materials.MPM.Base):
                part_soft_info = qd.types.struct(
                    link_idx=gs.qd_int,
                    geom_idx=gs.qd_int,
                    trans_local_to_global=gs.qd_vec3,
                    quat_local_to_global=gs.qd_vec4,
                ).field(shape=(material_soft.n_groups,), needs_grad=False, layout=qd.Layout.SOA)
                part_soft_info.link_idx.from_numpy(np.asarray(link_idcs, dtype=gs.np_int))
                part_soft_info.geom_idx.from_numpy(np.asarray(geom_idcs, dtype=gs.np_int))
                part_soft_info.trans_local_to_global.from_numpy(np.asarray(trans_local_to_global, dtype=gs.np_float))
                part_soft_info.quat_local_to_global.from_numpy(np.asarray(quat_local_to_global, dtype=gs.np_float))

                part_soft_init_positions = qd.field(dtype=gs.qd_vec3, shape=(part_soft.init_particles.shape[0],))
                part_soft_init_positions.from_torch(gs.Tensor(part_soft.init_particles))

                self._part_soft_info = part_soft_info
                self._part_soft_init_positions = part_soft_init_positions
            else:
                raise ValueError(f"Cannot handle soft material {material_soft}")

            # set coupling func
            def wrap_func(func, before=False):
                def wrapper(f):
                    if before:
                        self.update_soft_part(f)
                    func(f)
                    if not before:
                        self.update_soft_part(f)

                return wrapper

            if isinstance(material_soft, gs.materials.MPM.Base):
                # NOTE: coupling operating at particle level and here we modify post_coupling, i.e., update particle state after g2p
                self._update_soft_part_at_pre_coupling = False
                if self._update_soft_part_at_pre_coupling:
                    part_soft.solver.substep_pre_coupling = wrap_func(
                        part_soft.solver.substep_pre_coupling, before=True

View on GitHub (pinned to 56e4aa5d82)

Solutions

  1. Pass a supported soft material class (e.g. gs.materials.Particle or the MSM/soft material used in the hybrid examples) as the soft material.
  2. Check the hybrid examples for the exact material combination supported by HybridEntity and mirror it.

Example fix

// not applicable - depends on supported soft material classes in the installed version
Defensive patterns

Strategy: type-guard

Validate before calling

import genesis as gs
soft = gs.materials.Particle()
if not isinstance(soft, tuple(SUPPORTED_SOFT_MATERIALS)):
    raise TypeError(f"Unsupported soft material: {type(soft).__name__}")

Type guard

def is_supported_soft_material(material) -> bool:
    import genesis as gs
    return isinstance(material, (gs.materials.Particle,))  # extend per version's supported set

Try / catch

try:
    entity = scene.add_entity(gs.entities.HybridEntity(morph=m, material=mat))
except ValueError as e:
    if "Cannot handle soft material" in str(e):
        raise ValueError(f"Bad soft material: {e}") from e
    raise

Prevention

When it happens

Trigger: `scene.add_entity(HybridEntity(...))` with `use_default_coupling=False` and a soft material whose type is not one of the supported soft material classes (e.g. a rigid or unknown/custom material passed as the soft part).

Common situations: Mixing up the material arguments when constructing a hybrid entity (passing a RigidMaterial where the soft material is expected); passing a custom material subclass the coupler does not recognize.

Related errors


AI-assisted analysis of Genesis-Embodied-AI/genesis-world@56e4aa5d82 (2026-08-28). Data as JSON: /api/errors/5d80ebc706141c87. Report an issue: GitHub.