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



Page generated by Doxygen 1.8.12 for MRPT 1.3.2 SVN: at Thu Nov 10 13:46:27 UTC 2016