Rendering error of camera sensor (partially gray image)

asked 2018-01-12 04:16:31 -0500

ScreenName gravatar image

updated 2018-01-15 04:50:02 -0500

I use a camera plugin to create an image for each iteration of a controller. However, quite often, rendering errors occur. This is how the image should look like (piece of wood lying on the ground [dark gray] with "sky" in the background [light gray]): image description

This is how the image looks sometimes: image description

And this is the predominant outcome of the rendering: image description

Edit: In all cases, the function returns True (successful).

It seems like the rendering starts at the top of the image and is interrupted at some point during the task. The shown images are have been created in one run without change of code (see below). Any ideas what might be the cause of this error?

Gazebo version is 7.0.0.

This is the code from the camera plugin:

class FlipBook : public ModelPlugin
{
private:
std::shared_ptr<gazebo::sensors::CameraSensor> camera;
ros::NodeHandle* rosnode_;
ros::Subscriber sub_;
physics::ModelPtr model;
public:
void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
{
  // Store the pointer to the model
  this->model = _parent;

    int argc = 0;
    char** argv = NULL;
    ros::init(argc, argv, "ModelPublisher", ros::init_options::NoSigintHandler | ros::init_options::AnonymousName);
    rosnode_ = new ros::NodeHandle("robot/");

    // Subscribe
    sub_ = rosnode_->subscribe("data", 100, &FlipBook::callback, this);

    gazebo::sensors::SensorManager *mgr = gazebo::sensors::SensorManager::Instance();
    this->camera=std::static_pointer_cast<gazebo::sensors::CameraSensor>(mgr->GetSensor("my_camera"));
}

void createImage(const std_msgs::Float64MultiArray::ConstPtr& data) {
    camera->SaveFrame (std::string("/home/user/catkin_ws/camera/temp.jpg"); // <---- This is used to create the images.
}
// Register this plugin with the simulator
GZ_REGISTER_MODEL_PLUGIN(ModelPush)
}
edit retag flag offensive close merge delete

Comments

hi, same issue here, did you find a solution ? I wonder if explicitly asking gazebo to wait for the function to end before continuing would help but I tried on another API call ( a looped spawnModel ) and I didn't suceed in doing it cleanly.

TTDM gravatar imageTTDM ( 2018-06-18 07:57:25 -0500 )edit

I found a solution but it's not as clean as I'd like it to be. Actually, it's pretty ugly: I noticed that automatic recording of images (according to http://gazebosim.org/tutorials?tut=camera_save) works without these rendering problems. So, I just let the camera save images into a specified folder and every time I need a rendering, I take the last one and delete the remaining.

ScreenName gravatar imageScreenName ( 2018-06-18 08:12:28 -0500 )edit