IsaacLab icon indicating copy to clipboard operation
IsaacLab copied to clipboard

[Proposal] Stabilize `_spawn_mesh_geom_from_mesh`

Open TCA166 opened this issue 8 months ago • 1 comments

Proposal

I would like for the _spawn_mesh_geom_from_mesh function to become a stable, documented and public part of the library.

Motivation

I am trying to implement a way to spawn procedurally generated objects into a scene, meaning creating USD files is a bit of a hassle. While looking through the source I found this awesome function _spawn_mesh_geom_from_mesh, however it's very hidden and marked as private. Why is that?

Alternatives

Honestly any sort of interface for spawning things that aren't inside of a file would be great.

Additional context

Checklist

  • [x] I have checked that there is no similar issue in the repo (required)

Acceptance Criteria

TCA166 avatar Apr 29 '25 18:04 TCA166

Thanks for posting this proposal. Have you looked at domain randomization? Would this be something that'd help?

RandomOakForest avatar Apr 30 '25 21:04 RandomOakForest

Thank you for responding! No I haven't looked into domain randomization, it certainly will come in useful later down the line so thank you for pointing me in that direction, but I can't see the relevance of it in regards to spawning procedurally generated meshes. The workflow we have currently looks something like this:

@dataclass
class DynamicMesh(AssetMesh):

    mesh: Trimesh

    def to_cfg(self) -> SpawnerCfg:
        def func_wrapper(prim: str, cfg: MeshCfg, *args, **kwargs):
            return _spawn_mesh_geom_from_mesh(
                prim, cfg, self.mesh, *args, **kwargs
            )

        return MeshCfg(func=func_wrapper)

which is then used to create AssetBaseCfg instances. It works great right now, but we are rather obviously afraid that some change later down the line will break it.

TCA166 avatar May 05 '25 09:05 TCA166

Just in case anyone else stumbles upon a similar issue; we eventually found create_prim_from_mesh call in isaaclab.terrains.utils which does a similar thing. It isn't marked as private, nor does it use a shitty approximate collider mesh, so I think this proposal is moot and you should just use that call. The snippet in my previous comment now looks like this:

def to_cfg(self) -> SpawnerCfg:
        logger.debug("Creating dynamic mesh cfg")

        def func_wrapper(prim: str, cfg: SpawnerCfg, *args, **kwargs):
            create_prim_from_mesh(
                prim,
                self.mesh,
                # visual_material=cfg.visual_material,
                # physics_material=cfg.physics_material,
                *args,
                **kwargs,
            )
            p = prim_utils.get_prim_at_path(prim)
            if cfg.semantic_tags is not None:
                for tag, value in cfg.semantic_tags:
                    apply_semantics(p, tag, value)
            return p

        return SpawnerCfg(func=func_wrapper)

TCA166 avatar May 18 '25 13:05 TCA166