YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RGBDToPointCloudSensor_nws_ros.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_RGBDTOPOINTCLOUDSENSOR_NWS_ROS_H
7#define YARP_DEV_RGBDTOPOINTCLOUDSENSOR_NWS_ROS_H
8
9#include <vector>
10#include <iostream>
11#include <string>
12#include <sstream>
13
14#include <yarp/os/Port.h>
15#include <yarp/os/Time.h>
16#include <yarp/os/Stamp.h>
17#include <yarp/os/Network.h>
18#include <yarp/os/Property.h>
20
21#include <yarp/sig/Vector.h>
22
24#include <yarp/dev/PolyDriver.h>
27
28// ROS stuff
29#include <yarp/os/Node.h>
30#include <yarp/os/Publisher.h>
31#include <yarp/os/Subscriber.h>
32#include <yarp/rosmsg/TickTime.h>
33#include <yarp/rosmsg/sensor_msgs/PointCloud2.h>
34
35constexpr double DEFAULT_THREAD_PERIOD = 0.033; // s
36
38 const std::string frameId_param = "frame_Id";
39 const std::string nodeName_param = "nodeName";
40 const std::string pointCloudTopicName_param = "pointCloudTopicName";
41}
79{
80private:
81 // defining types for shorter names
84 typedef yarp::rosmsg::sensor_msgs::PointCloud2 PointCloud2Type;
85 typedef unsigned int UInt;
86
87 enum SensorType{COLOR_SENSOR, DEPTH_SENSOR};
88
89 template <class T>
90 struct param
91 {
92 param(T& inVar, std::string inName)
93 {
94 var = &inVar;
95 parname = inName;
96 }
97 T* var;
98 std::string parname;
99 };
100
101 PointCloudTopicType publisherPort_pointCloud;
102 yarp::os::Node* m_node = nullptr;
103 std::string nodeName;
104 std::string pointCloudTopicName;
105 std::string frameId;
106
107 // images from device
108 yarp::sig::FlexImage colorImage;
110 UInt nodeSeq = 0;
111
112
113 // this is the sub device or the real device
114
115 double period = DEFAULT_THREAD_PERIOD;
116 std::string sensorId;
117 yarp::dev::IRGBDSensor* sensor_p = nullptr;
118 yarp::dev::IFrameGrabberControls* fgCtrl = nullptr;
120
121 int verbose = 4;
122 bool forceInfoSync = true;
123 bool initialize_ROS(yarp::os::Searchable& config);
124
125 // Open the wrapper only, the attach method needs to be called before using it
126 // Typical usage: yarprobotinterface
127 bool openDeferredAttach(yarp::os::Searchable& prop);
128
129 // Synch
130 yarp::os::Stamp colorStamp;
131 yarp::os::Stamp depthStamp;
132 yarp::os::Property m_conf;
133
134 bool writeData();
135
136public:
143
144 bool open(yarp::os::Searchable &params) override;
146 bool close() override;
147
151 bool attach(yarp::dev::PolyDriver *poly) override;
152 bool detach() override;
153
154 bool threadInit() override;
155 void threadRelease() override;
156 void run() override;
157};
158
159#endif // YARP_DEV_RGBDTOPOINTCLOUDSENSOR_NWS_ROS_H
constexpr double DEFAULT_THREAD_PERIOD
contains the definition of a Vector type
RGBDToPointCloudSensor_nws_ros: A Network grabber for kinect-like devices. This device will produce o...
RGBDToPointCloudSensor_nws_ros(RGBDToPointCloudSensor_nws_ros &&)=delete
bool open(yarp::os::Searchable &params) override
Device driver interface.
bool attach(yarp::dev::PolyDriver *poly) override
Specify which sensor this thread has to read from.
bool threadInit() override
Initialization method.
bool close() override
Close the DeviceDriver.
bool detach() override
WrapperSingle interface.
RGBDToPointCloudSensor_nws_ros & operator=(RGBDToPointCloudSensor_nws_ros &&)=delete
RGBDToPointCloudSensor_nws_ros & operator=(const RGBDToPointCloudSensor_nws_ros &)=delete
RGBDToPointCloudSensor_nws_ros(const RGBDToPointCloudSensor_nws_ros &)=delete
bool fromConfig(yarp::os::Searchable &params)
Interface implemented by all device drivers.
Control interface for frame grabber devices.
A generic interface for cameras that have both color camera as well as depth camera sensor,...
Definition IRGBDSensor.h:39
A container for a device driver.
Definition PolyDriver.h:23
Helper interface for an object that can wrap/or "attach" to a single other device.
A mini-server for performing network communication in the background.
The Node class.
Definition Node.h:23
An abstraction for a periodic thread.
A class for storing options and configuration information.
Definition Property.h:33
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
Image class with user control of representation details.
Definition Image.h:363
Typed image class.
Definition Image.h:605