YARP
Yet Another Robot Platform
RGBDSensorClient_StreamingMsgParser.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_DEV_RGBDSENSORCLIENT_RGBDSENSORCLIENT_STREAMINGMSGPARSER_H
10 #define YARP_DEV_RGBDSENSORCLIENT_RGBDSENSORCLIENT_STREAMINGMSGPARSER_H
11 
12 #include <yarp/os/LogStream.h>
13 #include <yarp/os/PortablePair.h>
14 #include <yarp/os/Stamp.h>
15 #include <yarp/sig/Image.h>
16 #include <yarp/dev/DeviceDriver.h>
17 
18 #include <list>
19 #include <tuple>
20 #include <mutex>
21 
22 
24  public yarp::os::BufferedPort<yarp::sig::FlexImage>
25 {
26 private:
27  double local_arrival_time {0.0};
28  yarp::os::Stamp stamp;
29  yarp::sig::FlexImage last_rgb;
30  mutable std::mutex mutex;
31 
32 public:
33  RgbImageBufferedPort() = default;
34  ~RgbImageBufferedPort() override = default;
35 
37  void onRead(yarp::sig::FlexImage& datum) override;
38  std::tuple<bool, yarp::sig::FlexImage, yarp::os::Stamp> getImage() const;
39 };
40 
41 
43  public yarp::os::BufferedPort<yarp::sig::ImageOf< yarp::sig::PixelFloat>>
44 {
45 private:
46  double local_arrival_time {0.0};
47  yarp::os::Stamp stamp;
49  mutable std::mutex mutex;
50 
51 public:
53  ~FloatImageBufferedPort() override = default;
54 
57  std::tuple<bool, yarp::sig::ImageOf<yarp::sig::PixelFloat>, yarp::os::Stamp> getImage() const;
58 };
59 
60 
62 {
63 private:
64  RgbImageBufferedPort *port_rgb {nullptr};
65  FloatImageBufferedPort *port_depth {nullptr};
66 
67 public:
69 
70  bool readRgb(yarp::sig::FlexImage &data,
71  yarp::os::Stamp *timeStamp = nullptr);
72 
74  yarp::os::Stamp *timeStamp = nullptr);
75 
76  bool read(yarp::sig::FlexImage &rgbImage,
78  yarp::os::Stamp *rgbStamp = nullptr,
79  yarp::os::Stamp *depthStamp = nullptr);
80 
81  void attach(RgbImageBufferedPort* _port_rgb,
82  FloatImageBufferedPort* _port_depth);
83 };
84 
85 #endif // YARP_DEV_RGBDSENSORCLIENT_RGBDSENSORCLIENT_STREAMINGMSGPARSER_H
LogStream.h
RGBDSensor_StreamingMsgParser::read
bool read(yarp::sig::FlexImage &rgbImage, yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthImage, yarp::os::Stamp *rgbStamp=nullptr, yarp::os::Stamp *depthStamp=nullptr)
Definition: RGBDSensorClient_StreamingMsgParser.cpp:100
FloatImageBufferedPort
Definition: RGBDSensorClient_StreamingMsgParser.h:44
yarp::os::TypedReaderCallback
A callback for typed data from a port.
Definition: TypedReaderCallback.h:31
RgbImageBufferedPort::~RgbImageBufferedPort
~RgbImageBufferedPort() override=default
PortablePair.h
FloatImageBufferedPort::~FloatImageBufferedPort
~FloatImageBufferedPort() override=default
yarp::sig::ImageOf< yarp::sig::PixelFloat >
yarp::os::BufferedPort
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:64
RGBDSensor_StreamingMsgParser::attach
void attach(RgbImageBufferedPort *_port_rgb, FloatImageBufferedPort *_port_depth)
Definition: RGBDSensorClient_StreamingMsgParser.cpp:124
RGBDSensor_StreamingMsgParser
Definition: RGBDSensorClient_StreamingMsgParser.h:62
RgbImageBufferedPort
Definition: RGBDSensorClient_StreamingMsgParser.h:25
yarp::sig::FlexImage
Image class with user control of representation details.
Definition: Image.h:403
Stamp.h
RGBDSensor_StreamingMsgParser::readRgb
bool readRgb(yarp::sig::FlexImage &data, yarp::os::Stamp *timeStamp=nullptr)
Definition: RGBDSensorClient_StreamingMsgParser.cpp:68
RgbImageBufferedPort::RgbImageBufferedPort
RgbImageBufferedPort()=default
FloatImageBufferedPort::FloatImageBufferedPort
FloatImageBufferedPort()=default
FloatImageBufferedPort::getImage
std::tuple< bool, yarp::sig::ImageOf< yarp::sig::PixelFloat >, yarp::os::Stamp > getImage() const
Definition: RGBDSensorClient_StreamingMsgParser.cpp:50
Image.h
RGBDSensor_StreamingMsgParser::RGBDSensor_StreamingMsgParser
RGBDSensor_StreamingMsgParser()=default
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
RgbImageBufferedPort::getImage
std::tuple< bool, yarp::sig::FlexImage, yarp::os::Stamp > getImage() const
Definition: RGBDSensorClient_StreamingMsgParser.cpp:25
RgbImageBufferedPort::onRead
void onRead(yarp::sig::FlexImage &datum) override
Definition: RGBDSensorClient_StreamingMsgParser.cpp:17
FloatImageBufferedPort::onRead
void onRead(yarp::sig::ImageOf< yarp::sig::PixelFloat > &datum) override
Definition: RGBDSensorClient_StreamingMsgParser.cpp:42
RGBDSensor_StreamingMsgParser::readDepth
bool readDepth(yarp::sig::ImageOf< yarp::sig::PixelFloat > &data, yarp::os::Stamp *timeStamp=nullptr)
Definition: RGBDSensorClient_StreamingMsgParser.cpp:84
DeviceDriver.h