Ignition Rendering

API Reference

5.1.0
BaseGpuRays.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef IGNITION_RENDERING_BASE_BASEGPURAYS_HH_
18 #define IGNITION_RENDERING_BASE_BASEGPURAYS_HH_
19 
20 #include <string>
21 
22 #include <ignition/common/Event.hh>
24 
33 
34 
35 namespace ignition
36 {
37  namespace rendering
38  {
39  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
40  //
41  template <class T>
42  class BaseGpuRays :
43  public virtual GpuRays,
44  public virtual BaseCamera<T>,
45  public virtual T
46  {
48  protected: BaseGpuRays();
49 
51  public: virtual ~BaseGpuRays();
52 
53  // Documentation inherited.
54  public: virtual const float *Data() const override;
55 
56  // Documentation inherited.
57  public: virtual void Copy(float *_data) override;
58 
59  // Documentation inherited.
60  public: virtual void SetClamp(bool _enable) override;
61 
62  // Documentation inherited.
63  public: virtual bool Clamp() const override;
64 
65  // Documentation inherited.
66  public: virtual common::ConnectionPtr ConnectNewGpuRaysFrame(
67  std::function<void(const float *_frame, unsigned int _width,
68  unsigned int _height, unsigned int _depth,
69  const std::string &_format)> _subscriber) override;
70 
72  public: virtual RenderTargetPtr RenderTarget() const override = 0;
73 
74  // Documentation inherited.
75  public: virtual void SetIsHorizontal(const bool _horizontal) override;
76 
77  // Documentation inherited.
78  public: virtual bool IsHorizontal() const override;
79 
82  public: virtual void SetVFOV(const math::Angle &_vfov);
83 
84  // Documentation inherited.
85  public: virtual math::Angle VFOV() const override;
86 
87  // Documentation inherited.
88  public: virtual double RayCountRatio() const override;
89 
90  // Documentation inherited.
91  public: virtual double RangeCountRatio() const override;
92 
93  // Documentation inherited.
94  public: virtual void SetRayCountRatio(
95  const double _rayCountRatio) override;
96 
97  // Documentation inherited.
98  public: virtual ignition::math::Angle AngleMin() const override;
99 
100  // Documentation inherited.
101  public: virtual void SetAngleMin(double _angle) override;
102 
103  // Documentation inherited.
104  public: virtual ignition::math::Angle AngleMax() const override;
105 
106  // Documentation inherited.
107  public: virtual void SetAngleMax(double _angle) override;
108 
109  // Documentation inherited.
110  public: virtual void SetVerticalRayCount(int _samples) override;
111 
112  // Documentation inherited.
113  public: virtual void SetRayCount(int _samples) override;
114 
115  // Documentation inherited.
116  public: virtual int RayCount() const override;
117 
118  // Documentation inherited.
119  public: virtual int RangeCount() const override;
120 
121  // Documentation inherited.
122  public: virtual int VerticalRayCount() const override;
123 
124  // Documentation inherited.
125  public: virtual int VerticalRangeCount() const override;
126 
127  // Documentation inherited.
128  public: virtual ignition::math::Angle VerticalAngleMin() const override;
129 
130  // Documentation inherited.
131  public: virtual void SetVerticalAngleMin(const double _angle) override;
132 
133  // Documentation inherited.
134  public: virtual ignition::math::Angle VerticalAngleMax() const override;
135 
136  // Documentation inherited.
137  public: virtual void SetVerticalAngleMax(const double _angle) override;
138 
139  // Documentation inherited.
140  public: virtual unsigned int Channels() const override;
141 
142  // Documentation inherited.
143  public: virtual void SetHorizontalResolution(double _resolution) override;
144 
145  // Documentation inherited.
146  public: virtual double HorizontalResolution() const override;
147 
148  // Documentation inherited.
149  public: virtual void SetVerticalResolution(double resolution) override;
150 
151  // Documentation inherited.
152  public: virtual double VerticalResolution() const override;
153 
155  public: float dataMaxVal = ignition::math::INF_D;
156 
158  public: float dataMinVal = -ignition::math::INF_D;
159 
161  // false if data outside of camera range is +/- inf
162  public: bool clamping = false;
163 
165  protected: double rayCountRatio = 0;
166 
168  protected: double rangeCountRatio = 0;
169 
171  protected: math::Angle vfov;
172 
174  protected: bool isHorizontal = true;
175 
177  protected: double minAngle = 0;
178 
180  protected: double maxAngle = 0;
181 
183  protected: double vMinAngle = 0;
184 
186  protected: double vMaxAngle = 0;
187 
189  protected: int hSamples = 0;
190 
192  protected: int vSamples = 0;
193 
195  protected: double hResolution = 1;
196 
198  protected: double vResolution = 1;
199 
201  protected: unsigned int channels = 1u;
202 
203  private: friend class OgreScene;
204  };
205 
207  template <class T>
209  {
210  }
211 
213  template <class T>
215  {
216  }
217 
219  template <class T>
220  const float *BaseGpuRays<T>::Data() const
221  {
222  return nullptr;
223  }
224 
226  template <class T>
227  void BaseGpuRays<T>::Copy(float *_dataDest)
228  {
229  // Unused
230  (void)_dataDest;
231  }
232 
234  template <class T>
235  void BaseGpuRays<T>::SetClamp(bool _enable)
236  {
237  this->clamping = _enable;
238 
239  if (this->clamping)
240  {
241  this->dataMinVal = this->NearClipPlane();
242  this->dataMaxVal = this->FarClipPlane();
243  }
244  else
245  {
246  this->dataMinVal = -ignition::math::INF_D;
247  this->dataMaxVal = ignition::math::INF_D;
248  }
249  }
250 
252  template <class T>
254 
255  {
256  return this->clamping;
257  }
258 
260  template <class T>
262  std::function<void(const float *, unsigned int, unsigned int,
263  unsigned int, const std::string &)>)
264  {
265  return nullptr;
266  }
267 
269  template <class T>
270  void BaseGpuRays<T>::SetIsHorizontal(const bool _horizontal)
271  {
272  this->isHorizontal = _horizontal;
273  }
274 
276  template <class T>
278  {
279  return this->isHorizontal;
280  }
281 
283  template <class T>
285  {
286  return this->rayCountRatio;
287  }
288 
290  template <class T>
291  void BaseGpuRays<T>::SetRayCountRatio(const double _rayCountRatio)
292  {
293  this->rayCountRatio = _rayCountRatio;
294  }
295 
297  template <class T>
299  {
300  return this->rangeCountRatio;
301  }
302 
304  template <class T>
306  {
307  return this->vfov;
308  }
309 
311  template <class T>
313  {
314  this->vfov = _vfov;
315  }
316 
317  template <class T>
320  {
321  return this->minAngle;
322  }
323 
324  template <class T>
326  void BaseGpuRays<T>::SetAngleMin(double _angle)
327  {
328  this->minAngle = _angle;
329  }
330 
331  template <class T>
334  {
335  return this->maxAngle;
336  }
337 
338  template <class T>
340  void BaseGpuRays<T>::SetAngleMax(double _angle)
341  {
342  this->maxAngle = _angle;
343  }
344 
345  template <class T>
348  {
349  return this->hSamples;
350  }
351 
352  template <class T>
354  void BaseGpuRays<T>::SetRayCount(int _samples)
355  {
356  this->hSamples = _samples;
357  }
358 
359  template <class T>
362  {
363  return static_cast<int>(this->RayCount() * this->hResolution);
364  }
365 
366  template <class T>
369  {
370  return this->vSamples;
371  }
372 
373  template <class T>
376  {
377  this->vSamples = _samples;
378  }
379 
380  template <class T>
383  {
384  return static_cast<int>(this->VerticalRayCount() * this->vResolution);
385  }
386 
387  template <class T>
390  {
391  return this->vMinAngle;
392  }
393 
394  template <class T>
396  void BaseGpuRays<T>::SetVerticalAngleMin(const double _angle)
397  {
398  this->vMinAngle = _angle;
399  }
400 
401  template <class T>
404  {
405  return this->vMaxAngle;
406  }
407 
408  template <class T>
410  void BaseGpuRays<T>::SetVerticalAngleMax(const double _angle)
411  {
412  this->vMaxAngle = _angle;
413  }
414 
415  template <class T>
417  unsigned int BaseGpuRays<T>::Channels() const
418  {
419  return this->channels;
420  }
421 
422  template <class T>
425  {
426  this->hResolution = std::abs(_resolution);
427  }
428 
429  template <class T>
432  {
433  return this->hResolution;
434  }
435 
436  template <class T>
438  void BaseGpuRays<T>::SetVerticalResolution(double _resolution)
439  {
440  this->vResolution = std::abs(_resolution);
441  }
442 
443  template <class T>
446  {
447  return this->vResolution;
448  }
449  }
450  }
451 }
452 #endif
Generate depth ray data.
Definition: GpuRays.hh:37
virtual math::Angle VFOV() const override
Get the vertical field-of-view.
Definition: BaseGpuRays.hh:305
virtual bool Clamp() const override
Get behaviour for data values outside of camera range.
Definition: BaseGpuRays.hh:253
virtual double RayCountRatio() const override
Get the ray count ratio (equivalent to aspect ratio)
Definition: BaseGpuRays.hh:284
virtual void SetVFOV(const math::Angle &_vfov)
Set the vertical fov.
Definition: BaseGpuRays.hh:312
Definition: BaseCamera.hh:44
BaseGpuRays()
Constructor.
Definition: BaseGpuRays.hh:208
virtual void SetAngleMin(double _angle) override
Set minimal horizontal angle value.
Definition: BaseGpuRays.hh:326
virtual void SetHorizontalResolution(double _resolution) override
Set the horizontal resolution. This number is multiplied by RayCount to calculate RangeCount...
Definition: BaseGpuRays.hh:424
virtual void SetVerticalResolution(double resolution) override
Set the vertical resolution. This number is multiplied by VerticalRayCount to calculate VerticalRange...
Definition: BaseGpuRays.hh:438
virtual double HorizontalResolution() const override
Get the horizontal resolution. This number is multiplied by RayCount to calculate RangeCount...
Definition: BaseGpuRays.hh:431
Definition: BaseGpuRays.hh:42
virtual int VerticalRangeCount() const override
Get vertical range count, i.e. ray count * vert resolution.
Definition: BaseGpuRays.hh:382
virtual ignition::math::Angle VerticalAngleMax() const override
Get maximal vertical angle value.
Definition: BaseGpuRays.hh:403
virtual void SetVerticalAngleMin(const double _angle) override
Set minimal vertical angle value.
Definition: BaseGpuRays.hh:396
virtual void SetVerticalRayCount(int _samples) override
Set vertical quantity of rays.
Definition: BaseGpuRays.hh:375
virtual void SetRayCount(int _samples) override
Set horizontal quantity of rays.
Definition: BaseGpuRays.hh:354
STL class.
virtual unsigned int Channels() const override
Get the number of channels used to store the ray data.
Definition: BaseGpuRays.hh:417
Represents a render-target to which cameras can render images.
Definition: RenderTarget.hh:37
virtual const float * Data() const override
All things needed to get back z buffer for gpu rays data.
Definition: BaseGpuRays.hh:220
virtual int RayCount() const override
Get horizontal quantity of rays.
Definition: BaseGpuRays.hh:347
virtual void SetRayCountRatio(const double _rayCountRatio) override
Sets the ray count ratio (equivalent to aspect ratio)
Definition: BaseGpuRays.hh:291
virtual int RangeCount() const override
Get hoizontal range count, i.e. ray count * horz resolution.
Definition: BaseGpuRays.hh:361
virtual void SetClamp(bool _enable) override
Configure behaviour for data values outside of camera range.
Definition: BaseGpuRays.hh:235
virtual void SetIsHorizontal(const bool _horizontal) override
Set sensor horizontal or vertical.
Definition: BaseGpuRays.hh:270
virtual void SetAngleMax(double _angle) override
Set maximal horizontal angle value.
Definition: BaseGpuRays.hh:340
math::Angle vfov
Vertical field-of-view.
Definition: BaseGpuRays.hh:171
Definition: OgreScene.hh:39
virtual ignition::math::Angle AngleMin() const override
Get minimal horizontal angle value.
Definition: BaseGpuRays.hh:319
virtual double RangeCountRatio() const override
Get the ray count ratio (equivalent to aspect ratio)
Definition: BaseGpuRays.hh:298
static const double INF_D
virtual void SetVerticalAngleMax(const double _angle) override
Set maximal vertical angle value.
Definition: BaseGpuRays.hh:410
virtual common::ConnectionPtr ConnectNewGpuRaysFrame(std::function< void(const float *_frame, unsigned int _width, unsigned int _height, unsigned int _depth, const std::string &_format)> _subscriber) override
Definition: BaseGpuRays.hh:261
virtual int VerticalRayCount() const override
Get vertical quantity of rays.
Definition: BaseGpuRays.hh:368
virtual ignition::math::Angle AngleMax() const override
Get maximal horizontal angle value.
Definition: BaseGpuRays.hh:333
virtual void Copy(float *_data) override
Copy to the specified memory direction the gpu rays data.
Definition: BaseGpuRays.hh:227
virtual double VerticalResolution() const override
Get the vertical resolution. This number is multiplied by VerticalRayCount to calculate VerticalRange...
Definition: BaseGpuRays.hh:445
virtual ignition::math::Angle VerticalAngleMin() const override
Get minimal vertical angle value.
Definition: BaseGpuRays.hh:389
virtual bool IsHorizontal() const override
Gets if sensor is horizontal.
Definition: BaseGpuRays.hh:277
virtual ~BaseGpuRays()
Destructor.
Definition: BaseGpuRays.hh:214