Gazebo Rendering
API Reference
9.0.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-rendering
include
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
"
27
#include "
gz/rendering/RenderEngine.hh
"
28
#include "
gz/rendering/Scene.hh
"
29
#include "
gz/rendering/base/BaseRenderTarget.hh
"
30
#include "
gz/rendering/base/BaseCamera.hh
"
31
#include "
gz/rendering/Visual.hh
"
32
#include "
gz/rendering/RenderTypes.hh
"
33
34
35
namespace
gz
36
{
37
namespace
rendering
38
{
39
inline
namespace
GZ_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>
208
BaseGpuRays<T>::BaseGpuRays
()
209
{
210
}
211
213
template
<
class
T>
214
BaseGpuRays<T>::~BaseGpuRays
()
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>
253
bool
BaseGpuRays<T>::Clamp
()
const
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>
277
bool
BaseGpuRays<T>::IsHorizontal
()
const
278
{
279
return
this->isHorizontal;
280
}
281
283
template
<
class
T>
284
double
BaseGpuRays<T>::RayCountRatio
()
const
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>
298
double
BaseGpuRays<T>::RangeCountRatio
()
const
299
{
300
return
this->rangeCountRatio;
301
}
302
304
template
<
class
T>
305
math::Angle
BaseGpuRays<T>::VFOV
()
const
306
{
307
return
this->vfov;
308
}
309
311
template
<
class
T>
312
void
BaseGpuRays<T>::SetVFOV
(
const
math::Angle
&_vfov)
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>
347
int
BaseGpuRays<T>::RayCount
()
const
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>
361
int
BaseGpuRays<T>::RangeCount
()
const
362
{
363
return
static_cast<
int
>
(this->RayCount() * this->hResolution);
364
}
365
366
template
<
class
T>
368
int
BaseGpuRays<T>::VerticalRayCount
()
const
369
{
370
return
this->vSamples;
371
}
372
373
template
<
class
T>
375
void
BaseGpuRays<T>::SetVerticalRayCount
(
int
_samples)
376
{
377
this->vSamples = _samples;
378
}
379
380
template
<
class
T>
382
int
BaseGpuRays<T>::VerticalRangeCount
()
const
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>
424
void
BaseGpuRays<T>::SetHorizontalResolution
(
double
_resolution)
425
{
426
this->hResolution =
std::abs
(_resolution);
427
}
428
429
template
<
class
T>
431
double
BaseGpuRays<T>::HorizontalResolution
()
const
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>
445
double
BaseGpuRays<T>::VerticalResolution
()
const
446
{
447
return
this->vResolution;
448
}
449
}
450
}
451
}
452
#endif