Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

World plugins run on gzserver, which is a different process from gzclient. So you won't be able to get a pointer to the user camera, which runs in the client.

You could add a camera sensor to the world and take the screenshot with that instead. And since that would live in sensor land, rather than physics land, I'd use something like this to get it:

auto camera = std::dynamic_pointer_cast<sensors::Camera>(
    sensors::SensorManager::Instance()->GetSensor(cameraName));

That's still 2 lines ;)

World plugins run on gzserver, which is a different process from gzclient. So you won't be able to get a pointer to the user camera, which runs in the client.

You could add a camera sensor to the world and take the screenshot with that instead. And since that would live in sensor land, rather than physics land, I'd use something like this to get it:

auto camera = std::dynamic_pointer_cast<sensors::Camera>(
std::dynamic_pointer_cast<sensors::CameraSensor>(
    sensors::SensorManager::Instance()->GetSensor(cameraName));

That's still 2 lines ;)