Main MRPT website > C++ reference
MRPT logo
CObservationGasSensors.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CObservationGasSensors_H
29 #define CObservationGasSensors_H
30 
32 #include <mrpt/slam/CObservation.h>
33 #include <mrpt/poses/CPose3D.h>
34 #include <mrpt/poses/CPose2D.h>
35 
36 namespace mrpt
37 {
38 namespace slam
39 {
40 
42 
43  /** Declares a class derived from "CObservation" that represents a set of readings from gas sensors.
44  *
45  * \sa CObservation
46  * \ingroup mrpt_obs_grp
47  */
49  {
50  // This must be added to any CSerializable derived class:
52 
53  public:
54  /** Constructor.
55  */
57 
58  /** The structure for each e-nose
59  */
61  {
62  TObservationENose() :
63  eNosePoseOnTheRobot(),
64  readingsVoltage(),
65  sensorTypes(),
66  hasTemperature(false),
67  temperature()
68  {}
69 
70  /** The pose of the sensors on the robot
71  */
73 
74  /** The set of readings (in volts) from the array of sensors (size of "sensorTypes" is the same that the size of "readingsVoltage")
75  */
76  std::vector<float> readingsVoltage;
77 
78  /** The kind of sensors in the array (size of "sensorTypes" is the same that the size of "readingsVoltage")
79  * The meaning of values for types of sensors is as follows:
80  * 0x0000 : No sensor installed in this slot
81  * 0x2600 : Figaro TGS 2600
82  * 0x2602 : Figaro TGS 2602
83  * 0x2620 : Figaro TGS 2620
84  * 0x4161 : Figaro TGS 4161
85  */
87 
88  /** Must be true for "temperature" to contain a valid measurement
89  */
91 
92  /** Sensed temperature in Celcius (valid if hasTemperature=true only)
93  */
94  float temperature;
95 
96  /** True if the input to this chamber/enose is poluted air, False if clean air
97  */
98  bool isActive;
99 
100  };
101 
102  /** One entry per e-nose on the robot.
103  */
104  std::vector<TObservationENose> m_readings;
105 
106  /** A general method to retrieve the sensor pose on the robot.
107  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
108  * \sa setSensorPose
109  */
110  void getSensorPose( CPose3D &out_sensorPose ) const;
111 
112 
113  /** A general method to change the sensor pose on the robot.
114  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
115  * \sa getSensorPose
116  */
117  void setSensorPose( const CPose3D &newSensorPose );
118 
119 
120  /** Declares a class within "CObservationGasSensors" that represents a set of gas concentration readings from the modelation of a MOS gas sensor readings.
121  * This class provides the parameters and functions to simulate the inverse model of a MOS gas sensor.
122  *
123  * \sa CObservationGasSensors
124  */
126  {
127 
128  public:
129  /** Constructor
130  */
131  CMOSmodel();
132  ~CMOSmodel();
133 
134  /** @name MOS-model parameters
135  * @{ */
136 
137  size_t winNoise_size; //!< The size of the mobile average window used to reduce noise on sensor reagings.
138  int decimate_value; //!< [useMOSmodel] The decimate frecuency applied after noise filtering
139 
140  float a_rise; //!< tau = a*AMPLITUDE +b (linear relationship)
141  float b_rise; //!< tau = a*AMPLITUDE +b (linear relationship)
142  float a_decay; //!< tau = a*AMPLITUDE +b (linear relationship)
143  float b_decay; //!< tau = a*AMPLITUDE +b (linear relationship)
144 
145  bool save_maplog; //!< If true save generated gas map as a log file
146 
147  /** @} */
148 
149  /** Obtain an estimation of the gas distribution based on raw sensor readings */
150  bool get_GasDistribution_estimation(
151  float &reading,
152  mrpt::system::TTimeStamp &timestamp );
153 
154  protected:
155 
156  /** The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1)
157  */
159  {
160  float reading; //!< Sensore reading
161  mrpt::system::TTimeStamp timestamp; //!< Timestamp of the observation
162  float tau; //!< tau value applied
163  float estimation; //!< The value estimated according to the MOXmodel
164  float reading_filtered; //!< Reading after smooth (noise averaging)
165  };
166 
167  TdataMap last_Obs, temporal_Obs; //!< The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1)
168  std::vector<TdataMap> m_antiNoise_window; //!< Vector to temporally store and averge readings to reduce noise
169  std::ofstream *m_debug_dump; //!< Ofstream to save to file option "save_maplog"
170  uint16_t decimate_count; //!< Decimate value for oversampled enose readings
171  double fixed_incT; //!< To force e-nose samples to have fixed time increments
172  bool first_incT; //!< To force e-nose samples to have fixed time increments
173  float min_reading; //!< Minimum reading value till the moment, used as approximation to baeline level
174  bool first_iteration; //!< To avoid the model estimation on first iteration
175 
176  /** Estimates the gas concentration based on readings and sensor model
177  */
178  void inverse_MOSmodeling (
179  const float &reading,
180  const mrpt::system::TTimeStamp &timestamp);
181 
182  /** Reduce noise by averaging with a mobile window of specific size (winNoise_size)
183  */
184  void noise_filtering (
185  const float &reading,
186  const mrpt::system::TTimeStamp &timestamp );
187 
188  /** Save the gas distribution estiamtion into a log file for offline representation
189  */
190  void save_log_map(
191  const mrpt::system::TTimeStamp &timestamp,
192  const float &reading,
193  const float &estimation,
194  const float &tau);
195 
196  }; //End of CMOSmodel class def.
197 
198  }; // End of class def.
199 
200 
201  } // End of namespace
202 } // End of namespace
203 
204 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013