gazebosim / gz-sensors

Provides numerous sensor models designed to generate realistic data from simulation environments.
https://gazebosim.org
Apache License 2.0
63 stars 58 forks source link

WideAngleCameraSensor only supports RGB8 format, not L8 as in Classic #479

Open ana-GT opened 2 weeks ago

ana-GT commented 2 weeks ago

Desired behavior

WideAngleCameraSensor is currently supporting only RGB8 format. The same sensor in Gazebo Classic supported RGB8 and gray (L8) images. I am porting some robot simulation code for Astrobee from Gazebo classic to Gazebo, where one of the robot's sensors is defined as a wideanglecamera of type mono8, which seems not to be supported (line 330 of WideAngleCameraSensor.cc indicates that the L8 type is an unsupported format)

Alternatives considered

The easiest option would be for me to create a custom sensor that is a copy-and-paste of wideanglecamerasensor and just allow both RGB8 and L8 as valid pixel formats. Before doing this however, I wanted to check if there was the possibility of adding support for gray images, as it might be useful for other users with similar setups and it seems as if it might be relatively easy to do (just add a case in the switch (line 324-333 of WideAngleCameraSensor.cc) to allow L8 to be accepted:

  sdf::PixelFormatType pixelFormat = cameraSdf->PixelFormat();
  switch (pixelFormat)
  {
    case sdf::PixelFormatType::RGB_INT8:
      this->dataPtr->camera->SetImageFormat(gz::rendering::PF_R8G8B8);
      break;
    default:
      gzerr << "Unsupported pixel format ["
        << static_cast<int>(pixelFormat) << "]\n";
      break;
  }

Additional context

Test setup: Ubuntu 24.04, gz-sensors 8.8.2. ROS2 Jazzy (the issue is exclusively regarding the sensor, nothing to do with ROS, but adding that piece of info for completeness).

Thanks!