24 #define RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR 1
25 #define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR 0
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 setId(
"RGBDSensorWrapper for " + depthFrame_StreamingPort_Name);
209 if(!initialize_YARP(config))
219 if(! openAndAttachSubDevice(config))
227 if (!openDeferredAttach(config)) {
237 if (!config.
check(
"period",
"refresh period of the broadcasted values in s"))
246 std::string rootName;
247 rootName = config.
check(
"name",
Value(
"/"),
"starting '/' if needed.").asString();
249 if (!config.
check(
"name",
"Prefix name of the ports opened by the RGBD wrapper.")) {
256 rpcPort_Name = rootName +
"/rpc:i";
257 colorFrame_StreamingPort_Name = rootName +
"/rgbImage:o";
258 depthFrame_StreamingPort_Name = rootName +
"/depthImage:o";
260 if(config.
check(
"subdevice")) {
261 isSubdeviceOwned=
true;
263 isSubdeviceOwned=
false;
269 bool RgbdSensor_nws_yarp::openDeferredAttach(
Searchable& prop)
272 isSubdeviceOwned =
false;
276 bool RgbdSensor_nws_yarp::openAndAttachSubDevice(
Searchable& prop)
282 p.setMonitor(prop.getMonitor(),
"subdevice");
288 subDeviceOwned->
open(p);
290 if (!subDeviceOwned->
isValid())
295 isSubdeviceOwned =
true;
296 if(!
attach(subDeviceOwned)) {
313 delete subDeviceOwned;
314 subDeviceOwned=
nullptr;
318 isSubdeviceOwned =
false;
328 colorFrame_StreamingPort.
close();
329 depthFrame_StreamingPort.
close();
341 if(!rpcPort.
open(rpcPort_Name))
348 if(!colorFrame_StreamingPort.
open(colorFrame_StreamingPort_Name))
353 if(!depthFrame_StreamingPort.
open(depthFrame_StreamingPort_Name))
383 if (isSubdeviceOwned) {
395 poly->
view(sensor_p);
399 if(sensor_p ==
nullptr)
411 if(fgCtrl !=
nullptr)
423 PeriodicThread::setPeriod(period);
424 return PeriodicThread::start();
440 bool RgbdSensor_nws_yarp::setCamInfo(
const std::string& frame_id,
const UInt& seq,
const SensorType& sensorType)
454 std::string distModel, currentSensor;
457 std::vector<param<double> > parVector;
461 currentSensor = sensorType == COLOR_SENSOR ?
"Rgb" :
"Depth";
470 if(!camData.
check(
"distortionModel"))
477 if (distModel !=
"plumb_bob")
486 parVector.emplace_back(phyF,
"physFocalLength");
487 parVector.emplace_back(fx,
"focalLengthX");
488 parVector.emplace_back(fy,
"focalLengthY");
489 parVector.emplace_back(cx,
"principalPointX");
490 parVector.emplace_back(cy,
"principalPointY");
491 parVector.emplace_back(k1,
"k1");
492 parVector.emplace_back(k2,
"k2");
493 parVector.emplace_back(t1,
"t1");
494 parVector.emplace_back(t2,
"t2");
495 parVector.emplace_back(k3,
"k3");
496 parVector.emplace_back(stamp,
"stamp");
497 for(i = 0; i < parVector.size(); i++)
501 if(!camData.
check(par->parname))
512 bool RgbdSensor_nws_yarp::writeData()
526 bool rgb_data_ok =
true;
527 bool depth_data_ok =
true;
529 if (((colorStamp.
getTime() - oldColorStamp.
getTime()) > 0) ==
false)
534 else { oldColorStamp = colorStamp; }
536 if (((depthStamp.
getTime() - oldDepthStamp.
getTime()) > 0) ==
false)
541 else { oldDepthStamp = depthStamp; }
551 colorFrame_StreamingPort.
write();
559 depthFrame_StreamingPort.
write();
567 if (sensor_p!=
nullptr)
571 switch (sensorStatus)
573 case(IRGBDSensor::RGBD_SENSOR_OK_IN_USE) :
581 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
const yarp::os::LogComponent & RGBDSENSORNWSYARP()
#define RGBD_INTERFACE_PROTOCOL_VERSION_MINOR
#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 setId(const std::string &id)
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 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.
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,...)
An interface for the device drivers.
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
An interface to the operating system, including Port based communication.