YARP
Yet Another Robot Platform
RGBDSensorClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_DEV_RGBDSENSORCLIENT_RGBDSENSORCLIENT_H
10 #define YARP_DEV_RGBDSENSORCLIENT_RGBDSENSORCLIENT_H
11 
12 
13 #include <yarp/os/Time.h>
14 #include <yarp/os/Network.h>
15 #include <yarp/os/BufferedPort.h>
16 
17 #include <yarp/dev/PolyDriver.h>
18 #include <yarp/dev/IRGBDSensor.h>
23 
24 #define DEFAULT_THREAD_PERIOD 20 //ms
25 #define RGBDSENSOR_TIMEOUT_DEFAULT 100 //ms
26 
27 
29 
30 
86 {
87 protected:
89 private:
90  yarp::dev::Implement_RgbVisualParams_Sender* RgbMsgSender{nullptr};
91  yarp::dev::Implement_DepthVisualParams_Sender* DepthMsgSender{nullptr};
92 protected:
97  std::string image_carrier_type;
98  std::string depth_carrier_type;
101 
102  // Use a single RPC port for now
103  std::string local_rpcPort_name;
104  std::string remote_rpcPort_name;
105 
106  /*
107  * In case the client has to connect to 2 different wrappers/server because the rgb
108  * and depth comes from two different sources.
109  *
110  * It should be possible to attach this guy to more than one port, try to see what
111  * will happen when receiving 2 calls at the same time (receive one calls while serving
112  * another one, it will result in concurrent thread most probably) and buffering issues.
113  *
114 
115  std::string local_colorFrame_rpcPort_Name;
116  std::string local_depthFrame_rpcPort_Name;
117  std::string remote_colorFrame_rpcPort_Name;
118  std::string remote_depthFrame_rpcPort_Name;
119 
120  yarp::os::Port colorFrame_rpcPort;
121  yarp::os::Port depthFrame_rpcPort;
122  */
123 
124  // Image data specs
125  std::string sensorId;
127  IRGBDSensor::RGBDSensor_status sensorStatus{IRGBDSensor::RGBD_SENSOR_NOT_READY};
128  int verbose{2};
129 
130  bool use_ROS{false}; // if false (default) read from YARP port, if true read from ROS topic instead (Both at the same time is not possible).
132  bool initialize_ROS(yarp::os::Searchable &config);
133 
136 
137 
138  // This is gonna be superseded by the synchronized when it'll be ready
140  bool fromConfig(yarp::os::Searchable &config);
141 
142 public:
148  ~RGBDSensorClient() override;
149 
150  int getRgbHeight() override;
151  int getRgbWidth() override;
153  bool getRgbResolution(int &width, int &height) override;
154  bool setRgbResolution(int width, int height) override;
155  bool getRgbFOV(double &horizontalFov, double &verticalFov) override;
156  bool setRgbFOV(double horizontalFov, double verticalFov) override;
157  bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override;
158  bool getRgbMirroring(bool& mirror) override;
159  bool setRgbMirroring(bool mirror) override;
160 
161  /*
162  * IDepthVisualParams interface. Look at IVisualParams.h for documentation
163  */
164  int getDepthHeight() override;
165  int getDepthWidth() override;
166  bool setDepthResolution(int width, int height) override;
167  bool getDepthFOV(double &horizontalFov, double &verticalFov) override;
168  bool setDepthFOV(double horizontalFov, double verticalFov) override;
169  double getDepthAccuracy() override;
170  bool setDepthAccuracy(double accuracy) override;
171  bool getDepthClipPlanes(double &near, double &far) override;
172  bool setDepthClipPlanes(double near, double far) override;
173  bool getDepthIntrinsicParam(yarp::os::Property &intrinsic) override;
174  bool getDepthMirroring(bool& mirror) override;
175  bool setDepthMirroring(bool mirror) override;
176 
177  // Device Driver interface //
191  bool open(yarp::os::Searchable& config) override;
192 
197  bool close() override;
198 
199  /*
200  * IRgbVisualParams interface. Look at IVisualParams.h for documentation
201  */
202 
203  /*
204  * IRGBDSensor specific interface methods
205  */
206 
213  bool getExtrinsicParam(yarp::sig::Matrix &extrinsic) override;
214 
221  IRGBDSensor::RGBDSensor_status getSensorStatus() override;
222 
228  std::string getLastErrorMsg(yarp::os::Stamp *timeStamp = NULL) override;
229 
242  bool getRgbImage(yarp::sig::FlexImage &rgbImage, yarp::os::Stamp *timeStamp = NULL) override;
243 
256  bool getDepthImage(yarp::sig::ImageOf<yarp::sig::PixelFloat> &depthImage, yarp::os::Stamp *timeStamp = NULL) override;
257 
270 
271 
272  // IFrame Grabber Control 2
273  //
274  // Implemented by FrameGrabberControls2_Sender
275  //
276  using FrameGrabberControls_Sender::getCameraDescription;
277  using FrameGrabberControls_Sender::hasFeature;
278  using FrameGrabberControls_Sender::setFeature;
279  using FrameGrabberControls_Sender::getFeature;
280  using FrameGrabberControls_Sender::hasOnOff;
281  using FrameGrabberControls_Sender::setActive;
282  using FrameGrabberControls_Sender::getActive;
283  using FrameGrabberControls_Sender::hasAuto;
284  using FrameGrabberControls_Sender::hasManual;
285  using FrameGrabberControls_Sender::hasOnePush;
286  using FrameGrabberControls_Sender::setMode;
287  using FrameGrabberControls_Sender::getMode;
288  using FrameGrabberControls_Sender::setOnePush;
289 };
290 
291 #endif // YARP_DEV_RGBDSENSORCLIENT_RGBDSENSORCLIENT_H
define common interfaces to discover remote camera capabilities
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
std::string remote_colorFrame_StreamingPort_name
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
int getDepthWidth() override
Return the height of each frame.
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool setDepthMirroring(bool mirror) override
Set the mirroring setting of the sensor.
yarp::dev::IRGBDSensor * sensor_p
bool getDepthClipPlanes(double &near, double &far) override
Get the clipping planes of the sensor.
std::string local_colorFrame_StreamingPort_name
bool getRgbImage(yarp::sig::FlexImage &rgbImage, yarp::os::Stamp *timeStamp=NULL) override
Get the rgb frame from the device.
RGBDSensorClient(RGBDSensorClient &&)=delete
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
IRGBDSensor::RGBDSensor_status sensorStatus
bool setDepthAccuracy(double accuracy) override
Set the minimum detectable variation in distance [meter] when possible.
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
int getRgbWidth() override
Return the width of each frame.
bool setDepthResolution(int width, int height) override
Set the resolution of the depth image from the camera.
bool getDepthIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the depth camera.
bool getDepthFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the depth camera.
bool initialize_YARP(yarp::os::Searchable &config)
bool setDepthClipPlanes(double near, double far) override
Set the clipping planes of the sensor.
bool getDepthMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
std::string remote_depthFrame_StreamingPort_name
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
std::string remote_rpcPort_name
~RGBDSensorClient() override
bool getDepthImage(yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthImage, yarp::os::Stamp *timeStamp=NULL) override
Get the depth frame from the device.
bool close() override
Close the DeviceDriver.
std::string local_rpcPort_name
double getDepthAccuracy() override
Get the minimum detectable variation in distance [meter].
RGBDSensorClient(const RGBDSensorClient &)=delete
bool getImages(yarp::sig::FlexImage &colorFrame, yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthFrame, yarp::os::Stamp *colorStamp=NULL, yarp::os::Stamp *depthStamp=NULL) override
Get the both the color and depth frame in a single call.
yarp::os::Port rpcPort
RGBDSensor_StreamingMsgParser * streamingReader
yarp::os::Stamp colorStamp
bool fromConfig(yarp::os::Searchable &config)
bool setDepthFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the depth camera.
bool initialize_ROS(yarp::os::Searchable &config)
bool getExtrinsicParam(yarp::sig::Matrix &extrinsic) override
Get the extrinsic parameters from the device.
int getDepthHeight() override
Return the height of each frame.
std::string getLastErrorMsg(yarp::os::Stamp *timeStamp=NULL) override
Return an error message in case of error.
yarp::os::BufferedPort< yarp::sig::FlexImage > colorFrame_StreamingPort
IRGBDSensor::RGBDSensor_status getSensorStatus() override
Get the surrent status of the sensor, using enum type.
std::string sensorId
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
RGBDSensorClient & operator=(const RGBDSensorClient &)=delete
bool open(yarp::os::Searchable &config) override
Create and configure a device, by name.
int getRgbHeight() override
Return the height of each frame.
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
RGBDSensorClient & operator=(RGBDSensorClient &&)=delete
std::string local_depthFrame_StreamingPort_name
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelFloat > > depthFrame_StreamingPort
std::string depth_carrier_type
std::string image_carrier_type
yarp::os::Stamp depthStamp
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
This classes implement a sender / parser for IFrameGrabberControls interface messages.
A generic interface for cameras that have both color camera as well as depth camera sensor,...
Definition: IRGBDSensor.h:56
A mini-server for network communication.
Definition: Port.h:50
A class for storing options and configuration information.
Definition: Property.h:37
A base class for nested structures that can be searched.
Definition: Searchable.h:69
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
Image class with user control of representation details.
Definition: Image.h:403
A class for a Matrix.
Definition: Matrix.h:46
constexpr char accuracy[]