20 #define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR 1
21 #define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR 0
38 delete DepthMsgSender;
39 delete streamingReader;
47 if(!fromConfig(config))
53 sensorId=
"RGBDSensorClient for " + local_depthFrame_StreamingPort_name;
55 if(!initialize_YARP(config) )
61 if(!initialize_ROS(config) )
76 yCInfo(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: ROS configuration parameters are not set, skipping ROS topic initialization.";
90 if (!config.
check(
"localImagePort",
"full name of the port for streaming color image"))
92 yCError(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: missing 'localImagePort' parameter. Check you configuration file; it must be like:";
98 local_colorFrame_StreamingPort_name = config.
find(
"localImagePort").
asString();
101 if (!config.
check(
"localDepthPort",
"full name of the port for streaming depth image"))
103 yCError(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: missing 'localDepthPort' parameter. Check you configuration file; it must be like:";
109 local_depthFrame_StreamingPort_name = config.
find(
"localDepthPort").
asString();
113 if (!config.
check(
"remoteImagePort",
"full name of the port for streaming color image"))
115 yCError(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: missing 'remoteImagePort' parameter. Check you configuration file; it must be like:";
116 yCError(
RGBDSENSORCLIENT) <<
" remoteImagePort: Full name of the port to read color images from, e.g. /robotName/image_camera";
121 remote_colorFrame_StreamingPort_name = config.
find(
"remoteImagePort").
asString();
124 if (!config.
check(
"remoteDepthPort",
"full name of the port for streaming depth image"))
126 yCError(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: missing 'remoteDepthPort' parameter. Check you configuration file; it must be like:";
127 yCError(
RGBDSENSORCLIENT) <<
" remoteDepthPort: Full name of the port to read depth images from, e.g. /robotName/depth_camera ";
132 remote_depthFrame_StreamingPort_name = config.
find(
"remoteDepthPort").
asString();
136 if (!config.
check(
"localRpcPort",
"full name of the port for streaming depth image"))
138 yCError(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: missing 'localRpcPort' parameter. Check you configuration file; it must be like:";
144 local_rpcPort_name = config.
find(
"localRpcPort").
asString();
147 if (!config.
check(
"remoteRpcPort",
"full name of the port for streaming depth image"))
149 yCError(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: missing 'remoteRpcPort' parameter. Check you configuration file; it must be like:";
155 remote_rpcPort_name = config.
find(
"remoteRpcPort").
asString();
158 image_carrier_type =
"udp";
159 depth_carrier_type =
"udp";
161 if (config.
check(
"ImageCarrier",
"carrier for the image stream"))
163 image_carrier_type = config.
find(
"ImageCarrier").
asString();
166 if (config.
check(
"DepthCarrier",
"carrier for the depth tream"))
168 depth_carrier_type = config.
find(
"DepthCarrier").
asString();
183 if(!ROS_parameters.
isNull())
186 yCInfo(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: found 'ROS' group in config file, parsing ROS specific parameters.";
192 yCInfo(
RGBDSENSORCLIENT) <<
"RGBDSensorClient: 'ROS' group was NOT found in config file, skipping ROS specific parameters.";
203 ret = colorFrame_StreamingPort.open(local_colorFrame_StreamingPort_name);
204 ret &= depthFrame_StreamingPort.open(local_depthFrame_StreamingPort_name);
209 colorFrame_StreamingPort.close();
210 depthFrame_StreamingPort.close();
213 if(!
yarp::os::Network::connect(remote_colorFrame_StreamingPort_name, colorFrame_StreamingPort.getName(), image_carrier_type) )
215 yCError(
RGBDSENSORCLIENT) << colorFrame_StreamingPort.getName() <<
" cannot connect to remote port " << remote_colorFrame_StreamingPort_name <<
"with carrier " << image_carrier_type;
219 if(!
yarp::os::Network::connect(remote_depthFrame_StreamingPort_name, depthFrame_StreamingPort.getName(), depth_carrier_type) )
221 yCError(
RGBDSENSORCLIENT) << depthFrame_StreamingPort.getName() <<
" cannot connect to remote port " << remote_depthFrame_StreamingPort_name <<
"with carrier " << depth_carrier_type;
227 ret = rpcPort.open(local_rpcPort_name);
232 colorFrame_StreamingPort.close();
233 depthFrame_StreamingPort.close();
237 if(! rpcPort.addOutput(remote_rpcPort_name) )
240 colorFrame_StreamingPort.close();
241 depthFrame_StreamingPort.close();
251 rpcPort.write(cmd, response);
257 yCError(
RGBDSENSORCLIENT) <<
"Major protocol number does not match, please verify client and server are updated. \
293 streamingReader->attach(&colorFrame_StreamingPort, &depthFrame_StreamingPort);
310 colorFrame_StreamingPort.close();
311 depthFrame_StreamingPort.close();
339 rpcPort.write(cmd, response);
358 rpcPort.write(cmd, response);
369 rpcPort.write(cmd, response);
377 return streamingReader->readRgb(rgbImage);
384 return streamingReader->readDepth(depthImage);
390 ret &= streamingReader->readRgb(rgbImage);
391 ret &= streamingReader->readDepth(depthImage);
410 return RgbMsgSender->getRgbHeight();
415 return RgbMsgSender->getRgbWidth();
419 return RgbMsgSender->getRgbSupportedConfigurations(configurations);
422 return RgbMsgSender->getRgbResolution(width, height);
427 return RgbMsgSender->setRgbResolution(width, height);
431 return RgbMsgSender->getRgbFOV(horizontalFov, verticalFov);
435 return RgbMsgSender->getRgbFOV(horizontalFov, verticalFov);
439 return RgbMsgSender->getRgbIntrinsicParam(intrinsic);
444 return RgbMsgSender->getRgbMirroring(mirror);
449 return RgbMsgSender->setRgbMirroring(mirror);
457 return DepthMsgSender->getDepthHeight();
461 return DepthMsgSender->getDepthWidth();
465 return DepthMsgSender->setDepthResolution(width, height);
469 return DepthMsgSender->getDepthFOV(horizontalFov, verticalFov);
473 return DepthMsgSender->setDepthFOV(horizontalFov, verticalFov);
477 return DepthMsgSender->getDepthAccuracy();
481 return DepthMsgSender->setDepthAccuracy(
accuracy);
485 return DepthMsgSender->getDepthClipPlanes(nearPlane, farPlane);
489 return DepthMsgSender->setDepthClipPlanes(nearPlane, farPlane);
493 return DepthMsgSender->getDepthIntrinsicParam(intrinsic);
498 return DepthMsgSender->getDepthMirroring(mirror);
503 return DepthMsgSender->setDepthMirroring(mirror);
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_FAILED
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
const yarp::os::LogComponent & RGBDSENSORCLIENT()
#define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR
#define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR
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.
bool getDepthClipPlanes(double &near, double &far) override
Get the clipping planes of the sensor.
bool getRgbImage(yarp::sig::FlexImage &rgbImage, yarp::os::Stamp *timeStamp=NULL) override
Get the rgb frame from the device.
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 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 getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
~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.
double getDepthAccuracy() override
Get the minimum detectable variation in distance [meter].
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.
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.
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.
This classes implement a sender / parser for IFrameGrabberControls interface messages.
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab(int 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.
bool isNull() const override
Checks if the object is invalid.
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.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
An abstraction for a time stamp and/or sequence number.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::int32_t asVocab() const
Get vocabulary identifier as an integer.
virtual std::string asString() const
Get string value.
Image class with user control of representation details.
void zero()
Zero the matrix.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.
constexpr char accuracy[]