Height scale when using png image as heightmap

Issue #2601 new
R. Omar Chavez Garcia
created an issue

I have been analysing how gazebo (v7.0) renders a png image when included as heightmap in a world file.

Assuming we have a 513x513 8bit png where its maximum value is 127 and its minimum 0. When I indicate the size of the collision/geometry element as 10 10 0.5:

       <collision name="collision">
          <geometry>
            <heightmap>
              <uri>model://worlds/steps.png</uri>
              <size>10 10 0.5</size>
              <pos>0 0 0</pos>
            </heightmap>
          </geometry>
        </collision>

(Note: I indicate the same size in the visual/geometry/heightmap element of the world file)

I expect the image to be rendered as a 10 x10m map with a maximum height value of 0.5 meters. However it maximum height is around 0.25m. Documentation mentions that the size either for collision or visual elements for a heightmap indicates the scale the heightmap to which it will be rendered in gazebo. It properly renders width and length but height seems unreliable. Am I missing something regarding how Z element in size is treated?

I have analysed other maps (same png size but different max/min values) and some times I get the height properly rendered, specially when the max value in the png is 255 and I want to render it to 1.0m.

Comments (2)

  1. R. Omar Chavez Garcia reporter

    Update: this is the full world file:

    <?xml version="1.0" ?>
    <sdf version="1.4">
      <world name="default">
    
        <include>
          <uri>model://sun</uri>
        </include>
    
        <model name="heightmap">
          <static>true</static>
          <link name="link">
    
            <collision name="collision">
              <geometry>
                <heightmap>
                  <uri>model://worlds/steps.png</uri>
                  <size>10 10 0.5</size>
                  <pos>0 0 0</pos>
                </heightmap>
              </geometry>
            </collision>
    
            <visual name="visual_abcedf">
              <geometry>
                <heightmap>
                  <use_terrain_paging>false</use_terrain_paging>
                  <texture>
                    <diffuse>file://media/materials/textures/dirt_diffusespecular.png</diffuse>
                    <normal>file://media/materials/textures/flat_normal.png</normal>
                    <size>1</size>
                  </texture>
                  <uri>model://worlds/steps.png</uri>
                  <size>10 10 0.5</size>
                  <pos>0 0 0</pos>
                </heightmap>
              </geometry>
              <material script='Gazebo/White'>
                <emissive rgba='1.0 1.0 1.0 1.0'/>
              </material>
            </visual>
          </link>
        </model>
    
      </world>
    </sdf>
    
  2. Steven Peters

    It's my understanding that the vertical size of the heightmap is based on the product of the Z value in the <size> element with the pixel values scaled from 0 to 1. In both examples, you have a z value of 0.5, so I would expect a size of 0.5 only if you had pixel values of 0 and 1 (or 0, 255 in 8-bit).

  3. Log in to comment