YARP
Yet Another Robot Platform
FrameGrabber_nws_yarp.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_FRAMEGRABBER_NWS_YARP_H
8 #define YARP_FRAMEGRABBER_NWS_YARP_H
9 
10 #include <yarp/os/BufferedPort.h>
11 #include <yarp/os/PeriodicThread.h>
12 #include <yarp/os/RpcServer.h>
13 #include <yarp/os/Stamp.h>
14 
15 #include <yarp/dev/DeviceDriver.h>
21 #include <yarp/dev/WrapperSingle.h>
22 
27 
28 
89 {
90 private:
91  // Ports
92  yarp::os::RpcServer rpcPort;
94 
95  // Subdevice
96  yarp::dev::PolyDriver* subdevice {nullptr};
97  bool isSubdeviceOwned {false};
98 
99  // Interfaces handled
100  yarp::dev::IRgbVisualParams* iRgbVisualParams {nullptr};
101  yarp::dev::IFrameGrabberImage* iFrameGrabberImage {nullptr};
102  yarp::dev::IFrameGrabberImageRaw* iFrameGrabberImageRaw {nullptr};
103  yarp::dev::IFrameGrabberControls* iFrameGrabberControls {nullptr};
104  yarp::dev::IFrameGrabberControlsDC1394* iFrameGrabberControlsDC1394 {nullptr};
105  yarp::dev::IPreciselyTimed* iPreciselyTimed {nullptr};
106 
107  // Responders
111  yarp::proto::framegrabber::FrameGrabberControls_Responder frameGrabberControls_Responder;
112  yarp::proto::framegrabber::FrameGrabberControlsDC1394_Responder frameGrabberControlsDC1394_Responder;
113 
114  // Images
116  yarp::sig::ImageOf<yarp::sig::PixelMono>* img_Raw {nullptr};
117 
118  // Internal state
119  bool active {false};
120  yarp::os::Stamp stamp;
121 
122  // Options
123  static constexpr double DEFAULT_THREAD_PERIOD = 0.03; // seconds
124  double period {DEFAULT_THREAD_PERIOD};
125  bool noDrop {true}; // FIXME DRDANZ
126 
127  enum Capabilities
128  {
129  COLOR,
130  RAW,
131  };
132  Capabilities cap {COLOR};
133 
134 public:
140  ~FrameGrabber_nws_yarp() override;
141 
142  // DeviceDriver
143  bool close() override;
144  bool open(yarp::os::Searchable& config) override;
145 
146  // IWrapper interface
147  bool attach(yarp::dev::PolyDriver* poly) override;
148  bool detach() override;
149 
150  //RateThread
151  bool threadInit() override;
152  void run() override;
153 
154  // DeviceResponder
155  bool respond(const yarp::os::Bottle& command, yarp::os::Bottle& reply) override;
156 };
157 
158 #endif // YARP_FRAMEGRABBER_NWS_YARP_H
#define DEFAULT_THREAD_PERIOD
Definition: AnalogWrapper.h:42
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_IMAGERAW
Definition: CameraVocabs.h:17
frameGrabber_nws_yarp: A YARP NWS for camera devices.
FrameGrabber_nws_yarp & operator=(FrameGrabber_nws_yarp &&)=delete
FrameGrabber_nws_yarp & operator=(const FrameGrabber_nws_yarp &)=delete
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool detach() override
Detach the object (you must have first called attach).
bool threadInit() override
Initialization method.
FrameGrabber_nws_yarp(const FrameGrabber_nws_yarp &)=delete
FrameGrabber_nws_yarp(FrameGrabber_nws_yarp &&)=delete
void run() override
Loop function.
bool close() override
Close the DeviceDriver.
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
bool respond(const yarp::os::Bottle &command, yarp::os::Bottle &reply) override
Respond to a message.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
A cheap and cheerful framework for human readable/writable forms of messages to devices.
Definition: DeviceDriver.h:131
Control interface for frame grabber devices.
An interface for retrieving intrinsic parameter from a rgb camera.
A container for a device driver.
Definition: PolyDriver.h:24
Helper interface for an object that can wrap/or "attach" to a single other device.
Definition: WrapperSingle.h:32
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
An abstraction for a periodic thread.
A port that is specialized as an RPC server.
Definition: RpcServer.h:24
A base class for nested structures that can be searched.
Definition: Searchable.h:66
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22