Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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  math::TPose3D eNosePoseOnTheRobot;//!< The pose of the sensors on the robot
52  std::vector<float> readingsVoltage;//!< The set of readings (in volts) from the array of sensors (size of "sensorTypes" is the same that the size of "readingsVoltage")
53 
54  /** The kind of sensors in the array (size of "sensorTypes" is the same 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  */
63  bool hasTemperature;//!< Must be true for "temperature" to contain a valid measurement
64  float temperature;//!< Sensed temperature in Celcius (valid if hasTemperature=true only)
65  bool isActive;//!< True if the input to this chamber/enose is poluted air, False if clean air
66  };
67 
68  /** One entry per e-nose on the robot */
69  std::vector<TObservationENose> m_readings;
70 
71  // See base class docs
72  void getSensorPose( mrpt::poses::CPose3D &out_sensorPose ) const MRPT_OVERRIDE;
73  void setSensorPose( const mrpt::poses::CPose3D &newSensorPose ) MRPT_OVERRIDE;
74  void getDescriptionAsText(std::ostream &o) const MRPT_OVERRIDE;
75 
76  /** Declares a class within "CObservationGasSensors" that represents a set of gas concentration readings from the modelation of a MOS gas sensor readings.
77  * This class provides the parameters and functions to simulate the inverse model of a MOS gas sensor.
78  *
79  * \sa CObservationGasSensors
80  */
82  {
83  public:
84  /** Constructor */
85  CMOSmodel();
86  ~CMOSmodel();
87 
88  /** @name MOS-model parameters
89  * @{ */
90  size_t winNoise_size; //!< The size of the mobile average window used to reduce noise on sensor reagings.
91  int decimate_value; //!< [useMOSmodel] The decimate frecuency applied after noise filtering
92 
93  float a_rise; //!< tau = a*AMPLITUDE +b (linear relationship)
94  float b_rise; //!< tau = a*AMPLITUDE +b (linear relationship)
95  float a_decay; //!< tau = a*AMPLITUDE +b (linear relationship)
96  float b_decay; //!< tau = a*AMPLITUDE +b (linear relationship)
97 
98  bool save_maplog; //!< If true save generated gas map as a log file
99 
100  /** @} */
101 
102  /** Obtain an estimation of the gas distribution based on raw sensor readings */
103  bool get_GasDistribution_estimation(
104  float &reading,
105  mrpt::system::TTimeStamp &timestamp );
106 
107  protected:
108 
109  /** The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1)
110  */
112  {
113  float reading; //!< Sensore reading
114  mrpt::system::TTimeStamp timestamp; //!< Timestamp of the observation
115  float tau; //!< tau value applied
116  float estimation; //!< The value estimated according to the MOXmodel
117  float reading_filtered; //!< Reading after smooth (noise averaging)
118  };
119 
120  TdataMap last_Obs, temporal_Obs; //!< The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1)
121  std::vector<TdataMap> m_antiNoise_window; //!< Vector to temporally store and averge readings to reduce noise
122  std::ofstream *m_debug_dump; //!< Ofstream to save to file option "save_maplog"
123  uint16_t decimate_count; //!< Decimate value for oversampled enose readings
124  double fixed_incT; //!< To force e-nose samples to have fixed time increments
125  bool first_incT; //!< To force e-nose samples to have fixed time increments
126  float min_reading; //!< Minimum reading value till the moment, used as approximation to baeline level
127  bool first_iteration; //!< To avoid the model estimation on first iteration
128 
129  /** Estimates the gas concentration based on readings and sensor model
130  */
131  void inverse_MOSmodeling (
132  const float &reading,
133  const mrpt::system::TTimeStamp &timestamp);
134 
135  /** Reduce noise by averaging with a mobile window of specific size (winNoise_size)
136  */
137  void noise_filtering (
138  const float &reading,
139  const mrpt::system::TTimeStamp &timestamp );
140 
141  /** Save the gas distribution estiamtion into a log file for offline representation
142  */
143  void save_log_map(
144  const mrpt::system::TTimeStamp &timestamp,
145  const float &reading,
146  const float &estimation,
147  const float &tau);
148 
149  }; //End of CMOSmodel class def.
150 
151  }; // End of class def.
153 
154  } // End of namespace
155 } // End of namespace
156 
157 #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)
unsigned __int16 uint16_t
Definition: rptypes.h:46
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
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.
#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'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.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018