Main MRPT website > C++ reference
MRPT logo
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-2014, 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/slam/CObservation.h>
14 #include <mrpt/poses/CPose3D.h>
15 #include <mrpt/poses/CPose2D.h>
16 
17 namespace mrpt
18 {
19 namespace slam
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  /** A general method to retrieve the sensor pose on the robot.
88  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
89  * \sa setSensorPose
90  */
91  void getSensorPose( CPose3D &out_sensorPose ) const;
92 
93 
94  /** A general method to change the sensor pose on the robot.
95  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
96  * \sa getSensorPose
97  */
98  void setSensorPose( const CPose3D &newSensorPose );
99 
100 
101  /** Declares a class within "CObservationGasSensors" that represents a set of gas concentration readings from the modelation of a MOS gas sensor readings.
102  * This class provides the parameters and functions to simulate the inverse model of a MOS gas sensor.
103  *
104  * \sa CObservationGasSensors
105  */
107  {
108 
109  public:
110  /** Constructor
111  */
112  CMOSmodel();
113  ~CMOSmodel();
114 
115  /** @name MOS-model parameters
116  * @{ */
117 
118  size_t winNoise_size; //!< The size of the mobile average window used to reduce noise on sensor reagings.
119  int decimate_value; //!< [useMOSmodel] The decimate frecuency applied after noise filtering
120 
121  float a_rise; //!< tau = a*AMPLITUDE +b (linear relationship)
122  float b_rise; //!< tau = a*AMPLITUDE +b (linear relationship)
123  float a_decay; //!< tau = a*AMPLITUDE +b (linear relationship)
124  float b_decay; //!< tau = a*AMPLITUDE +b (linear relationship)
125 
126  bool save_maplog; //!< If true save generated gas map as a log file
127 
128  /** @} */
129 
130  /** Obtain an estimation of the gas distribution based on raw sensor readings */
131  bool get_GasDistribution_estimation(
132  float &reading,
133  mrpt::system::TTimeStamp &timestamp );
134 
135  protected:
136 
137  /** The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1)
138  */
140  {
141  float reading; //!< Sensore reading
142  mrpt::system::TTimeStamp timestamp; //!< Timestamp of the observation
143  float tau; //!< tau value applied
144  float estimation; //!< The value estimated according to the MOXmodel
145  float reading_filtered; //!< Reading after smooth (noise averaging)
146  };
147 
148  TdataMap last_Obs, temporal_Obs; //!< The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1)
149  std::vector<TdataMap> m_antiNoise_window; //!< Vector to temporally store and averge readings to reduce noise
150  std::ofstream *m_debug_dump; //!< Ofstream to save to file option "save_maplog"
151  uint16_t decimate_count; //!< Decimate value for oversampled enose readings
152  double fixed_incT; //!< To force e-nose samples to have fixed time increments
153  bool first_incT; //!< To force e-nose samples to have fixed time increments
154  float min_reading; //!< Minimum reading value till the moment, used as approximation to baeline level
155  bool first_iteration; //!< To avoid the model estimation on first iteration
156 
157  /** Estimates the gas concentration based on readings and sensor model
158  */
159  void inverse_MOSmodeling (
160  const float &reading,
161  const mrpt::system::TTimeStamp &timestamp);
162 
163  /** Reduce noise by averaging with a mobile window of specific size (winNoise_size)
164  */
165  void noise_filtering (
166  const float &reading,
167  const mrpt::system::TTimeStamp &timestamp );
168 
169  /** Save the gas distribution estiamtion into a log file for offline representation
170  */
171  void save_log_map(
172  const mrpt::system::TTimeStamp &timestamp,
173  const float &reading,
174  const float &estimation,
175  const float &tau);
176 
177  }; //End of CMOSmodel class def.
178 
179  }; // End of class def.
181 
182 
183  } // End of namespace
184 } // End of namespace
185 
186 #endif
mrpt::system::TTimeStamp timestamp
Timestamp of the observation.
std::vector< TdataMap > m_antiNoise_window
Vector to temporally store and averge readings to reduce noise.
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:30
size_t winNoise_size
The size of the mobile average window used to reduce noise on sensor reagings.
std::vector< TObservationENose > m_readings
One entry per e-nose on the robot.
float min_reading
Minimum reading value till the moment, used as approximation to baeline level.
bool first_iteration
To avoid the model estimation on first iteration.
uint16_t decimate_count
Decimate value for oversampled enose readings.
float a_decay
tau = a*AMPLITUDE +b (linear relationship)
float a_rise
tau = a*AMPLITUDE +b (linear relationship)
The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmod...
bool isActive
True if the input to this chamber/enose is poluted air, False if clean air.
vector_int sensorTypes
The kind of sensors in the array (size of "sensorTypes" is the same that the size of "readingsVoltage...
float estimation
The value estimated according to the MOXmodel.
#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...
bool save_maplog
If true save generated gas map as a log file.
Declares a class that represents any robot's observation.
Definition: CObservation.h:52
bool first_incT
To force e-nose samples to have fixed time increments.
bool hasTemperature
Must be true for "temperature" to contain a valid measurement.
Declares a class within "CObservationGasSensors" that represents a set of gas concentration readings ...
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...
TdataMap temporal_Obs
The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmod...
std::ofstream * m_debug_dump
Ofstream to save to file option "save_maplog".
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:69
std::vector< int32_t > vector_int
std::vector< float > readingsVoltage
The set of readings (in volts) from the array of sensors (size of "sensorTypes" is the same that the ...
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
double fixed_incT
To force e-nose samples to have fixed time increments.
float temperature
Sensed temperature in Celcius (valid if hasTemperature=true only)
int decimate_value
[useMOSmodel] The decimate frecuency applied after noise filtering
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
float reading_filtered
Reading after smooth (noise averaging)
math::TPose3D eNosePoseOnTheRobot
The pose of the sensors on the robot.
float b_rise
tau = a*AMPLITUDE +b (linear relationship)
float b_decay
tau = a*AMPLITUDE +b (linear relationship)



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014