Robotics StackExchange | Archived questions

imported mesh (.dae) with texture too dark in gazebo

Hey,

I acquired a point cloud with the kinect and generated a mesh with texture in meshlab leading to a dae-file and a png.

First, the object was completely black in gazebo. I changed the ambient value from 0 0 0 1 to 1 1 1 1. Now, I can see the texture but it is still darker than it should be.

Visualizing the object with rviz it looks as I would expect (it is a little darker if i set the ambient value to 0 0 0, but still fine).

This is how it looks like in rviz: rviz

and here with gazebo: gazebo

Is this a normal behavior?

Asked by edith on 2015-04-14 10:04:46 UTC

Comments

Answers

Shading in gazebo depends on:

  1. Material properties of the object being rendered. This is found in your dae file, and possibly in your SDF file.
  2. Lighting properties, which includes ambient light and any lights
  3. Normals of the object being rendered.

Try to visualize the normals of you mesh in blender, and possibly recalculate the normals in blender to see if the problem is fixed.

Asked by nkoenig on 2015-04-14 13:14:06 UTC

Comments

Open your .dae file in a text editor and search for the location where the texture file is specified (e.g. tex.png)

The surrounding lines should look something like the following

  <library_images>
    <image id="tex_png" name="tex_png">
      <init_from>tex.png</init_from>
    </image>
  </library_images>
  <library_effects>
    <effect id="tex_png-effect">
      <profile_COMMON>
        <newparam sid="tex_png-surface">
          <surface type="2D">
            <init_from>tex_png</init_from>
          </surface>
        </newparam>
        <newparam sid="tex_png-sampler">
          <sampler2D>
            <source>tex_png-surface</source>
          </sampler2D>
        </newparam>
        <technique sid="common">
          <phong>

            <emission>
              <color sid="emission">0.2 0.2 0.2 1</color>
            </emission>
            <ambient>
              <color sid="ambient">0.9 0.9 0.9 1</color>
            </ambient>
            <specular>
              <color sid="specular">0.5 0.5 0.5 1</color>
            </specular>
            <shininess>
              <float sid="shininess">50</float>
            </shininess>
            <index_of_refraction>
              <float sid="index_of_refraction">1</float>
            </index_of_refraction>

            <diffuse>
              <texture texture="tex_png-sampler" texcoord="tex_png"/>
            </diffuse>
          </phong>
        </technique>
      </profile_COMMON>
    </effect>
  </library_effects>

Make sure the <ambient> tag within the <phong> tags exist (since it seems gazebo defaults the ambient value to be some low value).

All the others are optional and can be tweaked to your own content. The values above were taken from the box_target_green example in the gazebo models repo and seems to work good enough.

If someone knows how to set these settings from blender, do enlighten us

PS:: Please enable the use of ``` for quoting code similar to stack overflow...

Asked by wongrufus on 2020-01-08 22:00:50 UTC

Comments