robosuite icon indicating copy to clipboard operation
robosuite copied to clipboard

How to add shapenet object

Open huisyy opened this issue 3 years ago • 5 comments

I'm trying to add a shapenet object. I understand the structure of objects, but I'm really struggling to create the xml/png texture files, as specified in robosuite--right now, I'm trying to use Blender to create an object, and then export into the xml/png files respectively. I was wondering how you guys created the native objects in robosuite, and if there's a better way to do so than what I'm currently doing? Thanks!

huisyy avatar May 19 '22 03:05 huisyy

Hi,

Are you looking to simulate shape shapes (boxes, cylinders, etc) or more complex shapes (a shoe, mug, etc)? For the former case robosuite offers a number of primitive shapes that you can programmatically create, without creating any xml manually (see here for an example).

However if you are interested in more complex shapes, the process is more involved:

  1. First, we recommend switching to the latest mujoco version to support .obj object meshes. This feature was introduced in mujoco 2.1.2, and you would need to use a compatible mujoco-py version that supports this version of mujoco.
  2. You need to generate a convex collision mesh. This can be done with the trimesh collision package, or V-HACD.
  3. Then you need to create a new xml for the object, using the textures and meshes you created in the previous steps. You can perhaps follow the example here for reference.

Just to let you know, our team is working on a pipeline to automatically port ShapeNet objects into robosuite. This is still in the works, we plan to release these features to the public in the coming months. Please let us know if you have additional questions.

Soroush

snasiriany avatar Aug 01 '22 21:08 snasiriany

Hello I have a question: for step 1, I can't find a Mujoco 2.1.2 compatible mujoco-py (the official one supports mujoco210) is there some fork that make this work, or is it possible to run robosuite on >2.1.2 mujoco which is possible to install with pip install mujoco?

Harimus avatar Sep 16 '22 04:09 Harimus

Thanks for the question. Indeed it is difficult to rely on mujoco-py for later versions of Mujoco. We are working right now on removing the dependency on pip install mujoco-py and instead using pip install mujoco. This involves a number of changes under the hood. We are planning to release this version in the coming weeks.

snasiriany avatar Sep 17 '22 01:09 snasiriany

Hi, thank you for the reply! Ok I guess I'll wait for now, but is there a known workaround to this if I want to move on with this while waiting?

otherwise, do you need help/take pr related to this dependency replacement?

Harimus avatar Sep 21 '22 09:09 Harimus

I tried these steps a while back for Ubuntu, hopefully they end up working for you:

  • Download mujoco-2.1.1 into ~/.mujoco directory

  • Make a “fake” mujoco210 folder in the ~/.mujoco directory, and make an empty bin folder in mujoco210

  • Add 4 symlinks exactly like this:

ln -sf ~/.mujoco/mujoco-2.1.1/lib/libglewegl.so ~/.mujoco/mujoco210/bin/libglewegl.so
ln -sf ~/.mujoco/mujoco-2.1.1/lib/libmujoco.so ~/.mujoco/mujoco210/bin/libmujoco210.so

ln -sf ~/.mujoco/mujoco-2.1.1/lib/libglewegl.so ~/.mujoco/mujoco-2.1.1/bin/libglewegl.so
ln -sf ~/.mujoco/mujoco-2.1.1/lib/libmujoco.so ~/.mujoco/mujoco-2.1.1/bin/libmujoco210.so
  • Make sure your ~/.bash_rc contains these lines:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.mujoco/mujoco210/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.mujoco/mujoco-2.1.1/bin
export MUJOCO_PY_MUJOCO_PATH=~/.mujoco/mujoco-2.1.1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia

snasiriany avatar Sep 21 '22 15:09 snasiriany

Noting here for reference (needed for older versions of robosuite):

  1. Export the object from blender as .obj: this gives both the .obj and the .mtl files
  2. Export the object as .stl
  3. Use obj2mjcf to get the correct .xml file structure
  4. Replace the .obj with the .stl (required for older versions of robosuite; not required for newer versions at the time of this post)

kevin-thankyou-lin avatar Aug 05 '23 19:08 kevin-thankyou-lin