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 
13 
14 #include <yarp/os/Time.h>
15 #include <yarp/os/Network.h>
16 #include <yarp/os/BufferedPort.h>
17 
18 #include <yarp/dev/PolyDriver.h>
19 #include <yarp/dev/IRGBDSensor.h>
24 
25 #define DEFAULT_THREAD_PERIOD 20 //ms
26 #define RGBDSENSOR_TIMEOUT_DEFAULT 100 //ms
27 
28 
30 
31 
88 {
89 protected:
91 private:
92  yarp::dev::Implement_RgbVisualParams_Sender* RgbMsgSender{nullptr};
93  yarp::dev::Implement_DepthVisualParams_Sender* DepthMsgSender{nullptr};
94 protected:
99  std::string image_carrier_type;
100  std::string depth_carrier_type;
101 
104 
105  // Use a single RPC port for now
106  std::string local_rpcPort_name;
107  std::string remote_rpcPort_name;
108 
109  /*
110  * In case the client has to connect to 2 different wrappers/server because the rgb
111  * and depth comes from two different sources.
112  *
113  * It should be possible to attach this guy to more than one port, try to see what
114  * will happen when receiving 2 calls at the same time (receive one calls while serving
115  * another one, it will result in concurrent thread most probably) and buffering issues.
116  *
117 
118  std::string local_colorFrame_rpcPort_Name;
119  std::string local_depthFrame_rpcPort_Name;
120  std::string remote_colorFrame_rpcPort_Name;
121  std::string remote_depthFrame_rpcPort_Name;
122 
123  yarp::os::Port colorFrame_rpcPort;
124  yarp::os::Port depthFrame_rpcPort;
125  */
126 
127  // Image data specs
128  std::string sensorId;
130  IRGBDSensor::RGBDSensor_status sensorStatus{IRGBDSensor::RGBD_SENSOR_NOT_READY};
131  int verbose{2};
132 
134 
137 
138 
139  // This is gonna be superseded by the synchronized when it'll be ready
141  bool fromConfig(yarp::os::Searchable &config);
142 
143 public:
149  ~RGBDSensorClient() override;
150 
151  int getRgbHeight() override;
152  int getRgbWidth() override;
154  bool getRgbResolution(int &width, int &height) override;
155  bool setRgbResolution(int width, int height) override;
156  bool getRgbFOV(double &horizontalFov, double &verticalFov) override;
157  bool setRgbFOV(double horizontalFov, double verticalFov) override;
158  bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override;
159  bool getRgbMirroring(bool& mirror) override;
160  bool setRgbMirroring(bool mirror) override;
161 
162  /*
163  * IDepthVisualParams interface. Look at IVisualParams.h for documentation
164  */
165  int getDepthHeight() override;
166  int getDepthWidth() override;
167  bool setDepthResolution(int width, int height) override;
168  bool getDepthFOV(double &horizontalFov, double &verticalFov) override;
169  bool setDepthFOV(double horizontalFov, double verticalFov) override;
170  double getDepthAccuracy() override;
171  bool setDepthAccuracy(double accuracy) override;
172  bool getDepthClipPlanes(double &near, double &far) override;
173  bool setDepthClipPlanes(double near, double far) override;
174  bool getDepthIntrinsicParam(yarp::os::Property &intrinsic) override;
175  bool getDepthMirroring(bool& mirror) override;
176  bool setDepthMirroring(bool mirror) override;
177 
178  // Device Driver interface //
192  bool open(yarp::os::Searchable& config) override;
193 
198  bool close() override;
199 
200  /*
201  * IRgbVisualParams interface. Look at IVisualParams.h for documentation
202  */
203 
204  /*
205  * IRGBDSensor specific interface methods
206  */
207 
214  bool getExtrinsicParam(yarp::sig::Matrix &extrinsic) override;
215 
222  IRGBDSensor::RGBDSensor_status getSensorStatus() override;
223 
229  std::string getLastErrorMsg(yarp::os::Stamp *timeStamp = nullptr) override;
230 
243  bool getRgbImage(yarp::sig::FlexImage &rgbImage, yarp::os::Stamp *timeStamp = nullptr) override;
244 
258 
271 
272 
273  // IFrame Grabber Control 2
274  //
275  // Implemented by FrameGrabberControls2_Sender
276  //
277  using FrameGrabberControls_Sender::getCameraDescription;
278  using FrameGrabberControls_Sender::hasFeature;
279  using FrameGrabberControls_Sender::setFeature;
280  using FrameGrabberControls_Sender::getFeature;
281  using FrameGrabberControls_Sender::hasOnOff;
282  using FrameGrabberControls_Sender::setActive;
283  using FrameGrabberControls_Sender::getActive;
284  using FrameGrabberControls_Sender::hasAuto;
285  using FrameGrabberControls_Sender::hasManual;
286  using FrameGrabberControls_Sender::hasOnePush;
287  using FrameGrabberControls_Sender::setMode;
288  using FrameGrabberControls_Sender::getMode;
289  using FrameGrabberControls_Sender::setOnePush;
290 };
291 
292 #endif // YARP_DEV_RGBDSENSORCLIENT_RGBDSENSORCLIENT_H
yarp::dev::FrameGrabberControls_Sender
This classes implement a sender / parser for IFrameGrabberControls interface messages.
Definition: FrameGrabberControlImpl.h:33
Network.h
RGBDSensorClient::setRgbFOV
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
Definition: RGBDSensorClient.cpp:376
RGBDSensorClient::RGBDSensorClient
RGBDSensorClient(const RGBDSensorClient &)=delete
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
RGBDSensorClient::remote_depthFrame_StreamingPort_name
std::string remote_depthFrame_StreamingPort_name
Definition: RGBDSensorClient.h:98
RGBDSensorClient::getRgbIntrinsicParam
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
Definition: RGBDSensorClient.cpp:381
RGBDSensorClient::remote_colorFrame_StreamingPort_name
std::string remote_colorFrame_StreamingPort_name
Definition: RGBDSensorClient.h:97
RGBDSensorClient::streamingReader
RGBDSensor_StreamingMsgParser * streamingReader
Definition: RGBDSensorClient.h:140
RGBDSensorClient::setDepthAccuracy
bool setDepthAccuracy(double accuracy) override
Set the minimum detectable variation in distance [meter] when possible.
Definition: RGBDSensorClient.cpp:429
RGBDSensorClient::setRgbResolution
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
Definition: RGBDSensorClient.cpp:366
RGBDSensorClient::getImages
bool getImages(yarp::sig::FlexImage &colorFrame, yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthFrame, yarp::os::Stamp *colorStamp=nullptr, yarp::os::Stamp *depthStamp=nullptr) override
Get the both the color and depth frame in a single call.
Definition: RGBDSensorClient.cpp:331
RGBDSensorClient::remote_rpcPort_name
std::string remote_rpcPort_name
Definition: RGBDSensorClient.h:107
IPreciselyTimed.h
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
FloatImageBufferedPort
Definition: RGBDSensorClient_StreamingMsgParser.h:44
yarp::dev::Implement_DepthVisualParams_Sender
Definition: IVisualParamsImpl.h:71
RGBDSensorClient::getDepthWidth
int getDepthWidth() override
Return the height of each frame.
Definition: RGBDSensorClient.cpp:404
RGBDSensorClient::getRgbImage
bool getRgbImage(yarp::sig::FlexImage &rgbImage, yarp::os::Stamp *timeStamp=nullptr) override
Get the rgb frame from the device.
Definition: RGBDSensorClient.cpp:321
FrameGrabberControlImpl.h
RGBDSensorClient::getDepthAccuracy
double getDepthAccuracy() override
Get the minimum detectable variation in distance [meter].
Definition: RGBDSensorClient.cpp:424
RGBDSensorClient::RGBDSensorClient
RGBDSensorClient(RGBDSensorClient &&)=delete
RGBDSensorClient::getDepthMirroring
bool getDepthMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
Definition: RGBDSensorClient.cpp:449
yarp::sig::ImageOf< yarp::sig::PixelFloat >
RGBDSensorClient::initialize_YARP
bool initialize_YARP(yarp::os::Searchable &config)
Definition: RGBDSensorClient.cpp:152
RGBDSensorClient::~RGBDSensorClient
~RGBDSensorClient() override
Definition: RGBDSensorClient.cpp:34
yarp::sig::VectorOf< yarp::dev::CameraConfig >
yarp::os::Port
A mini-server for network communication.
Definition: Port.h:50
RGBDSensor_StreamingMsgParser
Definition: RGBDSensorClient_StreamingMsgParser.h:62
RGBDSensorClient::operator=
RGBDSensorClient & operator=(const RGBDSensorClient &)=delete
RGBDSensorClient_StreamingMsgParser.h
yarp::dev::Implement_RgbVisualParams_Sender
Definition: IVisualParamsImpl.h:32
RGBDSensorClient::getDepthHeight
int getDepthHeight() override
Return the height of each frame.
Definition: RGBDSensorClient.cpp:399
RGBDSensorClient::getExtrinsicParam
bool getExtrinsicParam(yarp::sig::Matrix &extrinsic) override
Get the extrinsic parameters from the device.
Definition: RGBDSensorClient.cpp:278
RGBDSensorClient::RGBDSensorClient
RGBDSensorClient()
Definition: RGBDSensorClient.cpp:26
IVisualParamsImpl.h
RGBDSensorClient::getSensorStatus
IRGBDSensor::RGBDSensor_status getSensorStatus() override
Get the surrent status of the sensor, using enum type.
Definition: RGBDSensorClient.cpp:298
RgbImageBufferedPort
Definition: RGBDSensorClient_StreamingMsgParser.h:25
PolyDriver.h
RGBDSensorClient::fromConfig
bool fromConfig(yarp::os::Searchable &config)
Definition: RGBDSensorClient.cpp:66
RGBDSensorClient::local_depthFrame_StreamingPort_name
std::string local_depthFrame_StreamingPort_name
Definition: RGBDSensorClient.h:96
yarp::sig::FlexImage
Image class with user control of representation details.
Definition: Image.h:403
RGBDSensorClient::local_colorFrame_StreamingPort_name
std::string local_colorFrame_StreamingPort_name
Definition: RGBDSensorClient.h:95
RGBDSensorClient::setDepthClipPlanes
bool setDepthClipPlanes(double near, double far) override
Set the clipping planes of the sensor.
Definition: RGBDSensorClient.cpp:439
RGBDSensorClient::close
bool close() override
Close the DeviceDriver.
Definition: RGBDSensorClient.cpp:253
RGBDSensorClient::getRgbWidth
int getRgbWidth() override
Return the width of each frame.
Definition: RGBDSensorClient.cpp:351
RGBDSensorClient::getLastErrorMsg
std::string getLastErrorMsg(yarp::os::Stamp *timeStamp=nullptr) override
Return an error message in case of error.
Definition: RGBDSensorClient.cpp:310
RGBDSensorClient::setDepthResolution
bool setDepthResolution(int width, int height) override
Set the resolution of the depth image from the camera.
Definition: RGBDSensorClient.cpp:409
RGBDSensorClient::operator=
RGBDSensorClient & operator=(RGBDSensorClient &&)=delete
yarp::dev::IRGBDSensor
A generic interface for cameras that have both color camera as well as depth camera sensor,...
Definition: IRGBDSensor.h:56
RGBDSensorClient::open
bool open(yarp::os::Searchable &config) override
Create and configure a device, by name.
Definition: RGBDSensorClient.cpp:42
RGBDSensorClient::setDepthFOV
bool setDepthFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the depth camera.
Definition: RGBDSensorClient.cpp:419
BufferedPort.h
RGBDSensorClient::depth_carrier_type
std::string depth_carrier_type
Definition: RGBDSensorClient.h:100
RGBDSensorClient::setDepthMirroring
bool setDepthMirroring(bool mirror) override
Set the mirroring setting of the sensor.
Definition: RGBDSensorClient.cpp:454
RGBDSensorClient::sensorId
std::string sensorId
Definition: RGBDSensorClient.h:128
RGBDSensorClient::image_carrier_type
std::string image_carrier_type
Definition: RGBDSensorClient.h:99
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
IRGBDSensor.h
RGBDSensorClient::colorStamp
yarp::os::Stamp colorStamp
Definition: RGBDSensorClient.h:135
RGBDSensorClient::sensorStatus
IRGBDSensor::RGBDSensor_status sensorStatus
Definition: RGBDSensorClient.h:130
RGBDSensorClient::depthStamp
yarp::os::Stamp depthStamp
Definition: RGBDSensorClient.h:136
RGBDSensorClient::getRgbResolution
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
Definition: RGBDSensorClient.cpp:361
RGBDSensorClient::getDepthIntrinsicParam
bool getDepthIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the depth camera.
Definition: RGBDSensorClient.cpp:444
RGBDSensorClient::getRgbSupportedConfigurations
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
Definition: RGBDSensorClient.cpp:356
RGBDSensorClient
RGBDSensorClient: A Network client to receive data from kinect-like devices. This device will read fr...
Definition: RGBDSensorClient.h:88
RGBDSensorClient::depthFrame_StreamingPort
FloatImageBufferedPort depthFrame_StreamingPort
Definition: RGBDSensorClient.h:103
Time.h
RGBDSensorClient::local_rpcPort_name
std::string local_rpcPort_name
Definition: RGBDSensorClient.h:106
RGBDSensorClient::getRgbHeight
int getRgbHeight() override
Return the height of each frame.
Definition: RGBDSensorClient.cpp:346
RGBDSensorClient::verbose
int verbose
Definition: RGBDSensorClient.h:131
RGBDSensorClient::getDepthClipPlanes
bool getDepthClipPlanes(double &near, double &far) override
Get the clipping planes of the sensor.
Definition: RGBDSensorClient.cpp:434
RGBDSensorClient::getRgbFOV
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
Definition: RGBDSensorClient.cpp:371
RGBDSensorClient::getDepthImage
bool getDepthImage(yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthImage, yarp::os::Stamp *timeStamp=nullptr) override
Get the depth frame from the device.
Definition: RGBDSensorClient.cpp:326
RGBDSensorClient::rpcPort
yarp::os::Port rpcPort
Definition: RGBDSensorClient.h:90
FrameGrabberControl2.h
define common interfaces to discover remote camera capabilities
RGBDSensorClient::colorFrame_StreamingPort
RgbImageBufferedPort colorFrame_StreamingPort
Definition: RGBDSensorClient.h:102
RGBDSensorClient::getRgbMirroring
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
Definition: RGBDSensorClient.cpp:386
RGBDSensorClient::getDepthFOV
bool getDepthFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the depth camera.
Definition: RGBDSensorClient.cpp:414
RGBDSensorClient::sensor_p
yarp::dev::IRGBDSensor * sensor_p
Definition: RGBDSensorClient.h:129
RGBDSensorClient::setRgbMirroring
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
Definition: RGBDSensorClient.cpp:391
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::sig::Matrix
A class for a Matrix.
Definition: Matrix.h:46