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>
21
23
24const std::string frameId_param = "frame_id";
25const std::string nodeName_param = "node_name";
26const std::string pointCloudTopicName_param = "topic_name";
27
28 constexpr double DEFAULT_THREAD_PERIOD = 0.03; // s
29} // namespace
67{
68
69private:
70 // defining types for shorter names
72 typedef unsigned int UInt;
73 rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr m_rosPublisher_pointCloud2;
74 rclcpp::Node::SharedPtr m_node;
75
76 enum SensorType
77 {
78 COLOR_SENSOR,
79 DEPTH_SENSOR
80 };
81
82 template <class T>
83 struct param
84 {
85 param(T& inVar, std::string inName)
86 {
87 var = &inVar;
88 parname = inName;
89 }
90 T* var;
91 std::string parname;
92 };
93
94
95
96 std::string m_nodeName;
97 std::string m_pointCloudTopicName;
98 std::string m_rosFrameId;
99
100 UInt nodeSeq {0};
101
102 yarp::dev::IRGBDSensor* m_sensor_p {nullptr};
103 yarp::dev::IFrameGrabberControls* m_fgCtrl {nullptr};
104 bool m_forceInfoSync {true};
105
106 // Synch
107 yarp::os::Property m_conf;
108
109 bool writeData();
110
111 static std::string yarp2RosPixelCode(int code);
112
113 bool fromConfig(yarp::os::Searchable& config);
114 bool initialize_ROS2(yarp::os::Searchable& config);
115
116 bool read(yarp::os::ConnectionReader& connection);
117
118 bool attach(yarp::dev::IRGBDSensor* s);
119
120
121public:
127 ~RgbdToPointCloudSensor_nws_ros2() override = default;
128
129 // WrapperSingle
130 bool attach(yarp::dev::PolyDriver *poly) override;
131 bool detach() override;
132
133 // DeviceDriver
134 bool open(yarp::os::Searchable& config) override;
135 bool close() override;
136 // PeriodicThread
137 void run() override;
138};
139#endif // YARP_DEV_RGBDTOPOINTCLOUDSENSOR_NWS_ROS2_H
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:56
Typed image class.
Definition Image.h:616
The main, catch-all namespace for YARP.
Definition dirs.h:16