gz-sensors icon indicating copy to clipboard operation
gz-sensors copied to clipboard

OGRE2: Camera sensor clipping stops working when model is rotated

Open peci1 opened this issue 3 years ago • 6 comments

Environment

  • OS Version: Ubuntu 18.04
  • Source or binary build? binary 4.1.0
  • If this is a GUI or sensor rendering bug, describe your GPU and rendering system. Otherwise delete this section.
    • Rendering plugin: ogre2
      • [x] Sensor rendering error.
    • Generally, mention all circumstances that might affect rendering capabilities:
      • [x] running on real hardware
    • Rendering system info:
$ LANG=C glxinfo -B | grep -i '\(direct rendering\|opengl\|profile\)'  # might require installing mesa-utils package
direct rendering: Yes
    Preferred profile: core (0x1)
    Max core profile version: 4.6
    Max compat profile version: 4.6
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL vendor string: AMD
OpenGL renderer string: AMD RENOIR (DRM 3.40.0, 5.11.15-051115-generic, LLVM 12.0.0)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 21.0.3 - kisak-mesa PPA
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 4.6 (Compatibility Profile) Mesa 21.0.3 - kisak-mesa PPA
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 21.0.3 - kisak-mesa PPA
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20  
$           ps aux | grep Xorg
peci1     2932  2.9  0.3 2267408 113700 tty2   Sl+  dub27  92:55 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3
peci1    16226  0.0  0.0  15672  1024 pts/1    S+   22:53   0:00 grep --color=auto Xorg
$           sudo env LANG=C X -version  # if you don't have root access, try to tell the version of Xorg e.g. via package manager
X.Org X Server 1.20.8
X Protocol Version 11, Revision 0 
Build Operating System: Linux 4.15.0-140-generic x86_64 Ubuntu
Current Operating System: Linux cras-17 5.11.15-051115-generic #202104161034 SMP Fri Apr 16 10:40:30 UTC 2021   x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.11.15-051115-generic root=UUID=d982512a-7987-4852-992c-9aeeddc50c46 ro amd_iommu=on
Build Date: 08 April 2021  01:40:27PM
xorg-server-hwe-18.04 2:1.20.8-2ubuntu2.2~18.04.5 (For technical support please see http://www.ubuntu.com/support) 
Current version of pixman: 0.34.0
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.

Description

  • Expected behavior: Near clip distance of a camera means that all objects that are closer to the camera than this distance are not rendered.
  • Actual behavior: This holds only when the model is aligned with world axes. When the robot is rotated, the clipped objects appear in the camera view.

Steps to reproduce

  1. LANG=C ign gazebo -v4 occlusion.sdf
  2. display camera image
  3. it should be all grey
  4. use transform control or any other means to rotate the model
  5. when the model is rotated by roughly 10 degrees and more, the sphere appears in the camera view

This behavior is wrong because the transform between the sensor and the sphere is static. That should apply consistent behavior no matter where the model is located (except lighting).

The scene in the example is as follows: camera is in the origin, sphere with 0.1 radius is located at X axis 0.25 forward. So the sphere occupies X axis from 0.15 to 0.35. Near clip distance is set to 0.4, so the sphere should not be rendered.

OGRE1 handles this case correctly.

This bug manifests not only with simple shapes, but also with meshes. We've faced it with practically all of our SubT models when preparing them. A simple to test one is Marmotte camera_0 (https://github.com/osrf/subt/pull/842).

In the example SDF, setting camera near clip distance to anything higher than 0.35 triggers this bug.

This happens with "camera" and "thermal" type sensors. Types "rgbd" (both color and depth) and "depth" are not affected. The fact that the color camera from "rgbd" sensor is not affected might point to a possible direction of research for this bug...

Output

Aligned with axes:

Snímek obrazovky pořízený 2021-05-01 23-18-22

Rotated:

Snímek obrazovky pořízený 2021-05-01 23-18-48

Minimum Buggy Example

occlusion.sdf:

<?xml version="1.0" ?>
<sdf version="1.6">
    <world name="test_occlusion">
        <scene>
            <ambient>0.5 0.5 0.5 1.0</ambient>
        </scene>
        <plugin filename="ignition-gazebo-physics-system" name="ignition::gazebo::systems::Physics">
            <engine>
                <filename>ignition-physics3-tpe-plugin</filename>
            </engine>
        </plugin>
        <plugin filename="libignition-gazebo-sensors-system.so"
                name="ignition::gazebo::systems::Sensors">
            <render_engine>ogre2</render_engine>
        </plugin>
        <plugin filename="libignition-gazebo-user-commands-system.so"
                name="ignition::gazebo::systems::UserCommands">
        </plugin>
        <plugin filename="libignition-gazebo-scene-broadcaster-system.so"
                name="ignition::gazebo::systems::SceneBroadcaster">
        </plugin>

        <model name="occlusion">
            <static>1</static>
            <link name='base_link'>
                <visual name="test">
                    <pose frame="">0.25 0 0 0 0 0</pose>
                    <geometry>
                        <sphere>
                            <radius>0.1</radius>
                        </sphere>
                    </geometry>
                </visual>
                <sensor name="camera" type="camera">
                    <camera name="camera">
                        <horizontal_fov>1.3</horizontal_fov>
                        <image>
                            <width>960</width>
                            <height>600</height>
                            <format>R8G8B8</format>
                        </image>
                        <clip>
                            <near>0.4</near>
                            <far>300</far>
                        </clip>
                    </camera>
                    <update_rate>6</update_rate>
                </sensor>
            </link>
        </model>

    </world>
</sdf>

peci1 avatar May 01 '21 21:05 peci1