YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RgbdSensor_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_RGBDSENSOR_NWS_ROS_H
7#define YARP_DEV_RGBDSENSOR_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/CameraInfo.h>
34#include <yarp/rosmsg/sensor_msgs/Image.h>
35
36#define DEFAULT_THREAD_PERIOD 0.03 // s
37
38namespace RGBDImpl
39{
40 const std::string frameId_param = "frame_Id";
41 const std::string nodeName_param = "nodeName";
42 const std::string colorTopicName_param = "colorTopicName";
43 const std::string depthTopicName_param = "depthTopicName";
44 const std::string depthInfoTopicName_param = "depthInfoTopicName";
45 const std::string colorInfoTopicName_param = "colorInfoTopicName";
46}
47
91{
92private:
96 typedef unsigned int UInt;
97
98 enum SensorType{COLOR_SENSOR, DEPTH_SENSOR};
99
100 template <class T>
101 struct param
102 {
103 param(T& inVar, std::string inName)
104 {
105 var = &inVar;
106 parname = inName;
107 }
108 T* var;
109 std::string parname;
110 };
111
112 ImageTopicType publisherPort_color;
113 ImageTopicType publisherPort_depth;
114 DepthTopicType publisherPort_colorCaminfo;
115 DepthTopicType publisherPort_depthCaminfo;
116 yarp::os::Node* m_node;
117 std::string nodeName;
118 std::string m_color_frame_id;
119 std::string m_depth_frame_id;
120 yarp::sig::FlexImage colorImage;
122 UInt nodeSeq;
123
124 // Image data specs
125 // int hDim, vDim;
126 double period;
127 std::string sensorId;
128 yarp::dev::IRGBDSensor* sensor_p;
131 int verbose;
132 bool forceInfoSync;
133 bool initialize_ROS(yarp::os::Searchable& config);
134
135 // Synch
136 yarp::os::Stamp colorStamp;
137 yarp::os::Stamp depthStamp;
138
139 bool writeData();
140 bool setCamInfo(yarp::rosmsg::sensor_msgs::CameraInfo& cameraInfo,
141 const std::string& frame_id,
142 const UInt& seq,
143 const SensorType& sensorType);
144
145public:
151 ~RgbdSensor_nws_ros() override;
152
153 bool open(yarp::os::Searchable &params) override;
154 bool close() override;
155
159 bool attach(yarp::dev::PolyDriver *poly) override;
160 bool detach() override;
161
162 bool threadInit() override;
163 void threadRelease() override;
164 void run() override;
165};
166
167#endif // YARP_DEV_RGBDSENSOR_NWS_ROS_H
contains the definition of a Vector type
rgbdSensor_nws_ros: A Network grabber for kinect-like devices. This device will produce two streams o...
bool close() override
Close the DeviceDriver.
void threadRelease() override
Release method.
RgbdSensor_nws_ros & operator=(const RgbdSensor_nws_ros &)=delete
RgbdSensor_nws_ros(RgbdSensor_nws_ros &&)=delete
bool attach(yarp::dev::PolyDriver *poly) override
Specify which sensor this thread has to read from.
RgbdSensor_nws_ros & operator=(RgbdSensor_nws_ros &&)=delete
bool open(yarp::os::Searchable &params) override
Device driver interface.
RgbdSensor_nws_ros(const RgbdSensor_nws_ros &)=delete
bool threadInit() override
Initialization method.
void run() override
Loop function.
bool detach() override
WrapperSingle interface.
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 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
const std::string depthInfoTopicName_param
const std::string depthTopicName_param
const std::string colorTopicName_param
const std::string nodeName_param
const std::string frameId_param
const std::string colorInfoTopicName_param