RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.33k stars 1.26k forks source link

Improve and distribute meshlab_to_sdf #18841

Closed jwnimmer-tri closed 1 year ago

jwnimmer-tri commented 1 year ago

In #18776 we added the ability to parse an OBJ file directly into a MultibodyPlant + SceneGraph. It presumes lot of defaults for things, which is useful for certain uses cases and/or prototyping, but those defaults are not always satisfactory.

When the user needs more than we can offer with that Parser feature, they should instead write a real model file that wraps the OBJ.

To date, we have drake/manipulation/util/meshlab_to_sdf.py available to semi-automate that model file creation process, but:

At this point, we should be able to do better by directly creating the SDFormat file using Drake features, without any need to shell out to meshlab.

The call to action here is to reimplement that tool, with better features, and install it as part of pydrake.

Near term, we'd want these options:

Longer term, we could image that this tool could also grow features like:

SeanCurtis-TRI commented 1 year ago

Where in pydrake would this python file go?

jwnimmer-tri commented 1 year ago

As far as an implementation pattern, either of meldis or model_visualizer are a good example. The class is in one file, and next door there's a sub-module with a main function that can be run from the command line.

The question then is which top-level model to place it in. I hadn't thought about that yet, but my first reaction is pydrake.multibody, so it would be like python3 -m pydrake.multibody.foobarbaz --input=carrot.obj.

SeanCurtis-TRI commented 1 year ago

I'm fine with pydrake.multibody. Seems as good as anything else.

jwnimmer-tri commented 1 year ago

We should probably leave room in the command line naming design so that we can output either SDFormat or URDF (or maybe even MJCF) at the user's choice, even if for now it only does SDFormat. I could foresee users wanting the option to use a different output format.

jwnimmer-tri commented 1 year ago

(See also https://github.com/kevinzakka/obj2mjcf/ for related work.)

SeanCurtis-TRI commented 1 year ago

18886 Largely resolves this issue.

There was a question about including a cross reference to the obj2mjcf resource linked above. So, until that last piece gets added, we'll leave this issue open.

jwnimmer-tri commented 1 year ago

I'll circle back to #19070 soon and mention both mesh_to_model and obj2mjcf in the documentation there.

I'll most likely also update the doxygen for class Parser with cross-links. For me, that class overview is already extremely difficult to read so I'm not quite sure yet about how to swing it.

rpoyner-tri commented 1 year ago

First thought: probably some of the class Parser doc could be spilled to the parsing_doxygen.h or so. I'm sure parsing_doxygen.h also needs some refresh as well.

jwnimmer-tri commented 1 year ago

With the doc changes landed in #19070, I understand this to be complete.