Gazebo Rendering

API Reference

6.6.3
gz/rendering/base/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 GZ_RENDERING_BASE_BASEGPURAYS_HH_
18 #define GZ_RENDERING_BASE_BASEGPURAYS_HH_
19 
20 #include <string>
21 
22 #include <gz/common/Event.hh>
23 #include <gz/common/Console.hh>
24 
25 #include "gz/rendering/GpuRays.hh"
26 #include "gz/rendering/Image.hh"
28 #include "gz/rendering/Scene.hh"
31 #include "gz/rendering/Visual.hh"
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 gz::math::Angle AngleMin() const override;
99 
100  // Documentation inherited.
101  public: virtual void SetAngleMin(double _angle) override;
102 
103  // Documentation inherited.
104  public: virtual gz::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 gz::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 gz::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 = gz::math::INF_D;
156 
158  public: float dataMinVal = -gz::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 = -gz::math::INF_D;
247  this->dataMaxVal = gz::math::INF_D;
248  }
249  }
250 
252  template <class T>
254 
255  {
256  return this->clamping;
257  }
258 
260  template <class T>
261  gz::common::ConnectionPtr BaseGpuRays<T>::ConnectNewGpuRaysFrame(
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>
319  gz::math::Angle BaseGpuRays<T>::AngleMin() const
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>
333  gz::math::Angle BaseGpuRays<T>::AngleMax() const
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>
389  gz::math::Angle BaseGpuRays<T>::VerticalAngleMin() const
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>
403  gz::math::Angle BaseGpuRays<T>::VerticalAngleMax() const
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
virtual gz::math::Angle VerticalAngleMax() const override
Get maximal vertical angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:403
virtual void SetAngleMin(double _angle) override
Set minimal horizontal angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:326
float dataMinVal
minimum value used for data outside sensor range
Definition: gz/rendering/base/BaseGpuRays.hh:158
virtual void SetHorizontalResolution(double _resolution) override
Set the horizontal resolution. This number is multiplied by RayCount to calculate RangeCount,...
Definition: gz/rendering/base/BaseGpuRays.hh:424
virtual void SetVerticalAngleMax(const double _angle) override
Set maximal vertical angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:410
virtual double HorizontalResolution() const override
Get the horizontal resolution. This number is multiplied by RayCount to calculate RangeCount,...
Definition: gz/rendering/base/BaseGpuRays.hh:431
double maxAngle
Horizontal maximal angle.
Definition: gz/rendering/base/BaseGpuRays.hh:180
STL class.
STL class.
virtual int VerticalRayCount() const override
Get vertical quantity of rays.
Definition: gz/rendering/base/BaseGpuRays.hh:368
virtual void Copy(float *_data) override
Copy to the specified memory direction the gpu rays data.
Definition: gz/rendering/base/BaseGpuRays.hh:227
Definition: gz/rendering/ogre/OgreScene.hh:39
virtual bool IsHorizontal() const override
Gets if sensor is horizontal.
Definition: gz/rendering/base/BaseGpuRays.hh:277
virtual gz::math::Angle AngleMax() const override
Get maximal horizontal angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:333
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: gz/rendering/base/BaseGpuRays.hh:261
virtual ~BaseGpuRays()
Destructor.
Definition: gz/rendering/base/BaseGpuRays.hh:214
unsigned int channels
Number of channels used to store the data.
Definition: gz/rendering/base/BaseGpuRays.hh:201
virtual void SetVerticalRayCount(int _samples) override
Set vertical quantity of rays.
Definition: gz/rendering/base/BaseGpuRays.hh:375
double hResolution
Resolution of horizontal rays.
Definition: gz/rendering/base/BaseGpuRays.hh:195
int hSamples
Quantity of horizontal rays.
Definition: gz/rendering/base/BaseGpuRays.hh:189
virtual const float * Data() const override
All things needed to get back z buffer for gpu rays data.
Definition: gz/rendering/base/BaseGpuRays.hh:220
virtual double RayCountRatio() const override
Get the ray count ratio (equivalent to aspect ratio)
Definition: gz/rendering/base/BaseGpuRays.hh:284
virtual bool Clamp() const override
Get behaviour for data values outside of camera range.
Definition: gz/rendering/base/BaseGpuRays.hh:253
double vResolution
Resolution of vertical rays.
Definition: gz/rendering/base/BaseGpuRays.hh:198
double vMinAngle
Vertical minimal angle.
Definition: gz/rendering/base/BaseGpuRays.hh:183
virtual void SetVerticalResolution(double resolution) override
Set the vertical resolution. This number is multiplied by VerticalRayCount to calculate VerticalRange...
Definition: gz/rendering/base/BaseGpuRays.hh:438
virtual void SetRayCountRatio(const double _rayCountRatio) override
Sets the ray count ratio (equivalent to aspect ratio)
Definition: gz/rendering/base/BaseGpuRays.hh:291
Definition: gz/rendering/base/BaseGpuRays.hh:42
virtual gz::math::Angle VerticalAngleMin() const override
Get minimal vertical angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:389
virtual int VerticalRangeCount() const override
Get vertical range count, i.e. ray count * vert resolution.
Definition: gz/rendering/base/BaseGpuRays.hh:382
virtual RenderTargetPtr RenderTarget() const override=0
Pointer to the render target.
virtual void SetAngleMax(double _angle) override
Set maximal horizontal angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:340
virtual void SetClamp(bool _enable) override
Configure behaviour for data values outside of camera range.
Definition: gz/rendering/base/BaseGpuRays.hh:235
virtual void SetIsHorizontal(const bool _horizontal) override
Set sensor horizontal or vertical.
Definition: gz/rendering/base/BaseGpuRays.hh:270
float dataMaxVal
maximum value used for data outside sensor range
Definition: gz/rendering/base/BaseGpuRays.hh:155
virtual void SetVerticalAngleMin(const double _angle) override
Set minimal vertical angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:396
int vSamples
Quantity of verical rays.
Definition: gz/rendering/base/BaseGpuRays.hh:192
Represents a render-target to which cameras can render images.
Definition: gz/rendering/RenderTarget.hh:37
virtual void SetRayCount(int _samples) override
Set horizontal quantity of rays.
Definition: gz/rendering/base/BaseGpuRays.hh:354
double rayCountRatio
Ray count ratio.
Definition: gz/rendering/base/BaseGpuRays.hh:165
double minAngle
Horizontal minimal angle.
Definition: gz/rendering/base/BaseGpuRays.hh:177
double rangeCountRatio
Range count ratio.
Definition: gz/rendering/base/BaseGpuRays.hh:168
Generate depth ray data.
Definition: gz/rendering/GpuRays.hh:37
double vMaxAngle
Vertical maximal angle.
Definition: gz/rendering/base/BaseGpuRays.hh:186
virtual unsigned int Channels() const override
Get the number of channels used to store the ray data.
Definition: gz/rendering/base/BaseGpuRays.hh:417
virtual double RangeCountRatio() const override
Get the ray count ratio (equivalent to aspect ratio)
Definition: gz/rendering/base/BaseGpuRays.hh:298
virtual int RayCount() const override
Get horizontal quantity of rays.
Definition: gz/rendering/base/BaseGpuRays.hh:347
virtual int RangeCount() const override
Get hoizontal range count, i.e. ray count * horz resolution.
Definition: gz/rendering/base/BaseGpuRays.hh:361
virtual double VerticalResolution() const override
Get the vertical resolution. This number is multiplied by VerticalRayCount to calculate VerticalRange...
Definition: gz/rendering/base/BaseGpuRays.hh:445
Definition: gz/rendering/base/BaseCamera.hh:44
virtual math::Angle VFOV() const override
Get the vertical field-of-view.
Definition: gz/rendering/base/BaseGpuRays.hh:305
bool isHorizontal
True if the sensor is horizontal only.
Definition: gz/rendering/base/BaseGpuRays.hh:174
bool clamping
True if data values are clamped to camera clip distances,.
Definition: gz/rendering/base/BaseGpuRays.hh:162
math::Angle vfov
Vertical field-of-view.
Definition: gz/rendering/base/BaseGpuRays.hh:171
virtual void SetVFOV(const math::Angle &_vfov)
Set the vertical fov.
Definition: gz/rendering/base/BaseGpuRays.hh:312
BaseGpuRays()
Constructor.
Definition: gz/rendering/base/BaseGpuRays.hh:208
virtual gz::math::Angle AngleMin() const override
Get minimal horizontal angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:319