Camera plugin changing image size during run time

asked 2022-01-12 02:22:27 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi guys,

I have an issue regarding a camera sensor. I would like to change the width and height of the image during simulation to simulate different cameras in one run. Changing horizontal field of view (HFOV) or Clipping works fine. However when setting the Image Size by SetImageWidth() / SetImageHeight() / SetImageSize() has no affect and calling e.g. ImageHeight directly afterwards returns the original value.

Any idea why the documented feature doesn't work as expected?

example code:

// if sensor is the camera sensor pointer of type gazebo::sensors::SensorPtr
gazebo::sensors::CameraSensorPtr camera = std::static_pointer_cast<gazebo::CameraSensor>(sensor);
camera->Camera()->SetHFOV(ignition::math::Angle(61*M_PI/180.0)); //Works
camera->Camera()->SetImageWidth(1920); // Has no affect as ImageWidth returns original value
camera->Camera()->SetImageHeight(1080); // Has no affect as ImageHeight returns original value
camera->Camera()->SetImageSize(1920,1080);// Has no affect as ImageWidth and /ImageHeight return original values
edit retag flag offensive close merge delete