Gazebo Rendering

API Reference

6.6.3
gz/rendering/base/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 
25 namespace ignition
26 {
27  namespace rendering
28  {
29  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
30  //
31  /* \class BaseGaussianNoisePass BaseGaussianNoisePass.hh \
32  * ignition/rendering/base/BaseGaussianNoisePass.hh
33  */
35  template <class T>
37  public virtual GaussianNoisePass,
38  public virtual T
39  {
41  protected: BaseGaussianNoisePass();
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>
93  {
94  }
95 
97  template <class T>
99  {
100  }
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
double StdDev() const
Accessor for stddev.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:111
double biasStdDev
The standard deviation of the Gaussian distribution from which bias values are drawn.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:85
double Mean() const
Accessor for mean.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:104
void SetStdDev(double _stdDev)
Set stddev.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:132
A render pass that applies Gaussian noise to the render target.
Definition: gz/rendering/GaussianNoisePass.hh:35
double bias
Gaussian noise bias.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:77
void SampleBias()
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:155
BaseGaussianNoisePass()
Constructor.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:92
double stdDev
Standard deviation of Gaussian noise.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:74
virtual ~BaseGaussianNoisePass()
Destructor.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:98
Base Gaussian noise render pass.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:36
void SetBiasStdDev(double _biasStdDev)
Set the standard deviation of the bias value. Bias is computed based on the bias mean and bias standa...
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:147
double biasMean
The mean of the Gaussian distribution from which bias values are drawn.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:81
double mean
Gaussian noise mean.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:71
double Bias() const
Accessor for bias.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:118
void SetMean(double _mean)
Set mean.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:125
void SetBiasMean(double _biasMean)
Set the mean of the bias value. Bias is computed based on the bias mean and bias standard deviation.
Definition: gz/rendering/base/BaseGaussianNoisePass.hh:139
T mean(const std::vector< T > &_values)