Robotics StackExchange | Archived questions

Camera plugin changing image size during run time

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

Asked by MP on 2022-01-12 03:22:27 UTC

Comments

Answers