Skip to content

Commit

Permalink
multicamera: Cleanup use of removeDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
traversaro committed Mar 31, 2022
1 parent e9a8a30 commit f3f0fc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugins/multicamera/include/gazebo/MultiCamera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ namespace gazebo
sensors::MultiCameraSensor *m_sensor;

yarp::dev::IFrameGrabberImage* iFrameGrabberImage;
bool m_deviceRegistered;
std::string m_scopedDeviceName;
};
}

Expand Down
7 changes: 6 additions & 1 deletion plugins/multicamera/src/MultiCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ using GazeboYarpPlugins::GAZEBOMULTICAMERA;
namespace gazebo {

GazeboYarpMultiCamera::GazeboYarpMultiCamera() :
MultiCameraPlugin()
MultiCameraPlugin(), m_deviceRegistered(false)
{
}

GazeboYarpMultiCamera::~GazeboYarpMultiCamera()
{
if (m_deviceRegistered) {
GazeboYarpPlugins::Handler::getHandler()->removeDevice(m_scopedDeviceName);
m_deviceRegistered = false;
}
this->m_cameraDriver.close();
GazeboYarpPlugins::Handler::getHandler()->removeSensor(this->m_sensorName);
}
Expand Down Expand Up @@ -110,6 +114,7 @@ void GazeboYarpMultiCamera::Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sd
yCError(GAZEBOMULTICAMERA)<<"GazeboYarpMultiCamera: failed setting scopedDeviceName(=" << scopedDeviceName << ")";
return;
}
m_deviceRegistered = true;
yCInfo(GAZEBOMULTICAMERA) << "GazeboYarpMultiCamera: Register YARP device with instance name:" << scopedDeviceName;
}

Expand Down

0 comments on commit f3f0fc4

Please sign in to comment.