YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RgbdToPointCloudSensor_nws_ros2.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_RGBDTOPOINTCLOUDSENSOR_NWS_ROS2_H
7#define YARP_DEV_RGBDTOPOINTCLOUDSENSOR_NWS_ROS2_H
8
12
15
16#include <rclcpp/rclcpp.hpp>
17#include <std_msgs/msg/string.hpp>
18#include <sensor_msgs/msg/point_cloud2.hpp>
19
20#include <mutex>
22
24
25const std::string frameId_param = "frame_id";
26const std::string nodeName_param = "node_name";
27const std::string pointCloudTopicName_param = "topic_name";
28
29 constexpr double DEFAULT_THREAD_PERIOD = 0.03; // s
30} // namespace
63{
64
65private:
66 // defining types for shorter names
68 typedef unsigned int UInt;
69 rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr m_rosPublisher_pointCloud2;
70 rclcpp::Node::SharedPtr m_node;
71
72 enum SensorType
73 {
74 COLOR_SENSOR,
75 DEPTH_SENSOR
76 };
77
78 template <class T>
79 struct param
80 {
81 param(T& inVar, std::string inName)
82 {
83 var = &inVar;
84 parname = inName;
85 }
86 T* var;
87 std::string parname;
88 };
89
90 UInt nodeSeq {0};
91
92 yarp::dev::IRGBDSensor* m_sensor_p {nullptr};
93 yarp::dev::IFrameGrabberControls* m_fgCtrl {nullptr};
94 bool m_forceInfoSync {true};
95
96 // Synch
97 yarp::os::Property m_conf;
98
99 bool writeData();
100
101 static std::string yarp2RosPixelCode(int code);
102
103 bool fromConfig(yarp::os::Searchable& config);
104 bool initialize_ROS2(yarp::os::Searchable& config);
105
106 bool read(yarp::os::ConnectionReader& connection);
107
108 bool attach(yarp::dev::IRGBDSensor* s);
109
110
111public:
117 ~RgbdToPointCloudSensor_nws_ros2() override = default;
118
119 // WrapperSingle
120 bool attach(yarp::dev::PolyDriver *poly) override;
121 bool detach() override;
122
123 // DeviceDriver
124 bool open(yarp::os::Searchable& config) override;
125 bool close() override;
126 // PeriodicThread
127 void run() override;
128};
129#endif // YARP_DEV_RGBDTOPOINTCLOUDSENSOR_NWS_ROS2_H
This class is the parameters parser for class RgbdToPointCloudSensor_nws_ros2.
rgbdToPointCloudSensor_nws_ros2: A Network grabber for kinect-like devices.
RgbdToPointCloudSensor_nws_ros2(const RgbdToPointCloudSensor_nws_ros2 &)=delete
RgbdToPointCloudSensor_nws_ros2(RgbdToPointCloudSensor_nws_ros2 &&) noexcept=delete
bool close() override
Close the DeviceDriver.
bool detach() override
Detach the object (you must have first called attach).
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
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
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.
An interface for reading from a network connection.
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
Typed image class.
Definition Image.h:616
The main, catch-all namespace for YARP.
Definition dirs.h:16