Skip to content

Applying identical CameraInfo intrinsics in SDF <lens> changes point cloud #614

Description

@AlessioLovato

Environment

  • OS Version: Ubuntu 24.04.3 LTS
  • ROS 2 Jazzy
  • Gazebo Sim, version 8.9.0
  • gz-rendering8 8.2.3
  • gz-sensors8 8.2.2

Description

  • Expected behavior: Using custom lens intrinsic parameters (copied from the CameraInfo topic of the same sensor, with the same horizontal FOV) should not alter the generated depth map or point cloud.
  • Actual behavior: Adding the <lens> property in the SDF of the depth camera sensor changes the pointcloud

Note: Adding the projection parameters of the lens does not change the exposed behavior.

Steps to reproduce

Simply add the lens and intrinsic parameters in the sdf. A minimal example to reproduce this can be found at: https://github.com/AlessioLovato/gz-sensors-pcl-bug

Output

The output of this test is shown below:

Horizontal FOV Horizontal FOV + Lens intrinsics

<gazebo reference="${color_frame}">
  <sensor name="${camera_name}_depth" type="depth">
    <topic>
      ${camera_name}/aligned_depth_to_color/image_raw
    </topic>
    <gz_frame_id>${color_frame}</gz_frame_id>
    <camera name="${camera_name}_aligned_depth_camera">
      <camera_info_topic>
        ${camera_name}/aligned_depth_to_color/camera_info
      </camera_info_topic>
      <optical_frame_id>${color_frame}</optical_frame_id>
      <horizontal_fov>
        ${2.0*atan(color_width/(2.0*color_fx))}
      </horizontal_fov>
      <image>
        <width>${color_width}</width>
        <height>${color_height}</height>
      </image>
      <clip>
        <near>${clip_distance_min}</near>
        <far>${clip_distance}</far>
      </clip>
    </camera>
    <always_on>1</always_on>
    <update_rate>${color_fps}</update_rate>
    <visualize>false</visualize>
  </sensor>
</gazebo>

<gazebo reference="${color_frame}">
  <sensor name="${camera_name}_depth_fake" type="depth">
    <topic>
      ${camera_name}_fake/aligned_depth_to_color/image_raw
    </topic>
    <gz_frame_id>${color_frame}</gz_frame_id>
    <camera name="${camera_name}_aligned_depth_camera_fake">
      <camera_info_topic>
        ${camera_name}_fake/aligned_depth_to_color/camera_info
      </camera_info_topic>
      <optical_frame_id>${color_frame}</optical_frame_id>
      <horizontal_fov>
        ${2.0*atan(color_width/(2.0*color_fx))}
      </horizontal_fov>
      <image>
        <width>${color_width}</width>
        <height>${color_height}</height>
      </image>
      <clip>
        <near>${clip_distance_min}</near>
        <far>${clip_distance}</far>
      </clip>
      <lens>
        <intrinsics>
          <fx>${color_fx}</fx>
          <fy>${color_fx}</fy>
          <cx>${color_width / 2.0}</cx>
          <cy>${color_height / 2.0}</cy>
          <s>0.0</s>
        </intrinsics>
      </lens>
    </camera>
    <always_on>1</always_on>
    <update_rate>${color_fps}</update_rate>
    <visualize>false</visualize>
  </sensor>
</gazebo>
No Intrinsics Intrinsics
ros2 topic echo /box_camera/aligned_depth_to_color/camera_info
header:
  stamp:
    sec: 5
    nanosec: 215000000
  frame_id: box_camera_color_frame
height: 720
width: 1280
distortion_model: plumb_bob
d:
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
k:
- 909.7210083007814
- 0.0
- 640.0
- 0.0
- 909.7210083007811
- 360.0
- 0.0
- 0.0
- 1.0
r:
- 1.0
- 0.0
- 0.0
- 0.0
- 1.0
- 0.0
- 0.0
- 0.0
- 1.0
p:
- 909.7210083007814
- 0.0
- 640.0
- 0.0
- 0.0
- 909.7210083007811
- 360.0
- 0.0
- 0.0
- 0.0
- 1.0
- 0.0
binning_x: 0
binning_y: 0
roi:
  x_offset: 0
  y_offset: 0
  height: 0
  width: 0
  do_rectify: false
---
ros2 topic echo /box_camera_fake/aligned_depth_to_color/camera_info
header:
  stamp:
    sec: 75
    nanosec: 769000000
  frame_id: box_camera_color_frame
height: 720
width: 1280
distortion_model: plumb_bob
d:
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
k:
- 909.7210083007812
- 0.0
- 640.0
- 0.0
- 909.7210083007812
- 360.0
- 0.0
- 0.0
- 1.0
r:
- 1.0
- 0.0
- 0.0
- 0.0
- 1.0
- 0.0
- 0.0
- 0.0
- 1.0
p:
- 909.7210083007814
- 0.0
- 640.0
- -0.0
- 0.0
- 909.7210083007811
- 360.0
- 0.0
- 0.0
- 0.0
- 1.0
- 0.0
binning_x: 0
binning_y: 0
roi:
  x_offset: 0
  y_offset: 0
  height: 0
  width: 0
  do_rectify: false
---

The data in the published depth image do not appear to change instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions