Gazebo Rendering

API Reference

9.0.0
BaseGaussianNoisePass.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 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_BASEGAUSSIANNOISEPASS_HH_
18#define GZ_RENDERING_BASE_BASEGAUSSIANNOISEPASS_HH_
19
20#include <string>
21#include <gz/math/Rand.hh>
22
24
25namespace gz
26{
27 namespace rendering
28 {
29 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
30 //
31 /* \class BaseGaussianNoisePass BaseGaussianNoisePass.hh \
32 * gz/rendering/base/BaseGaussianNoisePass.hh
33 */
35 template <class T>
37 public virtual GaussianNoisePass,
38 public virtual T
39 {
42
44 public: virtual ~BaseGaussianNoisePass();
45
46 // Documentation inherited.
47 public: double Mean() const;
48
49 // Documentation inherited.
50 public: double StdDev() const;
51
52 // Documentation inherited.
53 public: double Bias() const;
54
55 // Documentation inherited.
56 public: void SetMean(double _mean);
57
58 // Documentation inherited.
59 public: void SetStdDev(double _stdDev);
60
61 // Documentation inherited.
62 public: void SetBiasMean(double _biasMean);
63
64 // Documentation inherited.
65 public: void SetBiasStdDev(double _biasStdDev);
66
67 // Sample the bias from bias mean and bias standard deviation
68 protected: void SampleBias();
69
71 protected: double mean = 0.0;
72
74 protected: double stdDev = 0.0;
75
77 protected: double bias = 0.0;
78
81 protected: double biasMean = 0;
82
85 protected: double biasStdDev = 0;
86 };
87
89 // BaseGaussianNoisePass
91 template <class T>
95
97 template <class T>
101
103 template <class T>
105 {
106 return this->mean;
107 }
108
110 template <class T>
112 {
113 return this->stdDev;
114 }
115
117 template <class T>
119 {
120 return this->bias;
121 }
122
124 template <class T>
126 {
127 this->mean = _mean;
128 }
129
131 template <class T>
133 {
134 this->stdDev = _stdDev;
135 }
136
138 template <class T>
140 {
141 this->biasMean = _biasMean;
142 this->SampleBias();
143 }
144
146 template <class T>
148 {
149 this->biasStdDev = _biasStdDev;
150 this->SampleBias();
151 }
152
154 template <class T>
156 {
157 this->bias =
158 gz::math::Rand::DblNormal(this->biasMean, this->biasStdDev);
159 // With equal probability, we pick a negative bias (by convention,
160 // rateBiasMean should be positive, though it would work fine if
161 // negative).
162 if (gz::math::Rand::DblUniform() < 0.5)
163 this->bias = -this->bias;
164 }
165 }
166 }
167}
168#endif