|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
20 #define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR 1
21 #define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR 0
38 delete DepthMsgSender;
39 delete streamingReader;
48 if(!fromConfig(config))
54 sensorId=
"RGBDSensorClient for " + local_depthFrame_StreamingPort_name;
56 if(!initialize_YARP(config) )
70 if (!config.
check(
"localImagePort",
"full name of the port for streaming color image"))
72 yCError(
RGBDSENSORCLIENT) <<
"Missing 'localImagePort' parameter. Check you configuration file; it must be like:";
77 local_colorFrame_StreamingPort_name = config.
find(
"localImagePort").
asString();
79 if (!config.
check(
"localDepthPort",
"full name of the port for streaming depth image"))
81 yCError(
RGBDSENSORCLIENT) <<
"Missing 'localDepthPort' parameter. Check you configuration file; it must be like:";
86 local_depthFrame_StreamingPort_name = config.
find(
"localDepthPort").
asString();
89 if (!config.
check(
"remoteImagePort",
"full name of the port for streaming color image"))
91 yCError(
RGBDSENSORCLIENT) <<
"Missing 'remoteImagePort' parameter. Check you configuration file; it must be like:";
92 yCError(
RGBDSENSORCLIENT) <<
" remoteImagePort: Full name of the port to read color images from, e.g. /robotName/image_camera";
96 remote_colorFrame_StreamingPort_name = config.
find(
"remoteImagePort").
asString();
98 if (!config.
check(
"remoteDepthPort",
"full name of the port for streaming depth image"))
100 yCError(
RGBDSENSORCLIENT) <<
"Missing 'remoteDepthPort' parameter. Check you configuration file; it must be like:";
101 yCError(
RGBDSENSORCLIENT) <<
" remoteDepthPort: Full name of the port to read depth images from, e.g. /robotName/depth_camera ";
105 remote_depthFrame_StreamingPort_name = config.
find(
"remoteDepthPort").
asString();
108 if (!config.
check(
"localRpcPort",
"full name of the port for streaming depth image"))
110 yCError(
RGBDSENSORCLIENT) <<
"Missing 'localRpcPort' parameter. Check you configuration file; it must be like:";
115 local_rpcPort_name = config.
find(
"localRpcPort").
asString();
117 if (!config.
check(
"remoteRpcPort",
"full name of the port for streaming depth image"))
119 yCError(
RGBDSENSORCLIENT) <<
"Missing 'remoteRpcPort' parameter. Check you configuration file; it must be like:";
124 remote_rpcPort_name = config.
find(
"remoteRpcPort").
asString();
126 image_carrier_type =
"udp";
127 depth_carrier_type =
"udp";
129 if (config.
check(
"ImageCarrier",
"carrier for the image stream"))
131 image_carrier_type = config.
find(
"ImageCarrier").
asString();
134 if (config.
check(
"DepthCarrier",
"carrier for the depth tream"))
136 depth_carrier_type = config.
find(
"DepthCarrier").
asString();
157 ret = colorFrame_StreamingPort.open(local_colorFrame_StreamingPort_name);
158 ret &= depthFrame_StreamingPort.open(local_depthFrame_StreamingPort_name);
163 colorFrame_StreamingPort.close();
164 depthFrame_StreamingPort.close();
167 if(!
yarp::os::Network::connect(remote_colorFrame_StreamingPort_name, colorFrame_StreamingPort.getName(), image_carrier_type) )
169 yCError(
RGBDSENSORCLIENT) << colorFrame_StreamingPort.getName() <<
" cannot connect to remote port " << remote_colorFrame_StreamingPort_name <<
"with carrier " << image_carrier_type;
173 if(!
yarp::os::Network::connect(remote_depthFrame_StreamingPort_name, depthFrame_StreamingPort.getName(), depth_carrier_type) )
175 yCError(
RGBDSENSORCLIENT) << depthFrame_StreamingPort.getName() <<
" cannot connect to remote port " << remote_depthFrame_StreamingPort_name <<
"with carrier " << depth_carrier_type;
181 ret = rpcPort.open(local_rpcPort_name);
186 colorFrame_StreamingPort.close();
187 depthFrame_StreamingPort.close();
191 if(! rpcPort.addOutput(remote_rpcPort_name) )
194 colorFrame_StreamingPort.close();
195 depthFrame_StreamingPort.close();
206 rpcPort.write(cmd, response);
212 yCError(
RGBDSENSORCLIENT) <<
"Major protocol number does not match, please verify client and server are updated. \
248 streamingReader->attach(&colorFrame_StreamingPort, &depthFrame_StreamingPort);
255 colorFrame_StreamingPort.close();
256 depthFrame_StreamingPort.close();
285 rpcPort.write(cmd, response);
305 rpcPort.write(cmd, response);
317 rpcPort.write(cmd, response);
323 return streamingReader->readRgb(rgbImage, timeStamp);
328 return streamingReader->readDepth(
depthImage, timeStamp);
333 return streamingReader->read(rgbImage,
348 return RgbMsgSender->getRgbHeight();
353 return RgbMsgSender->getRgbWidth();
358 return RgbMsgSender->getRgbSupportedConfigurations(configurations);
363 return RgbMsgSender->getRgbResolution(width, height);
368 return RgbMsgSender->setRgbResolution(width, height);
373 return RgbMsgSender->getRgbFOV(horizontalFov, verticalFov);
378 return RgbMsgSender->getRgbFOV(horizontalFov, verticalFov);
383 return RgbMsgSender->getRgbIntrinsicParam(intrinsic);
388 return RgbMsgSender->getRgbMirroring(mirror);
393 return RgbMsgSender->setRgbMirroring(mirror);
401 return DepthMsgSender->getDepthHeight();
406 return DepthMsgSender->getDepthWidth();
411 return DepthMsgSender->setDepthResolution(width, height);
416 return DepthMsgSender->getDepthFOV(horizontalFov, verticalFov);
421 return DepthMsgSender->setDepthFOV(horizontalFov, verticalFov);
426 return DepthMsgSender->getDepthAccuracy();
431 return DepthMsgSender->setDepthAccuracy(accuracy);
436 return DepthMsgSender->getDepthClipPlanes(nearPlane, farPlane);
441 return DepthMsgSender->setDepthClipPlanes(nearPlane, farPlane);
446 return DepthMsgSender->getDepthIntrinsicParam(intrinsic);
451 return DepthMsgSender->getDepthMirroring(mirror);
456 return DepthMsgSender->setDepthMirroring(mirror);
A simple collection of objects that can be described and transmitted in a portable way.
virtual std::int32_t asVocab() const
Get vocabulary identifier as an integer.
This classes implement a sender / parser for IFrameGrabberControls interface messages.
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
A base class for nested structures that can be searched.
constexpr yarp::conf::vocab32_t VOCAB_RGBD_PROTOCOL_VERSION
#define yCWarning(component,...)
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
bool setDepthAccuracy(double accuracy) override
Set the minimum detectable variation in distance [meter] when possible.
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
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.
#define YARP_LOG_COMPONENT(name,...)
constexpr yarp::conf::vocab32_t VOCAB_STATUS
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_RGBD_SENSOR
int getDepthWidth() override
Return the height of each frame.
bool getRgbImage(yarp::sig::FlexImage &rgbImage, yarp::os::Stamp *timeStamp=nullptr) override
Get the rgb frame from the device.
An interface for the device drivers.
double getDepthAccuracy() override
Get the minimum detectable variation in distance [meter].
bool getDepthMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
constexpr yarp::conf::vocab32_t VOCAB_ERROR_MSG
bool initialize_YARP(yarp::os::Searchable &config)
~RGBDSensorClient() override
int getDepthHeight() override
Return the height of each frame.
bool getExtrinsicParam(yarp::sig::Matrix &extrinsic) override
Get the extrinsic parameters from the device.
IRGBDSensor::RGBDSensor_status getSensorStatus() override
Get the surrent status of the sensor, using enum type.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
bool fromConfig(yarp::os::Searchable &config)
Image class with user control of representation details.
bool setDepthClipPlanes(double near, double far) override
Set the clipping planes of the sensor.
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
virtual std::string asString() const
Get string value.
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.
bool close() override
Close the DeviceDriver.
constexpr yarp::conf::vocab32_t VOCAB_FAILED
int getRgbWidth() override
Return the width of each frame.
std::string getLastErrorMsg(yarp::os::Stamp *timeStamp=nullptr) override
Return an error message in case of error.
bool setDepthResolution(int width, int height) override
Set the resolution of the depth image from the camera.
const yarp::os::LogComponent & RGBDSENSORCLIENT()
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
#define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
bool open(yarp::os::Searchable &config) override
Create and configure a device, by name.
bool setDepthFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the depth camera.
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
bool setDepthMirroring(bool mirror) override
Set the mirroring setting of the sensor.
An abstraction for a time stamp and/or sequence number.
#define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR
#define yCError(component,...)
virtual std::int32_t asInt32() const
Get 32-bit integer value.
An interface to the operating system, including Port based communication.
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
bool getDepthIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the depth camera.
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
void zero()
Zero the matrix.
RGBDSensorClient: A Network client to receive data from kinect-like devices. This device will read fr...
int getRgbHeight() override
Return the height of each frame.
#define yCTrace(component,...)
bool getDepthClipPlanes(double &near, double &far) override
Get the clipping planes of the sensor.
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
bool getDepthImage(yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthImage, yarp::os::Stamp *timeStamp=nullptr) override
Get the depth frame from the device.
constexpr yarp::conf::vocab32_t VOCAB_EXTRINSIC_PARAM
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool getDepthFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the depth camera.
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
A class for storing options and configuration information.