YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RgbdSensor_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_RANGEFINDER2D_NWS_ROS2_H
7#define YARP_DEV_RANGEFINDER2D_NWS_ROS2_H
8
12
15
16#include <rclcpp/rclcpp.hpp>
17#include <std_msgs/msg/string.hpp>
18#include <sensor_msgs/msg/image.hpp>
19#include <sensor_msgs/msg/camera_info.hpp>
20#include <std_msgs/msg/u_int8.hpp>
21
23
24#include <mutex>
25
35 sensor_msgs::msg::CameraInfo colorCamInfo;
36 sensor_msgs::msg::CameraInfo depthCamInfo;
37};
38
44{
45public:
49 RgbdSensor_nws_ros2& operator=(const RgbdSensor_nws_ros2&) = delete;
50 RgbdSensor_nws_ros2& operator=(RgbdSensor_nws_ros2&&) noexcept = delete;
51 ~RgbdSensor_nws_ros2() override = default;
52
53 // WrapperSingle
54 bool attach(yarp::dev::PolyDriver *poly) override;
55 bool detach() override;
56
57 // DeviceDriver
58 bool open(yarp::os::Searchable& config) override;
59 bool close() override;
60
61 // PeriodicThread
62 void run() override;
63
64private:
65 enum SensorType
66 {
67 COLOR_SENSOR,
68 DEPTH_SENSOR
69 };
70
71 template <class T>
72 struct param
73 {
74 param(T& inVar, std::string inName)
75 {
76 var = &inVar;
77 parname = inName;
78 }
79 T* var;
80 std::string parname;
81 };
82
83 rclcpp::Node::SharedPtr m_node;
84 rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr rosPublisher_color;
85 rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr rosPublisher_depth;
86 rclcpp::Publisher<sensor_msgs::msg::CameraInfo>::SharedPtr rosPublisher_colorCaminfo;
87 rclcpp::Publisher<sensor_msgs::msg::CameraInfo>::SharedPtr rosPublisher_depthCaminfo;
88 rclcpp::Publisher<std_msgs::msg::UInt8>::SharedPtr m_rosPublisher_status;
89
90 std::string m_depth_info_topic_name;
91 std::string m_color_info_topic_name;
92
93 yarp::dev::IRGBDSensor* sensor_p {nullptr};
94 yarp::dev::IFrameGrabberControls* fgCtrl {nullptr};
95 bool m_forceInfoSync {true};
96 bool m_firstTime {true};
97
98 CameraInfoData m_camInfoData;
99
100 bool writeData();
101 bool setCamInfo(sensor_msgs::msg::CameraInfo& cameraInfo,
102 const std::string& frame_id,
103 const SensorType& sensorType);
104 bool fromConfig(yarp::os::Searchable &config);
105 bool initialize_ROS2(yarp::os::Searchable& config);
106
107 bool read(yarp::os::ConnectionReader& connection);
108
110
111};
112
113
114
115#endif // YARP_DEV_RANGEFINDER2D_NWS_ROS2_H
This class is the parameters parser for class RgbdSensor_nws_ros2.
bool detach() override
Detach the object (you must have first called attach).
RgbdSensor_nws_ros2(RgbdSensor_nws_ros2 &&) noexcept=delete
RgbdSensor_nws_ros2(const RgbdSensor_nws_ros2 &)=delete
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void run() override
Loop function.
bool close() override
Close 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.
An interface for reading from a network connection.
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition Searchable.h:31
The main, catch-all namespace for YARP.
Definition dirs.h:16
RgbdSensor_nws_ros2: A Network grabber for kinect-like devices.
sensor_msgs::msg::CameraInfo depthCamInfo
sensor_msgs::msg::CameraInfo colorCamInfo