Gazebo | Ignition | Community
Ask Your Question

Data corruption from camera sensor

asked 2015-12-16 09:08:46 -0600

Nic Greenway gravatar image

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>

I'm not all that experienced with Gazebo, so advice appreciated on just where I start looking to fix this.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-12-17 12:50:57 -0600

Nic Greenway gravatar image

Fixed - the issue wasn't Gazebo at all, it was my treatment of the image, specifically using a stringstream to process it. Replacing that sorted everything out.

edit flag offensive delete link more

answered 2015-12-16 12:03:46 -0600

nkoenig gravatar image

You are probably accessing the camera data during a render update. You should use a sensor plugin like the camera plugin. The OnNewFrame function will give you the buffer you need.

edit flag offensive delete link more


Thanks for the advice: although it wasn't the cause of my problem, I have switched to using OnNewFrame anyway

Nic Greenway gravatar imageNic Greenway ( 2015-12-17 12:52:03 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-12-16 09:08:46 -0600

Seen: 274 times

Last updated: Dec 17 '15