Gazebo Rendering

API Reference

3.7.2
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 
143  public: float dataMaxVal = gz::math::INF_D;
144 
146  public: float dataMinVal = -gz::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 = -gz::math::INF_D;
235  this->dataMaxVal = gz::math::INF_D;
236  }
237  }
238 
240  template <class T>
242 
243  {
244  return this->clamping;
245  }
246 
248  template <class T>
249  gz::common::ConnectionPtr BaseGpuRays<T>::ConnectNewGpuRaysFrame(
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>
307  gz::math::Angle BaseGpuRays<T>::AngleMin() const
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>
321  gz::math::Angle BaseGpuRays<T>::AngleMax() const
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>
377  gz::math::Angle BaseGpuRays<T>::VerticalAngleMin() const
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>
391  gz::math::Angle BaseGpuRays<T>::VerticalAngleMax() const
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
virtual gz::math::Angle VerticalAngleMax() const override
Get maximal vertical angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:391
virtual void SetAngleMin(double _angle) override
Set minimal horizontal angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:314
float dataMinVal
minimum value used for data outside sensor range
Definition: gz/rendering/base/BaseGpuRays.hh:146
virtual void SetVerticalAngleMax(const double _angle) override
Set maximal vertical angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:398
double maxAngle
Horizontal maximal angle.
Definition: gz/rendering/base/BaseGpuRays.hh:168
STL class.
STL class.
virtual int VerticalRayCount() const override
Get vertical quantity of rays.
Definition: gz/rendering/base/BaseGpuRays.hh:356
virtual void Copy(float *_data) override
Copy to the specified memory direction the gpu rays data.
Definition: gz/rendering/base/BaseGpuRays.hh:215
Definition: gz/rendering/ogre/OgreScene.hh:39
virtual bool IsHorizontal() const override
Gets if sensor is horizontal.
Definition: gz/rendering/base/BaseGpuRays.hh:265
virtual gz::math::Angle AngleMax() const override
Get maximal horizontal angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:321
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:249
virtual ~BaseGpuRays()
Destructor.
Definition: gz/rendering/base/BaseGpuRays.hh:202
unsigned int channels
Number of channels used to store the data.
Definition: gz/rendering/base/BaseGpuRays.hh:189
virtual void SetVerticalRayCount(int _samples) override
Set vertical quantity of rays.
Definition: gz/rendering/base/BaseGpuRays.hh:363
int hSamples
Quantity of horizontal rays.
Definition: gz/rendering/base/BaseGpuRays.hh:177
virtual const float * Data() const override
All things needed to get back z buffer for gpu rays data.
Definition: gz/rendering/base/BaseGpuRays.hh:208
virtual double RayCountRatio() const override
Get the ray count ratio (equivalent to aspect ratio)
Definition: gz/rendering/base/BaseGpuRays.hh:272
virtual bool Clamp() const override
Get behaviour for data values outside of camera range.
Definition: gz/rendering/base/BaseGpuRays.hh:241
double vMinAngle
Vertical minimal angle.
Definition: gz/rendering/base/BaseGpuRays.hh:171
virtual void SetRayCountRatio(const double _rayCountRatio) override
Sets the ray count ratio (equivalent to aspect ratio)
Definition: gz/rendering/base/BaseGpuRays.hh:279
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:377
int hResolution
Resolution of horizontal rays.
Definition: gz/rendering/base/BaseGpuRays.hh:183
virtual int VerticalRangeCount() const override
Get vertical range count, i.e. ray count * vert resolution.
Definition: gz/rendering/base/BaseGpuRays.hh:370
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:328
virtual void SetClamp(bool _enable) override
Configure behaviour for data values outside of camera range.
Definition: gz/rendering/base/BaseGpuRays.hh:223
virtual void SetIsHorizontal(const bool _horizontal) override
Set sensor horizontal or vertical.
Definition: gz/rendering/base/BaseGpuRays.hh:258
float dataMaxVal
maximum value used for data outside sensor range
Definition: gz/rendering/base/BaseGpuRays.hh:143
virtual void SetVerticalAngleMin(const double _angle) override
Set minimal vertical angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:384
int vSamples
Quantity of verical rays.
Definition: gz/rendering/base/BaseGpuRays.hh:180
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:342
double rayCountRatio
Ray count ratio.
Definition: gz/rendering/base/BaseGpuRays.hh:153
double minAngle
Horizontal minimal angle.
Definition: gz/rendering/base/BaseGpuRays.hh:165
double rangeCountRatio
Range count ratio.
Definition: gz/rendering/base/BaseGpuRays.hh:156
Generate depth ray data.
Definition: gz/rendering/GpuRays.hh:37
double vMaxAngle
Vertical maximal angle.
Definition: gz/rendering/base/BaseGpuRays.hh:174
virtual unsigned int Channels() const override
Get the number of channels used to store the ray data.
Definition: gz/rendering/base/BaseGpuRays.hh:405
virtual double RangeCountRatio() const override
Get the ray count ratio (equivalent to aspect ratio)
Definition: gz/rendering/base/BaseGpuRays.hh:286
virtual int RayCount() const override
Get horizontal quantity of rays.
Definition: gz/rendering/base/BaseGpuRays.hh:335
virtual int RangeCount() const override
Get hoizontal range count, i.e. ray count * horz resolution.
Definition: gz/rendering/base/BaseGpuRays.hh:349
int vResolution
Resolution of vertical rays.
Definition: gz/rendering/base/BaseGpuRays.hh:186
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:293
bool isHorizontal
True if the sensor is horizontal only.
Definition: gz/rendering/base/BaseGpuRays.hh:162
bool clamping
True if data values are clamped to camera clip distances,.
Definition: gz/rendering/base/BaseGpuRays.hh:150
math::Angle vfov
Vertical field-of-view.
Definition: gz/rendering/base/BaseGpuRays.hh:159
virtual void SetVFOV(const math::Angle &_vfov)
Set the vertical fov.
Definition: gz/rendering/base/BaseGpuRays.hh:300
BaseGpuRays()
Constructor.
Definition: gz/rendering/base/BaseGpuRays.hh:196
virtual gz::math::Angle AngleMin() const override
Get minimal horizontal angle value.
Definition: gz/rendering/base/BaseGpuRays.hh:307