MRPT  2.0.4
CObservationGasSensors.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/obs/CObservation.h>
12 #include <mrpt/poses/CPose2D.h>
13 #include <mrpt/poses/CPose3D.h>
15 
16 namespace mrpt::obs
17 {
18 /** Declares a class derived from "CObservation" that represents a set of
19  * readings from gas sensors.
20  *
21  * \sa CObservation
22  * \ingroup mrpt_obs_grp
23  */
25 {
27 
28  public:
29  /** Constructor.
30  */
32 
33  /** The structure for each e-nose
34  */
36  {
39  {
40  }
41 
42  /** The pose of the sensors on the robot */
44  /** The set of readings (in volts) from the array of sensors (size of
45  * "sensorTypes" is the same that the size of "readingsVoltage") */
46  std::vector<float> readingsVoltage;
47 
48  /** The kind of sensors in the array (size of "sensorTypes" is the same
49  *that the size of "readingsVoltage")
50  * The meaning of values for types of sensors is as follows:
51  * 0x0000 : No sensor installed in this slot
52  * 0x2600 : Figaro TGS 2600
53  * 0x2602 : Figaro TGS 2602
54  * 0x2620 : Figaro TGS 2620
55  * 0x4161 : Figaro TGS 4161
56  */
57  std::vector<int> sensorTypes;
58  /** Must be true for "temperature" to contain a valid measurement */
59  bool hasTemperature{false};
60  /** Sensed temperature in Celcius (valid if hasTemperature=true only) */
61  float temperature{0};
62  /** True if the input to this chamber/enose is poluted air, False if
63  * clean air */
64  bool isActive;
65  };
66 
67  /** One entry per e-nose on the robot */
68  std::vector<TObservationENose> m_readings;
69 
70  // See base class docs
71  void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const override;
72  void setSensorPose(const mrpt::poses::CPose3D& newSensorPose) override;
73  void getDescriptionAsText(std::ostream& o) const override;
74 
75  /** Declares a class within "CObservationGasSensors" that represents a set
76  * of gas concentration readings from the modelation of a MOS gas sensor
77  * readings.
78  * This class provides the parameters and functions to simulate the inverse
79  * model of a MOS gas sensor.
80  *
81  * \sa CObservationGasSensors
82  */
83  class CMOSmodel
84  {
85  public:
86  /** @name MOS-model parameters
87  * @{ */
88  /** The size of the mobile average window used to reduce noise on sensor
89  * reagings. */
90  size_t winNoise_size{30};
91  /** [useMOSmodel] The decimate frecuency applied after noise filtering
92  */
94 
95  /** tau = a*AMPLITUDE +b (linear relationship) */
96  float a_rise{0};
97  /** tau = a*AMPLITUDE +b (linear relationship) */
98  float b_rise{0};
99  /** tau = a*AMPLITUDE +b (linear relationship) */
100  float a_decay{0};
101  /** tau = a*AMPLITUDE +b (linear relationship) */
102  float b_decay{0};
103 
104  /** If true save generated gas map as a log file */
105  bool save_maplog{false};
106 
107  /** @} */
108 
109  /** Obtain an estimation of the gas distribution based on raw sensor
110  * readings */
112  float& reading, mrpt::system::TTimeStamp& timestamp);
113 
114  protected:
115  /** The content of each m_lastObservations in the estimation when using
116  * the option : MOS_MODEl (useMOSmodel =1)
117  */
118  struct TdataMap
119  {
120  /** Sensore reading */
121  float reading;
122  /** Timestamp of the observation */
124  /** tau value applied */
125  float tau;
126  /** The value estimated according to the MOXmodel */
127  float estimation;
128  /** Reading after smooth (noise averaging) */
130  };
131 
132  /** The content of each m_lastObservations in the estimation when using
133  * the option : MOS_MODEl (useMOSmodel =1) */
135  /** Vector to temporally store and averge readings to reduce noise */
136  std::vector<TdataMap> m_antiNoise_window;
137  /** Ofstream to save to file option "save_maplog" */
138  std::ofstream* m_debug_dump{nullptr};
139  /** Decimate value for oversampled enose readings */
140  uint16_t decimate_count{1};
141  /** To force e-nose samples to have fixed time increments */
142  double fixed_incT{0};
143  /** To force e-nose samples to have fixed time increments */
144  bool first_incT{true};
145  /** Minimum reading value till the moment, used as approximation to
146  * baeline level */
147  float min_reading{10};
148  /** To avoid the model estimation on first iteration */
149  bool first_iteration{true};
150 
151  /** Estimates the gas concentration based on readings and sensor model
152  */
153  void inverse_MOSmodeling(
154  float reading, const mrpt::system::TTimeStamp& timestamp);
155 
156  /** Reduce noise by averaging with a mobile window of specific size
157  * (winNoise_size)
158  */
159  void noise_filtering(
160  float reading, const mrpt::system::TTimeStamp& timestamp);
161 
162  /** Save the gas distribution estiamtion into a log file for offline
163  * representation
164  */
165  void save_log_map(
166  const mrpt::system::TTimeStamp& timestamp, float reading,
167  float estimation, float tau);
168 
169  }; // End of CMOSmodel class def.
170 
171 }; // End of class def.
172 
173 } // namespace mrpt::obs
float b_rise
tau = a*AMPLITUDE +b (linear relationship)
float temperature
Sensed temperature in Celcius (valid if hasTemperature=true only)
size_t winNoise_size
The size of the mobile average window used to reduce noise on sensor reagings.
double fixed_incT
To force e-nose samples to have fixed time increments.
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
std::vector< TdataMap > m_antiNoise_window
Vector to temporally store and averge readings to reduce noise.
float min_reading
Minimum reading value till the moment, used as approximation to baeline level.
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
math::TPose3D eNosePoseOnTheRobot
The pose of the sensors on the robot.
std::vector< int > sensorTypes
The kind of sensors in the array (size of "sensorTypes" is the same that the size of "readingsVoltage...
void save_log_map(const mrpt::system::TTimeStamp &timestamp, float reading, float estimation, float tau)
Save the gas distribution estiamtion into a log file for offline representation.
bool hasTemperature
Must be true for "temperature" to contain a valid measurement.
This namespace contains representation of robot actions and observations.
TdataMap last_Obs
The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmod...
Declares a class within "CObservationGasSensors" that represents a set of gas concentration readings ...
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
bool first_iteration
To avoid the model estimation on first iteration.
float estimation
The value estimated according to the MOXmodel.
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
float a_decay
tau = a*AMPLITUDE +b (linear relationship)
bool isActive
True if the input to this chamber/enose is poluted air, False if clean air.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
Definition: CObservation.h:60
bool first_incT
To force e-nose samples to have fixed time increments.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
bool save_maplog
If true save generated gas map as a log file.
The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmod...
std::vector< TObservationENose > m_readings
One entry per e-nose on the robot.
int decimate_value
[useMOSmodel] The decimate frecuency applied after noise filtering
void noise_filtering(float reading, const mrpt::system::TTimeStamp &timestamp)
Reduce noise by averaging with a mobile window of specific size (winNoise_size)
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:24
mrpt::system::TTimeStamp timestamp
Timestamp of the observation.
void inverse_MOSmodeling(float reading, const mrpt::system::TTimeStamp &timestamp)
Estimates the gas concentration based on readings and sensor model.
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
std::vector< float > readingsVoltage
The set of readings (in volts) from the array of sensors (size of "sensorTypes" is the same that the ...
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
float b_decay
tau = a*AMPLITUDE +b (linear relationship)
std::ofstream * m_debug_dump
Ofstream to save to file option "save_maplog".
float reading_filtered
Reading after smooth (noise averaging)
float a_rise
tau = a*AMPLITUDE +b (linear relationship)
uint16_t decimate_count
Decimate value for oversampled enose readings.
bool get_GasDistribution_estimation(float &reading, mrpt::system::TTimeStamp &timestamp)
Obtain an estimation of the gas distribution based on raw sensor readings.



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020