Ignition Rendering

API Reference

4.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 
143  public: float dataMaxVal = ignition::math::INF_D;
144 
146  public: float dataMinVal = -ignition::math::INF_D;
147 
149  // false if data outside of camera range is +/- inf
150  public: bool clamping = false;
151 
153  protected: double rayCountRatio = 0;
154 
156  protected: double rangeCountRatio = 0;
157 
159  protected: math::Angle vfov;
160 
162  protected: bool isHorizontal = true;
163 
165  protected: double minAngle = 0;
166 
168  protected: double maxAngle = 0;
169 
171  protected: double vMinAngle = 0;
172 
174  protected: double vMaxAngle = 0;
175 
177  protected: int hSamples = 0;
178 
180  protected: int vSamples = 0;
181 
183  protected: int hResolution = 1;
184 
186  protected: int vResolution = 1;
187 
189  protected: unsigned int channels = 1u;
190 
191  private: friend class OgreScene;
192  };
193 
195  template <class T>
197  {
198  }
199 
201  template <class T>
203  {
204  }
205 
207  template <class T>
208  const float *BaseGpuRays<T>::Data() const
209  {
210  return nullptr;
211  }
212 
214  template <class T>
215  void BaseGpuRays<T>::Copy(float *_dataDest)
216  {
217  // Unused
218  (void)_dataDest;
219  }
220 
222  template <class T>
223  void BaseGpuRays<T>::SetClamp(bool _enable)
224  {
225  this->clamping = _enable;
226 
227  if (this->clamping)
228  {
229  this->dataMinVal = this->NearClipPlane();
230  this->dataMaxVal = this->FarClipPlane();
231  }
232  else
233  {
234  this->dataMinVal = -ignition::math::INF_D;
235  this->dataMaxVal = ignition::math::INF_D;
236  }
237  }
238 
240  template <class T>
242 
243  {
244  return this->clamping;
245  }
246 
248  template <class T>
250  std::function<void(const float *, unsigned int, unsigned int,
251  unsigned int, const std::string &)>)
252  {
253  return nullptr;
254  }
255 
257  template <class T>
258  void BaseGpuRays<T>::SetIsHorizontal(const bool _horizontal)
259  {
260  this->isHorizontal = _horizontal;
261  }
262 
264  template <class T>
266  {
267  return this->isHorizontal;
268  }
269 
271  template <class T>
273  {
274  return this->rayCountRatio;
275  }
276 
278  template <class T>
279  void BaseGpuRays<T>::SetRayCountRatio(const double _rayCountRatio)
280  {
281  this->rayCountRatio = _rayCountRatio;
282  }
283 
285  template <class T>
287  {
288  return this->rangeCountRatio;
289  }
290 
292  template <class T>
294  {
295  return this->vfov;
296  }
297 
299  template <class T>
301  {
302  this->vfov = _vfov;
303  }
304 
305  template <class T>
308  {
309  return this->minAngle;
310  }
311 
312  template <class T>
314  void BaseGpuRays<T>::SetAngleMin(double _angle)
315  {
316  this->minAngle = _angle;
317  }
318 
319  template <class T>
322  {
323  return this->maxAngle;
324  }
325 
326  template <class T>
328  void BaseGpuRays<T>::SetAngleMax(double _angle)
329  {
330  this->maxAngle = _angle;
331  }
332 
333  template <class T>
336  {
337  return this->hSamples;
338  }
339 
340  template <class T>
342  void BaseGpuRays<T>::SetRayCount(int _samples)
343  {
344  this->hSamples = _samples;
345  }
346 
347  template <class T>
350  {
351  return this->RayCount() * this->hResolution;
352  }
353 
354  template <class T>
357  {
358  return this->vSamples;
359  }
360 
361  template <class T>
364  {
365  this->vSamples = _samples;
366  }
367 
368  template <class T>
371  {
372  return this->VerticalRayCount() * this->vResolution;
373  }
374 
375  template <class T>
378  {
379  return this->vMinAngle;
380  }
381 
382  template <class T>
384  void BaseGpuRays<T>::SetVerticalAngleMin(const double _angle)
385  {
386  this->vMinAngle = _angle;
387  }
388 
389  template <class T>
392  {
393  return this->vMaxAngle;
394  }
395 
396  template <class T>
398  void BaseGpuRays<T>::SetVerticalAngleMax(const double _angle)
399  {
400  this->vMaxAngle = _angle;
401  }
402 
403  template <class T>
405  unsigned int BaseGpuRays<T>::Channels() const
406  {
407  return this->channels;
408  }
409  }
410  }
411 }
412 #endif
Generate depth ray data.
Definition: GpuRays.hh:37
virtual math::Angle VFOV() const override
Get the vertical field-of-view.
Definition: BaseGpuRays.hh:293
virtual bool Clamp() const override
Get behaviour for data values outside of camera range.
Definition: BaseGpuRays.hh:241
virtual double RayCountRatio() const override
Get the ray count ratio (equivalent to aspect ratio)
Definition: BaseGpuRays.hh:272
virtual void SetVFOV(const math::Angle &_vfov)
Set the vertical fov.
Definition: BaseGpuRays.hh:300
Definition: BaseCamera.hh:43
BaseGpuRays()
Constructor.
Definition: BaseGpuRays.hh:196
virtual void SetAngleMin(double _angle) override
Set minimal horizontal angle value.
Definition: BaseGpuRays.hh:314
Definition: BaseGpuRays.hh:42
virtual int VerticalRangeCount() const override
Get vertical range count, i.e. ray count * vert resolution.
Definition: BaseGpuRays.hh:370
virtual ignition::math::Angle VerticalAngleMax() const override
Get maximal vertical angle value.
Definition: BaseGpuRays.hh:391
virtual void SetVerticalAngleMin(const double _angle) override
Set minimal vertical angle value.
Definition: BaseGpuRays.hh:384
virtual void SetVerticalRayCount(int _samples) override
Set vertical quantity of rays.
Definition: BaseGpuRays.hh:363
virtual void SetRayCount(int _samples) override
Set horizontal quantity of rays.
Definition: BaseGpuRays.hh:342
STL class.
virtual unsigned int Channels() const override
Get the number of channels used to store the ray data.
Definition: BaseGpuRays.hh:405
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:208
virtual int RayCount() const override
Get horizontal quantity of rays.
Definition: BaseGpuRays.hh:335
virtual void SetRayCountRatio(const double _rayCountRatio) override
Sets the ray count ratio (equivalent to aspect ratio)
Definition: BaseGpuRays.hh:279
virtual int RangeCount() const override
Get hoizontal range count, i.e. ray count * horz resolution.
Definition: BaseGpuRays.hh:349
virtual void SetClamp(bool _enable) override
Configure behaviour for data values outside of camera range.
Definition: BaseGpuRays.hh:223
virtual void SetIsHorizontal(const bool _horizontal) override
Set sensor horizontal or vertical.
Definition: BaseGpuRays.hh:258
virtual void SetAngleMax(double _angle) override
Set maximal horizontal angle value.
Definition: BaseGpuRays.hh:328
math::Angle vfov
Vertical field-of-view.
Definition: BaseGpuRays.hh:159
Definition: OgreScene.hh:39
virtual ignition::math::Angle AngleMin() const override
Get minimal horizontal angle value.
Definition: BaseGpuRays.hh:307
virtual double RangeCountRatio() const override
Get the ray count ratio (equivalent to aspect ratio)
Definition: BaseGpuRays.hh:286
static const double INF_D
virtual void SetVerticalAngleMax(const double _angle) override
Set maximal vertical angle value.
Definition: BaseGpuRays.hh:398
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:249
virtual int VerticalRayCount() const override
Get vertical quantity of rays.
Definition: BaseGpuRays.hh:356
virtual ignition::math::Angle AngleMax() const override
Get maximal horizontal angle value.
Definition: BaseGpuRays.hh:321
virtual void Copy(float *_data) override
Copy to the specified memory direction the gpu rays data.
Definition: BaseGpuRays.hh:215
virtual ignition::math::Angle VerticalAngleMin() const override
Get minimal vertical angle value.
Definition: BaseGpuRays.hh:377
virtual bool IsHorizontal() const override
Gets if sensor is horizontal.
Definition: BaseGpuRays.hh:265
virtual ~BaseGpuRays()
Destructor.
Definition: BaseGpuRays.hh:202