Data corruption from camera sensor
Hi All. I could do with advice on how to investigate what looks like intermittent corrupt data being returned from a camera sensor.
I'm accessing the camera image from a model plugin, but when I render the resulting images occasionally the scene will be briefly replaced with a mishmash of bright colours.
Frequency of occurrence: 1 or 2 times/minute, usually for less than one second each time. Seems to happen less often if the robot is stationary, i.e. it happens more frequently the more the contents of the scene are changing
On the visualization screen projected from the robot within the Gazebo UI, there is no such corruption visible
I'm accessing the data from within the plugin OnUpdate event, and actually extracting it using:
gazebo::sensors::SensorPtr s2 = gazebo::sensors::get_sensor("camera")
gazebo::sensors::CameraSensor *cs = dynamic_cast<gazebo::sensors::CameraSensor*>(sp.get());
const int COLOR_COMPONENTS = 3;
int _width = cs->GetImageWidth();
int _height = cs->GetImageHeight();
unsigned char buffer[_width*_height*COLOR_COMPONENTS];
std::stringstream ss;
ss << cs->GetImageData();
ss >> buffer;
Camera SDF:
<sensor name="camera" type="camera">
<pose>0.305 0 0.1 0 -0 0</pose>
<camera>
<horizontal_fov>1.0</horizontal_fov>
<image>
<width>20</width>
<height>10</height>
</image>
<clip>
<near>0.01</near>
<far>500</far>
</clip>
</camera>
<always_on>1</always_on>
<update_rate>20</update_rate>
<visualize>true</visualize>
</sensor>
I'm not all that experienced with Gazebo, so advice appreciated on just where I start looking to fix this.