17 #define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR 1
18 #define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR 0
24 yarp::proto::framegrabber::FrameGrabberControls_Forwarder(rpcPort),
25 RgbMsgSender(new
yarp::proto::framegrabber::RgbVisualParams_Forwarder(rpcPort)),
26 DepthMsgSender(new
yarp::proto::framegrabber::DepthVisualParams_Forwarder(rpcPort)),
35 delete DepthMsgSender;
36 delete streamingReader;
45 if(!fromConfig(config))
51 sensorId=
"RGBDSensorClient for " + local_depthFrame_StreamingPort_name;
53 if(!initialize_YARP(config) )
67 if (!config.
check(
"localImagePort",
"full name of the port for streaming color image"))
69 yCError(
RGBDSENSORCLIENT) <<
"Missing 'localImagePort' parameter. Check you configuration file; it must be like:";
74 local_colorFrame_StreamingPort_name = config.
find(
"localImagePort").
asString();
76 if (!config.
check(
"localDepthPort",
"full name of the port for streaming depth image"))
78 yCError(
RGBDSENSORCLIENT) <<
"Missing 'localDepthPort' parameter. Check you configuration file; it must be like:";
83 local_depthFrame_StreamingPort_name = config.
find(
"localDepthPort").
asString();
86 if (!config.
check(
"remoteImagePort",
"full name of the port for streaming color image"))
88 yCError(
RGBDSENSORCLIENT) <<
"Missing 'remoteImagePort' parameter. Check you configuration file; it must be like:";
89 yCError(
RGBDSENSORCLIENT) <<
" remoteImagePort: Full name of the port to read color images from, e.g. /robotName/image_camera";
93 remote_colorFrame_StreamingPort_name = config.
find(
"remoteImagePort").
asString();
95 if (!config.
check(
"remoteDepthPort",
"full name of the port for streaming depth image"))
97 yCError(
RGBDSENSORCLIENT) <<
"Missing 'remoteDepthPort' parameter. Check you configuration file; it must be like:";
98 yCError(
RGBDSENSORCLIENT) <<
" remoteDepthPort: Full name of the port to read depth images from, e.g. /robotName/depth_camera ";
102 remote_depthFrame_StreamingPort_name = config.
find(
"remoteDepthPort").
asString();
105 if (!config.
check(
"localRpcPort",
"full name of the port for streaming depth image"))
107 yCError(
RGBDSENSORCLIENT) <<
"Missing 'localRpcPort' parameter. Check you configuration file; it must be like:";
112 local_rpcPort_name = config.
find(
"localRpcPort").
asString();
114 if (!config.
check(
"remoteRpcPort",
"full name of the port for streaming depth image"))
116 yCError(
RGBDSENSORCLIENT) <<
"Missing 'remoteRpcPort' parameter. Check you configuration file; it must be like:";
121 remote_rpcPort_name = config.
find(
"remoteRpcPort").
asString();
123 image_carrier_type =
"udp";
124 depth_carrier_type =
"udp";
126 if (config.
check(
"ImageCarrier",
"carrier for the image stream"))
128 image_carrier_type = config.
find(
"ImageCarrier").
asString();
131 if (config.
check(
"DepthCarrier",
"carrier for the depth tream"))
133 depth_carrier_type = config.
find(
"DepthCarrier").
asString();
154 ret = colorFrame_StreamingPort.open(local_colorFrame_StreamingPort_name);
155 ret &= depthFrame_StreamingPort.open(local_depthFrame_StreamingPort_name);
160 colorFrame_StreamingPort.close();
161 depthFrame_StreamingPort.close();
164 if(!
yarp::os::Network::connect(remote_colorFrame_StreamingPort_name, colorFrame_StreamingPort.getName(), image_carrier_type) )
166 yCError(
RGBDSENSORCLIENT) << colorFrame_StreamingPort.getName() <<
" cannot connect to remote port " << remote_colorFrame_StreamingPort_name <<
"with carrier " << image_carrier_type;
170 if(!
yarp::os::Network::connect(remote_depthFrame_StreamingPort_name, depthFrame_StreamingPort.getName(), depth_carrier_type) )
172 yCError(
RGBDSENSORCLIENT) << depthFrame_StreamingPort.getName() <<
" cannot connect to remote port " << remote_depthFrame_StreamingPort_name <<
"with carrier " << depth_carrier_type;
178 ret = rpcPort.open(local_rpcPort_name);
183 colorFrame_StreamingPort.close();
184 depthFrame_StreamingPort.close();
188 if(! rpcPort.addOutput(remote_rpcPort_name) )
191 colorFrame_StreamingPort.close();
192 depthFrame_StreamingPort.close();
203 rpcPort.write(cmd, response);
209 yCError(
RGBDSENSORCLIENT) <<
"Major protocol number does not match, please verify client and server are updated. \
245 streamingReader->attach(&colorFrame_StreamingPort, &depthFrame_StreamingPort);
252 colorFrame_StreamingPort.close();
253 depthFrame_StreamingPort.close();
282 rpcPort.write(cmd, response);
302 rpcPort.write(cmd, response);
314 rpcPort.write(cmd, response);
320 return streamingReader->readRgb(rgbImage, timeStamp);
325 return streamingReader->readDepth(
depthImage, timeStamp);
330 return streamingReader->read(rgbImage,
345 return RgbMsgSender->getRgbHeight();
350 return RgbMsgSender->getRgbWidth();
355 return RgbMsgSender->getRgbSupportedConfigurations(configurations);
360 return RgbMsgSender->getRgbResolution(width, height);
365 return RgbMsgSender->setRgbResolution(width, height);
370 return RgbMsgSender->getRgbFOV(horizontalFov, verticalFov);
375 return RgbMsgSender->getRgbFOV(horizontalFov, verticalFov);
380 return RgbMsgSender->getRgbIntrinsicParam(intrinsic);
385 return RgbMsgSender->getRgbMirroring(mirror);
390 return RgbMsgSender->setRgbMirroring(mirror);
398 return DepthMsgSender->getDepthHeight();
403 return DepthMsgSender->getDepthWidth();
408 return DepthMsgSender->setDepthResolution(width, height);
413 return DepthMsgSender->getDepthFOV(horizontalFov, verticalFov);
418 return DepthMsgSender->setDepthFOV(horizontalFov, verticalFov);
423 return DepthMsgSender->getDepthAccuracy();
428 return DepthMsgSender->setDepthAccuracy(accuracy);
433 return DepthMsgSender->getDepthClipPlanes(nearPlane, farPlane);
438 return DepthMsgSender->setDepthClipPlanes(nearPlane, farPlane);
443 return DepthMsgSender->getDepthIntrinsicParam(intrinsic);
448 return DepthMsgSender->getDepthMirroring(mirror);
453 return DepthMsgSender->setDepthMirroring(mirror);
constexpr yarp::conf::vocab32_t VOCAB_RGBD_SENSOR
constexpr yarp::conf::vocab32_t VOCAB_EXTRINSIC_PARAM
constexpr yarp::conf::vocab32_t VOCAB_RGBD_PROTOCOL_VERSION
constexpr yarp::conf::vocab32_t VOCAB_STATUS
constexpr yarp::conf::vocab32_t VOCAB_ERROR_MSG
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_FAILED
const yarp::os::LogComponent & RGBDSENSORCLIENT()
#define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR
#define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR
RGBDSensorClient: A Network client to receive data from kinect-like devices. This device will read fr...
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
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.
std::string getLastErrorMsg(yarp::os::Stamp *timeStamp=nullptr) override
Return an error message in case of error.
bool getDepthClipPlanes(double &near, double &far) override
Get the clipping planes of the sensor.
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
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 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.
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.
bool getDepthImage(yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthImage, yarp::os::Stamp *timeStamp=nullptr) override
Get the depth frame from the device.
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
~RGBDSensorClient() override
bool close() override
Close the DeviceDriver.
double getDepthAccuracy() override
Get the minimum detectable variation in distance [meter].
bool getRgbImage(yarp::sig::FlexImage &rgbImage, yarp::os::Stamp *timeStamp=nullptr) override
Get the rgb frame from the device.
bool fromConfig(yarp::os::Searchable &config)
bool setDepthFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the depth camera.
bool getExtrinsicParam(yarp::sig::Matrix &extrinsic) override
Get the extrinsic parameters from the device.
int getDepthHeight() override
Return the height of each frame.
IRGBDSensor::RGBDSensor_status getSensorStatus() override
Get the surrent status of the sensor, using enum type.
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
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.
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
A class for storing options and configuration information.
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.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
An abstraction for a time stamp and/or sequence number.
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::string asString() const
Get string value.
Image class with user control of representation details.
void zero()
Zero the matrix.
#define yCError(component,...)
#define yCTrace(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.
The main, catch-all namespace for YARP.