mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

Question about texture

Open Lucky-hqj opened this issue 4 years ago • 4 comments

Recently, I tried to use [ Google Scanned Objects ] (https://app.gazebosim.org/GoogleResearch/fuel/collections/Google%20Scanned%20Objects) in mujoco, but I find the texture of the object like this: alarm_clock I didn't find a proper way to use the texture like this. Can you give me some advice?

Lucky-hqj avatar Jun 07 '22 15:06 Lucky-hqj

@Lucky-hqj The mug example in the model directory should be a great reference. I mimicked its contents and got the following:

Screen Shot 2022-06-07 at 12 34 45 PM

The documentation is also really helpful in this regard. Check out texture for loading the PNG image and material for referencing the texture. And finally, here's an XML file to help you get started (note that you are better off using simpler approximate collision geoms than the mesh itself).

XML file
<mujoco model="clock">
<compiler meshdir="meshes" texturedir="materials/textures"/>

<visual>
  <headlight ambient="0 0 0" diffuse="0 0 0" specular="1 1 1"/>
  <quality shadowsize="8192"/>
</visual>

<asset>
  <texture name="clock" file="texture.png" type="2d"/>
  <material name="clock" texture="clock" specular="1" shininess="1"/>
  <mesh name="clock" file="model.obj" scale="1 1 1"/>
  <material name="floor" reflectance=".1"/>
</asset>

<worldbody>
  <light pos=".4 -.4 .3" dir="-2 2 -1.5" diffuse=".6 .6 .6"/>
  <light pos="-.2 -.4 .3" dir="1 2 -1.5" diffuse=".6 .6 .6"/>
  <geom type="plane" size="5 5 .01" rgba="1 1 1 1" material="floor"/>
  <body name="clock" pos="0 0 0.01">
    <freejoint/>
    <geom type="mesh" material="clock" mesh="clock" group="2" contype="0" conaffinity="0"/>
    <geom type="mesh" mesh="clock" group="3"/>
  </body>
</worldbody>
</mujoco>

kevinzakka avatar Jun 07 '22 16:06 kevinzakka

Thank you very much! This is very inspiring to me. I'm not very familiar with mujoco yet. About "note that you are better off using simpler approximate collision geoms than the mesh itself ", Do you mean like this in the mug example:

  <default>
    <default class="collision">
      <geom type="box" group="3"/>
      <default class="cup">
        <geom size="0.0026 0.00704 0.033"/>
      </default>
      <default class="handle">
        <geom size="0.0025 0.00328 0.0055"/>
      </default>
    </default>
  </default>

Lucky-hqj avatar Jun 08 '22 03:06 Lucky-hqj

@Lucky-hqj Correct, you may want to do similar approximations for the clock.

kevinzakka avatar Jun 08 '22 18:06 kevinzakka

@kevinzakka Thank you very much! I hope I can do some interesting thing about robot learning on mujoco!

Lucky-hqj avatar Jun 09 '22 12:06 Lucky-hqj