Gazebo | Ignition | Community
Ask Your Question
0

Texture does not work properly

asked 2019-08-21 09:11:19 -0600

kumpakri gravatar image

I am trying to put a texture defined in PNG file to a custom made model in defined by OBJ file.

I have this folder structure with the model

model_name
├── materials
│   ├── scripts
│   │   └── model_name.material
│   └── textures
│       └── floor0.png
├── meshes
│   └── model_name.obj
├── model.config
└── model.sdf

this is the image floor0.png

image description

This is the model.sdf file content

<?xml version="1.0" ?>
<sdf version="1.6">
  <model name="model_name">
    <static>true</static>
    <link name="link">
      <pose>0 0 0 0 0 0</pose>
      <collision name="collision">
        <geometry>
          <mesh>
            <uri>model://model_name/meshes/model_name.obj</uri>
          </mesh>
        </geometry>
        <surface>
            <friction>
                <ode>
                    <mu>1</mu>
                    <mu2>1</mu2>
                    <fdir1>0 0 0</fdir1>
                    <slip1>0</slip1>
                    <slip2>0</slip2>
                </ode>
            </friction>
        </surface>
      </collision>
      <visual name="visual">
        <geometry>
          <mesh>
            <uri>model:/model_name/meshes/model_name.obj</uri>
          </mesh>
        </geometry>
        <material>
          <script>
            <uri>model://model_name/materials/scripts</uri>
            <uri>model://model_name/materials/textures</uri>
            <name>Floor0</name>
          </script>
        </material>
      </visual>
    </link>
  </model>
</sdf>

this is the model_name.material file content

material Floor0
{
    technique
    {
        pass
        {
            texture_unit
            {
                texture ../textures/floor0.png
                scale 1.0 1.0
            } 
        }
    }

And this is the resulting view in Gazebo when I launch spawn this model

image description

It is only one color (the color in the bottom left corner of the PNG file). Couriously if I change the scale in the material file, the color might change to orange (the color in the middle of the PNG file) but the color stays homogeneous.

What is happening and how do I make the Gazebo render the texture correctly?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-08-21 11:43:34 -0600

chapulina gravatar image

The problem seems to be on the UV mapping of your OBJ file.

We usually use MTL files to set the material of OBJ meshes, see an example here. I would try to export an MTL file together with your OBJ from the modelling software you used.

edit flag offensive delete link more

Comments

1

Thank you! I had to make the UV map for my model inside Blender by hand following this tutorial and after that the textures applied to the model are showing correctly.

kumpakri gravatar imagekumpakri ( 2019-08-22 03:40:19 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2019-08-21 09:11:19 -0600

Seen: 1,285 times

Last updated: Aug 21 '19