39 if (!config.
check(
"period",
"refresh period of the broadcasted values in s")) {
49 if (!config.
check(
"node_name",
"the name of the ros node")) {
57 if (!config.
check(
"topic_name",
"the name of the ros node")) {
61 pointCloudTopicName = config.
find(
"topic_name").
asString();
64 if (!config.
check(
"frame_id",
"the name of the ros node")) {
73 if (!publisherPort_pointCloud.
topic(pointCloudTopicName))
81 if(config.
check(
"subdevice")) {
82 if(! openAndAttachSubDevice(config))
87 isSubdeviceOwned=
true;
89 isSubdeviceOwned=
false;
94 bool RGBDToPointCloudSensor_nws_ros::openAndAttachSubDevice(
Searchable& prop)
100 p.setMonitor(prop.getMonitor(),
"subdevice");
106 subDeviceOwned->
open(p);
108 if (!subDeviceOwned->
isValid())
113 isSubdeviceOwned =
true;
114 if(!
attach(subDeviceOwned)) {
131 delete subDeviceOwned;
132 subDeviceOwned=
nullptr;
136 isSubdeviceOwned =
false;
161 if (isSubdeviceOwned)
173 poly->
view(sensor_p);
177 if(sensor_p ==
nullptr)
183 PeriodicThread::setPeriod(period);
184 return PeriodicThread::start();
201 bool RGBDToPointCloudSensor_nws_ros::writeData()
216 bool rgb_data_ok =
true;
217 bool depth_data_ok =
true;
224 else { oldColorStamp = colorStamp; }
231 else { oldDepthStamp = depthStamp; }
251 PointCloud2Type& pc2Ros = publisherPort_pointCloud.
prepare();
255 headerRos.
seq = nodeSeq;
260 std::vector<yarp::rosmsg::sensor_msgs::PointField> pointFieldRos;
265 pointFieldRos[0].name =
"x";
266 pointFieldRos[0].offset = 0;
267 pointFieldRos[0].datatype = 7;
268 pointFieldRos[0].count = 1;
269 pointFieldRos[1].name =
"y";
270 pointFieldRos[1].offset = 4;
271 pointFieldRos[1].datatype = 7;
272 pointFieldRos[1].count = 1;
273 pointFieldRos[2].name =
"z";
274 pointFieldRos[2].offset = 8;
275 pointFieldRos[2].datatype = 7;
276 pointFieldRos[2].count = 1;
277 pointFieldRos[3].name =
"rgb";
278 pointFieldRos[3].offset = 16;
279 pointFieldRos[3].datatype = 7;
280 pointFieldRos[3].count = 1;
281 pc2Ros.fields = pointFieldRos;
285 pc2Ros.header = headerRos;
286 pc2Ros.width = yarpCloud.
width() * yarpCloud.
height();
288 pc2Ros.is_dense = yarpCloud.
isDense();
293 publisherPort_pointCloud.
write();
305 if (sensor_p!=
nullptr)
309 switch (sensorStatus)
311 case(IRGBDSensor::RGBD_SENSOR_OK_IN_USE) :
319 case(IRGBDSensor::RGBD_SENSOR_NOT_READY):
const yarp::os::LogComponent & RGBDTOPOINTCLOUDSENSORNWSROS()
constexpr double DEFAULT_THREAD_PERIOD
bool open(yarp::os::Searchable ¶ms) override
Device driver interface.
bool attach(yarp::dev::PolyDriver *poly) override
Specify which sensor this thread has to read from.
void threadRelease() override
Release method.
bool threadInit() override
Initialization method.
bool close() override
Close the DeviceDriver.
bool detach() override
WrapperSingle interface.
~RGBDToPointCloudSensor_nws_ros() override
RGBDToPointCloudSensor_nws_ros()
void run() override
Loop function.
bool view(T *&x)
Get an interface to the device driver.
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override=0
Get the intrinsic parameters of the rgb camera.
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.
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.
void interrupt()
interrupt delegates the call to the Node port interrupt.
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...
A class for storing options and configuration information.
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.
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
bool topic(const std::string &name)
Set topic to publish to.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::Publisher::write.
void write(bool forceStrict=false)
Write the current object being returned by Publisher::prepare.
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.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual std::string asString() const
Get string value.
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 height() const
Gets height of image in pixels.
virtual size_t width() const
virtual bool isDense() const
virtual size_t height() const
const char * getRawData() const override
Get the pointer to the data.
size_t dataSizeBytes() const override
Get the size of the data in terms of number of bytes.
#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.
An interface to the operating system, including Port based communication.
yarp::sig::PointCloud< T1 > depthRgbToPC(const yarp::sig::ImageOf< yarp::sig::PixelFloat > &depth, const yarp::sig::ImageOf< T2 > &color, const yarp::sig::IntrinsicParams &intrinsic, const yarp::sig::utils::OrganizationType organizationType=yarp::sig::utils::OrganizationType::Organized)
depthRgbToPC, compute the colored PointCloud given depth image, color image and the intrinsic paramet...
The IntrinsicParams struct to handle the intrinsic parameter of cameras(RGB and RGBD either).