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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST