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
22
23#include <mutex>
24
38{
39public:
43 RgbdSensor_nws_ros2& operator=(const RgbdSensor_nws_ros2&) = delete;
44 RgbdSensor_nws_ros2& operator=(RgbdSensor_nws_ros2&&) noexcept = delete;
45 ~RgbdSensor_nws_ros2() override = default;
46
47 // WrapperSingle
48 bool attach(yarp::dev::PolyDriver *poly) override;
49 bool detach() override;
50
51 // DeviceDriver
52 bool open(yarp::os::Searchable& config) override;
53 bool close() override;
54
55 // PeriodicThread
56 void run() override;
57
58private:
59 enum SensorType
60 {
61 COLOR_SENSOR,
62 DEPTH_SENSOR
63 };
64
65 template <class T>
66 struct param
67 {
68 param(T& inVar, std::string inName)
69 {
70 var = &inVar;
71 parname = inName;
72 }
73 T* var;
74 std::string parname;
75 };
76
77 rclcpp::Node::SharedPtr m_node;
78 rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr rosPublisher_color;
79 rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr rosPublisher_depth;
80 rclcpp::Publisher<sensor_msgs::msg::CameraInfo>::SharedPtr rosPublisher_colorCaminfo;
81 rclcpp::Publisher<sensor_msgs::msg::CameraInfo>::SharedPtr rosPublisher_depthCaminfo;
82
83 std::string m_depth_info_topic_name;
84 std::string m_color_info_topic_name;
85
86 yarp::dev::IRGBDSensor* sensor_p {nullptr};
87 yarp::dev::IFrameGrabberControls* fgCtrl {nullptr};
88 bool m_forceInfoSync {true};
89
90 bool writeData();
91 bool setCamInfo(sensor_msgs::msg::CameraInfo& cameraInfo,
92 const std::string& frame_id,
93 const yarp::os::Stamp& stamp,
94 const SensorType& sensorType);
95
96// static std::string yarp2RosPixelCode(int code);
97
98
99 bool fromConfig(yarp::os::Searchable &config);
100 bool initialize_ROS2(yarp::os::Searchable& config);
101
102 bool read(yarp::os::ConnectionReader& connection);
103
105
106};
107
108
109
110#endif // YARP_DEV_RANGEFINDER2D_NWS_ROS2_H
This class is the parameters parser for class RgbdSensor_nws_ros2.
RgbdSensor_nws_ros2: A Network grabber for kinect-like devices.
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
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
The main, catch-all namespace for YARP.
Definition dirs.h:16