openrave-yarp-plugins
Loading...
Searching...
No Matches
YarpOpenraveGrabber.hpp
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3#ifndef __YARP_OPENRAVE_GRABBER_HPP__
4#define __YARP_OPENRAVE_GRABBER_HPP__
5
6#include <yarp/conf/version.h>
7
8#include <yarp/dev/DeviceDriver.h>
9#include <yarp/dev/IFrameGrabberImage.h>
10#include <yarp/dev/IFrameGrabberControls.h>
11#include <yarp/dev/IRgbVisualParams.h>
12
13#include <openrave/openrave.h>
14
15#include <boost/smart_ptr/shared_ptr.hpp>
16
17#include "YarpOpenraveBase.hpp"
18
19namespace roboticslab
20{
21
35 public yarp::dev::DeviceDriver,
36 public yarp::dev::IFrameGrabberControls,
37 public yarp::dev::IFrameGrabberImage,
38 public yarp::dev::IRgbVisualParams
39{
40public:
41#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
42 constexpr static auto ret_ok = yarp::dev::ReturnValue::return_code::return_value_ok;
43#endif
44
45 // ------- DeviceDriver declarations. Implementation in DeviceDriverImageImpl.cpp -------
46 bool open(yarp::os::Searchable & config) override;
47 bool close() override;
48
49 // ------- IFrameGrabberControls declarations. Implementation in IFrameGrabberControlsImpl.cpp -------
50#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
51 yarp::dev::ReturnValue getCameraDescription(yarp::dev::CameraDescriptor & camera) override;
52 yarp::dev::ReturnValue hasFeature(yarp::dev::cameraFeature_id_t feature, bool & hasFeature) override;
53 yarp::dev::ReturnValue setFeature(yarp::dev::cameraFeature_id_t feature, double value) override;
54 yarp::dev::ReturnValue getFeature(yarp::dev::cameraFeature_id_t feature, double & value) override;
55 yarp::dev::ReturnValue setFeature(yarp::dev::cameraFeature_id_t feature, double value1, double value2) override;
56 yarp::dev::ReturnValue getFeature(yarp::dev::cameraFeature_id_t feature, double & value1, double & value2) override;
57 yarp::dev::ReturnValue hasOnOff(yarp::dev::cameraFeature_id_t feature, bool & hasOnOff) override;
58 yarp::dev::ReturnValue setActive(yarp::dev::cameraFeature_id_t feature, bool onoff) override;
59 yarp::dev::ReturnValue getActive(yarp::dev::cameraFeature_id_t feature, bool & isActive) override;
60 yarp::dev::ReturnValue hasAuto(yarp::dev::cameraFeature_id_t feature, bool & hasAuto) override;
61 yarp::dev::ReturnValue hasManual(yarp::dev::cameraFeature_id_t feature, bool & hasManual) override;
62 yarp::dev::ReturnValue hasOnePush(yarp::dev::cameraFeature_id_t feature, bool & hasOnePush) override;
63 yarp::dev::ReturnValue setMode(yarp::dev::cameraFeature_id_t feature, yarp::dev::FeatureMode mode) override;
64 yarp::dev::ReturnValue getMode(yarp::dev::cameraFeature_id_t feature, yarp::dev::FeatureMode & mode) override;
65 yarp::dev::ReturnValue setOnePush(yarp::dev::cameraFeature_id_t feature) override;
66#else
67 bool getCameraDescription(CameraDescriptor * camera) override;
68 bool hasFeature(int feature, bool * hasFeature) override;
69 bool setFeature(int feature, double value) override;
70 bool getFeature(int feature, double * value) override;
71 bool setFeature(int feature, double value1, double value2) override;
72 bool getFeature(int feature, double * value1, double * value2) override;
73 bool hasOnOff(int feature, bool * HasOnOff) override;
74 bool setActive(int feature, bool onoff) override;
75 bool getActive(int feature, bool * isActive) override;
76 bool hasAuto(int feature, bool * hasAuto) override;
77 bool hasManual(int feature, bool * hasManual) override;
78 bool hasOnePush(int feature, bool * hasOnePush) override;
79 bool setMode(int feature, FeatureMode mode) override;
80 bool getMode(int feature, FeatureMode * mode) override;
81 bool setOnePush(int feature) override;
82#endif
83
84 // ------- IFrameGrabberImage declarations. Implementation in IFrameGrabberImageImpl.cpp -------
85#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
86 yarp::dev::ReturnValue getImage(yarp::sig::ImageOf<yarp::sig::PixelRgb> & image) override;
87#else
88 bool getImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>& image) override;
89#endif
90 int height() const override;
91 int width() const override;
92
93 // ------- IRgbVisualParams declarations. Look at IVisualParams.h for documentation. Implementation in IFrameGrabberImageImpl.cpp -------
94#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
95 yarp::dev::ReturnValue getRgbSupportedConfigurations(std::vector<yarp::dev::CameraConfig> & configurations) override { return ret_ok; }
96 yarp::dev::ReturnValue getRgbResolution(int & width, int & height) override { return ret_ok; }
97 yarp::dev::ReturnValue setRgbResolution(int width, int height) override { return ret_ok; }
98 yarp::dev::ReturnValue getRgbFOV(double & horizontalFov, double & verticalFov) override { return ret_ok; }
99 yarp::dev::ReturnValue setRgbFOV(double horizontalFov, double verticalFov) override { return ret_ok; }
100#if YARP_VERSION_COMPARE(>=, 4, 1, 0) || defined(YARP_NEXT)
101 yarp::dev::ReturnValue getRgbIntrinsicParam(yarp::sig::IntrinsicParams & intrinsic) override { return ret_ok; }
102#else
103 yarp::dev::ReturnValue getRgbIntrinsicParam(yarp::os::Property & intrinsic) override { return ret_ok; }
104#endif
105 yarp::dev::ReturnValue getRgbMirroring(bool & mirror) override { return ret_ok; }
106 yarp::dev::ReturnValue setRgbMirroring(bool mirror) override { return ret_ok; }
107#else
108 bool getRgbSupportedConfigurations(yarp::sig::VectorOf<yarp::dev::CameraConfig> & configurations) override { return true; }
109 bool getRgbResolution(int & width, int & height) override { return true; }
110 bool setRgbResolution(int width, int height) override { return true; }
111 bool getRgbFOV(double & horizontalFov, double & verticalFov) override { return true; }
112 bool setRgbFOV(double horizontalFov, double verticalFov) override { return true; }
113 bool getRgbIntrinsicParam(yarp::os::Property & intrinsic) override { return true; }
114 bool getRgbMirroring(bool & mirror) override { return true; }
115 bool setRgbMirroring(bool mirror) override { return true; }
116#endif
117 int getRgbHeight() override;
118 int getRgbWidth() override;
119
120private:
121 // General Grabber parameters
122 int _height, _width;
123
124 // OpenRAVE
125 OpenRAVE::SensorBasePtr sensorBasePtr;
126 boost::shared_ptr<OpenRAVE::SensorBase::CameraSensorData> sensorDataPtr;
127 boost::shared_ptr<OpenRAVE::SensorBase::CameraGeomData> modGeomDataPtr;
128
129 // YARP
130#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
131 yarp::dev::CameraDescriptor cameraDescriptor;
132#else
133 CameraDescriptor cameraDescriptor;
134#endif
135};
136
137} // namespace roboticslab
138
139#endif // __YARP_OPENRAVE_GRABBER_HPP__
Implements shared configuration functions.
Definition YarpOpenraveBase.hpp:32
Implements the YARP_dev IFrameGrabberImage, etc. interface class member functions.
Definition YarpOpenraveGrabber.hpp:39
The main, catch-all namespace for Robotics Lab UC3M.
Definition groups.dox:5