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