YARP
Yet Another Robot Platform
RGBDSensorClient_StreamingMsgParser.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
11 
12 using namespace yarp::dev;
13 
14 // Callback reader for rgb
17 
19 {
20  last_rgb = datum;
21 }
22 
24 {
25  return last_rgb;
26 }
27 
28 
29 // callback reader for depthImage
32 
34 {
35  last_depth = datum;
36 }
37 
39 {
40  return last_depth;
41 }
42 
43 
44 // Streaming handler
46  port_rgb(nullptr),
47  port_depth(nullptr)
48 {}
49 
51 {
52  data = read_rgb.getImage();
53  if(timeStamp)
54  port_rgb->getEnvelope(*timeStamp);
55  return true;
56 }
57 
59 {
60  data = read_depth.getImage();
61  if(timeStamp)
62  port_depth->getEnvelope(*timeStamp);
63  return true;
64 }
65 
67 {
68  rgbImage = read_rgb.getImage();
69  depthImage = read_depth.getImage();
70 
71  if(rgbStamp)
72  port_rgb->getEnvelope(*rgbStamp);
73 
74  if(depthStamp)
75  port_depth->getEnvelope(*depthStamp);
76  return true;
77 }
78 
81 {
82  port_rgb = _port_rgb;
83  port_depth = _port_depth;
84  port_rgb->useCallback(read_rgb);
85  port_depth->useCallback(read_depth);
86 }
void onRead(yarp::sig::ImageOf< yarp::sig::PixelFloat > &datum) override
yarp::sig::ImageOf< yarp::sig::PixelFloat > getImage()
bool readDepth(yarp::sig::ImageOf< yarp::sig::PixelFloat > &data, yarp::os::Stamp *timeStamp=NULL)
bool read(yarp::sig::FlexImage &rgbImage, yarp::sig::ImageOf< yarp::sig::PixelFloat > &depthImage, yarp::os::Stamp *rgbStamp=NULL, yarp::os::Stamp *depthStamp=NULL)
void attach(yarp::os::BufferedPort< yarp::sig::FlexImage > *_port_rgb, yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelFloat >> *_port_depth)
bool readRgb(yarp::sig::FlexImage &data, yarp::os::Stamp *timeStamp=NULL)
void onRead(yarp::sig::FlexImage &datum) override
bool getEnvelope(PortReader &envelope) override
Get the envelope information (e.g., a timestamp) from the last message received on the port.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
Image class with user control of representation details.
Definition: Image.h:403
An interface for the device drivers.