Gazebo Sensors

API Reference

6.8.1
gz/sensors/Noise.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 
18 #ifndef GZ_SENSORS_NOISE_HH_
19 #define GZ_SENSORS_NOISE_HH_
20 
21 #include <functional>
22 #include <string>
23 #include <vector>
24 
25 #include <gz/sensors/config.hh>
27 #include <gz/sensors/Export.hh>
28 
29 #include <sdf/sdf.hh>
30 
31 namespace ignition
32 {
33  namespace sensors
34  {
35  // Inline bracket to help doxygen filtering.
36  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
37  // Forward declarations
38  class NoisePrivate;
39 
42  class IGNITION_SENSORS_VISIBLE NoiseFactory
43  {
51  public: static NoisePtr NewNoiseModel(sdf::ElementPtr _sdf,
52  const std::string &_sensorType = "");
53 
61  public: static NoisePtr NewNoiseModel(const sdf::Noise &_sdf,
62  const std::string &_sensorType = "");
63  };
64 
66  enum class IGNITION_SENSORS_VISIBLE NoiseType : int
67  {
68  NONE = 0,
69  CUSTOM = 1,
70  GAUSSIAN = 2
71  };
72 
75  class IGNITION_SENSORS_VISIBLE Noise
76  {
82  public: explicit Noise(NoiseType _type);
83 
85  public: virtual ~Noise();
86 
89  public: virtual void Load(const sdf::Noise &_sdf);
90 
95  public: double Apply(double _in, double _dt = 0.0);
96 
102  public: virtual double ApplyImpl(double _in, double _dt);
103 
106  public: NoiseType Type() const;
107 
112  public: virtual void SetCustomNoiseCallback(
113  std::function<double(double, double)> _cb);
114 
117  public: virtual void Print(std::ostream &_out) const;
118 
120  private: NoisePrivate *dataPtr = nullptr;
121  };
122  }
123  }
124 }
125 #endif
Definition: gz/sensors/AirPressureSensor.hh:31
STL class.
virtual void SetCustomNoiseCallback(std::function< double(double, double)> _cb)
Register a custom noise callback.
STL class.
Noise models for sensor output signals.
Definition: gz/sensors/Noise.hh:75
Noise(NoiseType _type)
Constructor. This should not be called directly unless creating an empty noise model....
NoiseType
Which noise types we support.
Definition: gz/sensors/Noise.hh:66
Use this noise manager for creating and loading noise models.
Definition: gz/sensors/Noise.hh:42
static NoisePtr NewNoiseModel(sdf::ElementPtr _sdf, const std::string &_sensorType="")
Load a noise model based on the input sdf parameters and sensor type.
STL class.
virtual void Load(const sdf::Noise &_sdf)
Load noise parameters from sdf.
NoiseType Type() const
Accessor for NoiseType.
double Apply(double _in, double _dt=0.0)
Apply noise to input data value.
virtual double ApplyImpl(double _in, double _dt)
Apply noise to input data value. This gets overriden by derived classes, and called by Apply.
Forward declarations and typedefs for sensors.
virtual ~Noise()
Destructor.
virtual void Print(std::ostream &_out) const
Output information about the noise model.