Skip to content

Utilities for dealing with non-convex meshes #2985

@kerrickstaley

Description

@kerrickstaley

The feature, motivation and pitch

It'd be great if Mujoco bundled some helper functions for dealing with non-convex meshes. Right now this is clunky. The approach I originally took in my Python project involved a Bash script to call coacd with certain parameters, a Python script to split the coacd's output .stl into loose parts, git commiting those .stl files, and constructing the Mujoco model XML using string templating (this last part could have been done with the MjSpec API).

I since re-wrote that code to use a helper function def split_nonconvex_meshes(xml: str, mesh_names: list[str] | str, coacd_kwargs: dict = frozendict()) -> str. This function removes the given mesh(es) from the XML file, calls coacd.run_coacd on the .stl files with the given arguments, caches the results on disk, re-adds the split meshes, and updates all geoms to reference the new split meshes. This helper has made my code a lot cleaner: I was able to delete the helper scripts and the checked-in .stl files and string munging.

There's an implementation of this function here.. Is this helper something that y'all would be interested in shipping with Mujoco? Is there another design for this that might work better? (The implementation is AI-written and I would clean it up before opening a PR).

Thanks for building Mujoco!

Alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions