24#define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR 1
25#define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR 0
28RGBDSensorParser::RGBDSensorParser() :
36 iRGBDSensor = interface;
101 ret &= Property::copyPortable(params, params_b);
102 response.
append(params_b);
161 return DeviceResponder::respond(cmd,response);
176 isSubdeviceOwned(false),
177 subDeviceOwned(nullptr)
207 if(!initialize_YARP(config))
217 if(! openAndAttachSubDevice(config))
225 if (!openDeferredAttach(config)) {
235 if (!config.
check(
"period",
"refresh period of the broadcasted values in s"))
244 std::string rootName;
245 rootName = config.
check(
"name",
Value(
"/"),
"starting '/' if needed.").asString();
247 if (!config.
check(
"name",
"Prefix name of the ports opened by the RGBD wrapper.")) {
254 rpcPort_Name = rootName +
"/rpc:i";
255 colorFrame_StreamingPort_Name = rootName +
"/rgbImage:o";
256 depthFrame_StreamingPort_Name = rootName +
"/depthImage:o";
258 if(config.
check(
"subdevice")) {
259 isSubdeviceOwned=
true;
261 isSubdeviceOwned=
false;
267bool RgbdSensor_nws_yarp::openDeferredAttach(
Searchable& prop)
270 isSubdeviceOwned =
false;
274bool RgbdSensor_nws_yarp::openAndAttachSubDevice(
Searchable& prop)
280 p.setMonitor(prop.getMonitor(),
"subdevice");
286 subDeviceOwned->
open(p);
288 if (!subDeviceOwned->
isValid())
293 isSubdeviceOwned =
true;
294 if(!
attach(subDeviceOwned)) {
311 delete subDeviceOwned;
312 subDeviceOwned=
nullptr;
316 isSubdeviceOwned =
false;
326 colorFrame_StreamingPort.
close();
327 depthFrame_StreamingPort.
close();
339 if(!rpcPort.
open(rpcPort_Name))
346 if(!colorFrame_StreamingPort.
open(colorFrame_StreamingPort_Name))
351 if(!depthFrame_StreamingPort.
open(depthFrame_StreamingPort_Name))
371 if (isSubdeviceOwned) {
383 poly->
view(sensor_p);
387 if(sensor_p ==
nullptr)
399 if(fgCtrl !=
nullptr)
411 PeriodicThread::setPeriod(period);
412 return PeriodicThread::start();
428bool RgbdSensor_nws_yarp::setCamInfo(
const std::string& frame_id,
const UInt& seq,
const SensorType& sensorType)
442 std::string distModel, currentSensor;
445 std::vector<param<double> > parVector;
449 currentSensor = sensorType == COLOR_SENSOR ?
"Rgb" :
"Depth";
458 if(!camData.
check(
"distortionModel"))
465 if (distModel !=
"plumb_bob")
474 parVector.emplace_back(phyF,
"physFocalLength");
475 parVector.emplace_back(fx,
"focalLengthX");
476 parVector.emplace_back(fy,
"focalLengthY");
477 parVector.emplace_back(cx,
"principalPointX");
478 parVector.emplace_back(cy,
"principalPointY");
479 parVector.emplace_back(k1,
"k1");
480 parVector.emplace_back(k2,
"k2");
481 parVector.emplace_back(t1,
"t1");
482 parVector.emplace_back(t2,
"t2");
483 parVector.emplace_back(k3,
"k3");
484 parVector.emplace_back(stamp,
"stamp");
485 for(i = 0; i < parVector.size(); i++)
489 if(!camData.
check(par->parname))
500bool RgbdSensor_nws_yarp::writeData()
514 bool rgb_data_ok =
true;
515 bool depth_data_ok =
true;
517 if (((colorStamp.
getTime() - oldColorStamp.
getTime()) > 0) ==
false)
522 else { oldColorStamp = colorStamp; }
524 if (((depthStamp.
getTime() - oldDepthStamp.
getTime()) > 0) ==
false)
529 else { oldDepthStamp = depthStamp; }
539 colorFrame_StreamingPort.
write();
547 depthFrame_StreamingPort.
write();
555 if (sensor_p!=
nullptr)
559 switch (sensorStatus)
561 case(IRGBDSensor::RGBD_SENSOR_OK_IN_USE) :
569 case(IRGBDSensor::RGBD_SENSOR_NOT_READY):
constexpr yarp::conf::vocab32_t VOCAB_DEPTH_VISUAL_PARAMS
constexpr yarp::conf::vocab32_t VOCAB_RGBD_SENSOR
constexpr yarp::conf::vocab32_t VOCAB_RGB_VISUAL_PARAMS
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_FRAMEGRABBER_CONTROL
constexpr yarp::conf::vocab32_t VOCAB_ERROR_MSG
constexpr yarp::conf::vocab32_t VOCAB_IS
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_FAILED
constexpr yarp::conf::vocab32_t VOCAB_SET
constexpr double DEFAULT_THREAD_PERIOD
#define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR
const yarp::os::LogComponent & RGBDSENSORNWSYARP()
#define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR
bool configure(yarp::dev::IRGBDSensor *interface)
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
void run() override
Loop function.
bool threadInit() override
Initialization method.
bool detach() override
WrapperSingle interface.
bool fromConfig(yarp::os::Searchable ¶ms)
bool close() override
Close the DeviceDriver.
~RgbdSensor_nws_yarp() override
bool open(yarp::os::Searchable ¶ms) override
Device driver interface.
void threadRelease() override
Release method.
bool attach(yarp::dev::PolyDriver *poly) override
Specify which sensor this thread has to read from.
bool view(T *&x)
Get an interface to the device driver.
An interface for retrieving intrinsic parameter from a depth camera.
Control interface for frame grabber devices.
A generic interface for cameras that have both color camera as well as depth camera sensor,...
virtual std::string getLastErrorMsg(yarp::os::Stamp *timeStamp=nullptr)=0
Return an error message in case of error.
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override=0
Get the intrinsic parameters of the rgb camera.
virtual bool getExtrinsicParam(yarp::sig::Matrix &extrinsic)=0
Get the extrinsic parameters from the device.
virtual bool getImages(yarp::sig::FlexImage &colorFrame, yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthFrame, yarp::os::Stamp *colorStamp=nullptr, yarp::os::Stamp *depthStamp=nullptr)=0
Get the both the color and depth frame in a single call.
virtual RGBDSensor_status getSensorStatus()=0
Get the surrent status of the sensor, using enum type.
bool getDepthIntrinsicParam(yarp::os::Property &intrinsic) override=0
Get the intrinsic parameters of the depth camera.
An interface for retrieving intrinsic parameter from a rgb camera.
A container for a device driver.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
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.
void append(const Bottle &alt)
Append the content of the given bottle to the current list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
void close() override
Stop port activity.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
An abstraction for a periodic thread.
bool isRunning() const
Returns true when the thread is started, false otherwise.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
void setReader(PortReader &reader) override
Set an external reader for port data.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
A base class for nested structures that can be searched.
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 Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
An abstraction for a time stamp and/or sequence number.
double getTime() const
Get the time stamp.
A single value (typically within a Bottle).
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual std::string asString() const
Get string value.
bool configure(yarp::dev::IDepthVisualParams *interface)
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
bool configure(yarp::dev::IFrameGrabberControls *interface)
bool configure(yarp::dev::IRgbVisualParams *interface)
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
Image class with user control of representation details.
void setQuantum(size_t imgQuantum)
void setPixelCode(int imgPixelCode)
void setQuantum(size_t imgQuantum)
size_t width() const
Gets width of image in pixels.
void setExternal(const void *data, size_t imgWidth, size_t imgHeight)
Use this to wrap an external image.
unsigned char * getRawImage() const
Access to the internal image buffer.
size_t getQuantum() const
The size of a row is constrained to be a multiple of the "quantum".
size_t height() const
Gets height of image in pixels.
virtual int getPixelCode() const
Gets pixel type identifier.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
An interface to the operating system, including Port based communication.