26 if (!config.
check(
"depth_topic_name")) {
27 yCError(RGBD_ROS_TOPIC) <<
"missing depth_topic_name parameter, using default one";
30 std::string depth_topic_name = config.
find(
"depth_topic_name").
asString();
31 if(depth_topic_name[0] !=
'/'){
32 yCError(RGBD_ROS_TOPIC) <<
"depth_topic_name must begin with an initial /";
36 if (!config.
check(
"color_topic_name")) {
37 yCError(RGBD_ROS_TOPIC) <<
"missing color_topic_name parameter, using default one";
40 std::string color_topic_name = config.
find(
"color_topic_name").
asString();
41 if(color_topic_name[0] !=
'/'){
42 yCError(RGBD_ROS_TOPIC) <<
"color_topic_name must begin with an initial /";
45 std::string rgb_info_topic_name = color_topic_name.substr(0,color_topic_name.rfind(
'/')) +
"/camera_info";
46 std::string depth_info_topic_name = depth_topic_name.substr(0,depth_topic_name.rfind(
'/')) +
"/camera_info";
48 if (!config.
check(
"node_name")) {
49 yCError(RGBD_ROS_TOPIC) <<
"missing node_name parameter, using default one";
52 std::string node_name = config.
find(
"node_name").
asString();
53 if(node_name[0] !=
'/'){
54 yCError(RGBD_ROS_TOPIC) <<
"node_name must begin with an initial /";
63 m_rgb_input_processor->useCallback();
64 m_depth_input_processor->useCallback();
71 if (m_rgb_input_processor)
73 delete m_rgb_input_processor;
74 m_rgb_input_processor =
nullptr;
76 if (m_depth_input_processor)
78 delete m_depth_input_processor;
79 m_depth_input_processor =
nullptr;
91 if (m_rgb_input_processor==
nullptr)
95 return static_cast<int>(m_rgb_input_processor->getHeight());
100 if (m_rgb_input_processor==
nullptr)
104 return static_cast<int>(m_rgb_input_processor->getWidth());
110 yCWarning(RGBD_ROS_TOPIC) <<
"getRgbSupportedConfigurations not implemented yet";
116 if (m_rgb_input_processor ==
nullptr)
122 width =
static_cast<int>(m_rgb_input_processor->getWidth());
123 height =
static_cast<int>(m_rgb_input_processor->getHeight());
131 yCWarning(RGBD_ROS_TOPIC) <<
"setDepthResolution not supported";
139 yCWarning(RGBD_ROS_TOPIC) <<
"setRgbResolution not supported";
148 yCWarning(RGBD_ROS_TOPIC) <<
"setRgbFOV not supported";
156 yCWarning(RGBD_ROS_TOPIC) <<
"setDepthFOV not supported";
163 yCWarning(RGBD_ROS_TOPIC) <<
"setDepthAccuracy not supported";
169 if (m_rgb_input_processor ==
nullptr)
175 return m_rgb_input_processor->getFOV(horizontalFov, verticalFov);
181 yCWarning(RGBD_ROS_TOPIC) <<
"Mirroring not supported";
188 yCWarning(RGBD_ROS_TOPIC) <<
"Mirroring not supported";
194 if (m_rgb_input_processor ==
nullptr)
199 return m_rgb_input_processor->getIntrinsicParam(intrinsic);
204 if (m_depth_input_processor ==
nullptr)
208 return static_cast<int>(m_depth_input_processor->getHeight());
213 if (m_depth_input_processor ==
nullptr)
217 return static_cast<int>(m_depth_input_processor->getWidth());
222 if (m_depth_input_processor ==
nullptr)
228 return m_depth_input_processor->getFOV(horizontalFov, verticalFov);
233 if (m_depth_input_processor ==
nullptr)
238 return m_depth_input_processor->getIntrinsicParam(intrinsic);
243 yCWarning(RGBD_ROS_TOPIC) <<
"getDepthAccuracy not supported";
251 yCWarning(RGBD_ROS_TOPIC) <<
"getDepthClipPlanes not supported";
259 yCWarning(RGBD_ROS_TOPIC) <<
"setDepthClipPlanes not supported";
266 yCWarning(RGBD_ROS_TOPIC) <<
"getDepthMirroring not supported";
273 yCWarning(RGBD_ROS_TOPIC) <<
"setDepthMirroring not supported";
280 yCWarning(RGBD_ROS_TOPIC) <<
"getExtrinsicParam not supported";
286 std::lock_guard<std::mutex> guard(m_mutex);
288 if (m_rgb_input_processor!=
nullptr)
289 { rgb_ok = m_rgb_input_processor->getLastRGBData(rgbImage, *timeStamp); }
295 std::lock_guard<std::mutex> guard(m_mutex);
296 bool depth_ok =
false;
297 if (m_depth_input_processor !=
nullptr)
298 { depth_ok = m_depth_input_processor->getLastDepthData(
depthImage, *timeStamp); }
305 bool depth_ok =
false;
306 std::lock_guard<std::mutex> guard(m_mutex);
307 if (m_rgb_input_processor !=
nullptr)
308 { rgb_ok = m_rgb_input_processor->getLastRGBData(colorFrame, *colorStamp); }
309 if (m_depth_input_processor !=
nullptr)
310 { depth_ok = m_depth_input_processor->getLastDepthData(depthFrame, *depthStamp); }
311 return (rgb_ok && depth_ok);
316 return RGBD_SENSOR_OK_IN_USE;
bool getDepthFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the depth camera.
bool setDepthClipPlanes(double nearPlane, double farPlane) override
Set the clipping planes of the sensor.
bool getDepthMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
bool setDepthMirroring(bool mirror) override
Set the mirroring setting of the sensor.
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
int getDepthHeight() override
Return the height of each frame.
bool setDepthAccuracy(double accuracy) override
Set the minimum detectable variation in distance [meter] when possible.
bool getDepthIntrinsicParam(Property &intrinsic) override
Get the intrinsic parameters of the depth camera.
double getDepthAccuracy() override
Get the minimum detectable variation in distance [meter].
bool getRgbImage(FlexImage &rgbImage, Stamp *timeStamp=nullptr) override
Get the rgb frame from the device.
bool getDepthClipPlanes(double &nearPlane, double &farPlane) override
Get the clipping planes of the sensor.
bool getRgbIntrinsicParam(Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
bool getImages(FlexImage &colorFrame, depthImage &depthFrame, Stamp *colorStamp=nullptr, Stamp *depthStamp=nullptr) override
bool getExtrinsicParam(yarp::sig::Matrix &extrinsic) override
Get the extrinsic parameters from the device.
bool setDepthResolution(int width, int height) override
Set the resolution of the depth image from the camera.
int getRgbHeight() override
Return the height of each frame.
int getRgbWidth() override
Return the width of each frame.
int getDepthWidth() override
Return the height of each frame.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
RGBDSensor_status getSensorStatus() override
Get the surrent status of the sensor, using enum type.
bool setDepthFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the depth camera.
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
bool getDepthImage(depthImage &depthImage, Stamp *timeStamp=nullptr) override
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
std::string getLastErrorMsg(Stamp *timeStamp=nullptr) override
Return an error message in case of error.
bool close() override
Close the DeviceDriver.
A class for storing options and configuration information.
void clear()
Remove all associations.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
An abstraction for a time stamp and/or sequence number.
virtual std::string asString() const
Get string value.
Image class with user control of representation details.
#define yCError(component,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
An interface to the operating system, including Port based communication.