00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef CObservationGasSensors_H 00029 #define CObservationGasSensors_H 00030 00031 #include <mrpt/utils/CSerializable.h> 00032 #include <mrpt/slam/CObservation.h> 00033 #include <mrpt/poses/CPose3D.h> 00034 #include <mrpt/poses/CPose2D.h> 00035 00036 namespace mrpt 00037 { 00038 namespace slam 00039 { 00040 00041 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CObservationGasSensors , CObservation, OBS_IMPEXP) 00042 00043 /** Declares a class derived from "CObservation" that represents a set of readings from gas sensors. 00044 * 00045 * \sa CObservation 00046 * \ingroup mrpt_obs_grp 00047 */ 00048 class OBS_IMPEXP CObservationGasSensors : public CObservation 00049 { 00050 // This must be added to any CSerializable derived class: 00051 DEFINE_SERIALIZABLE( CObservationGasSensors ) 00052 00053 public: 00054 /** Constructor. 00055 */ 00056 CObservationGasSensors( ); 00057 00058 /** The structure for each e-nose 00059 */ 00060 struct OBS_IMPEXP TObservationENose 00061 { 00062 TObservationENose() : 00063 eNosePoseOnTheRobot(), 00064 readingsVoltage(), 00065 sensorTypes(), 00066 hasTemperature(false), 00067 temperature() 00068 {} 00069 00070 /** The pose of the sensors on the robot 00071 */ 00072 math::TPose3D eNosePoseOnTheRobot; 00073 00074 /** The set of readings (in volts) from the array of sensors (size of "sensorTypes" is the same that the size of "readingsVoltage") 00075 */ 00076 std::vector<float> readingsVoltage; 00077 00078 /** The kind of sensors in the array (size of "sensorTypes" is the same that the size of "readingsVoltage") 00079 * The meaning of values for types of sensors is as follows: 00080 * 0x0000 : No sensor installed in this slot 00081 * 0x2600 : Figaro TGS 2600 00082 * 0x2602 : Figaro TGS 2602 00083 * 0x2620 : Figaro TGS 2620 00084 * 0x4161 : Figaro TGS 4161 00085 */ 00086 vector_int sensorTypes; 00087 00088 /** Must be true for "temperature" to contain a valid measurement 00089 */ 00090 bool hasTemperature; 00091 00092 /** Sensed temperature in Celcius (valid if hasTemperature=true only) 00093 */ 00094 float temperature; 00095 00096 /** True if the input to this chamber/enose is poluted air, False if clean air 00097 */ 00098 bool isActive; 00099 00100 }; 00101 00102 /** One entry per e-nose on the robot. 00103 */ 00104 std::vector<TObservationENose> m_readings; 00105 00106 /** A general method to retrieve the sensor pose on the robot. 00107 * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases. 00108 * \sa setSensorPose 00109 */ 00110 void getSensorPose( CPose3D &out_sensorPose ) const; 00111 00112 00113 /** A general method to change the sensor pose on the robot. 00114 * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases. 00115 * \sa getSensorPose 00116 */ 00117 void setSensorPose( const CPose3D &newSensorPose ); 00118 00119 00120 /** Declares a class within "CObservationGasSensors" that represents a set of gas concentration readings from the modelation of a MOS gas sensor readings. 00121 * This class provides the parameters and functions to simulate the inverse model of a MOS gas sensor. 00122 * 00123 * \sa CObservationGasSensors 00124 */ 00125 class OBS_IMPEXP CMOSmodel 00126 { 00127 00128 public: 00129 /** Constructor 00130 */ 00131 CMOSmodel(); 00132 ~CMOSmodel(); 00133 00134 /** @name MOS-model parameters 00135 * @{ */ 00136 00137 size_t winNoise_size; //!< The size of the mobile average window used to reduce noise on sensor reagings. 00138 int decimate_value; //!< [useMOSmodel] The decimate frecuency applied after noise filtering 00139 float tauR; //!< Tau value for the rise (tauR) sensor phase. 00140 unsigned int lastObservations_size; //!< The number of observations to keep in m_lastObservations (Must be > max(delay) ) 00141 vector_float calibrated_tauD_voltages; //!< Calibrated values of K= 1/tauD for different volatile concentrations 00142 vector_float calibrated_tauD_values; //!< Calibrated values of K= 1/tauD for different volatile concentrations 00143 vector_float calibrated_delay_RobotSpeeds; //!< Calibrated values of the delay for different robot speeds 00144 vector_float calibrated_delay_values; //!< Calibrated values of the delay for different robot speeds 00145 bool save_maplog; //!< If true save generated gas map as a log file 00146 00147 /** @} */ 00148 00149 /** Obtain an estimation of the gas distribution based on raw sensor readings */ 00150 bool get_GasDistribution_estimation( 00151 float &reading, 00152 CPose3D &sensorPose, 00153 const mrpt::system::TTimeStamp ×tamp ); 00154 00155 protected: 00156 00157 /** The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1) 00158 */ 00159 struct OBS_IMPEXP TdataMap 00160 { 00161 float reading; 00162 mrpt::system::TTimeStamp timestamp; 00163 float k; 00164 CPose3D sensorPose; 00165 float estimation; 00166 float reading_filtered; 00167 float speed; 00168 }; 00169 00170 TdataMap last_Obs, temporal_Obs; //!< The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1) 00171 std::vector<TdataMap> m_lastObservations; //!< The last N GasObservations, used for the MOS MODEL estimation. 00172 std::vector<TdataMap> m_antiNoise_window; //!< Vector to temporally store and averge readings to reduce noise 00173 std::ofstream *m_debug_dump; //!< Ofstream to save to file option "save_maplog" 00174 uint16_t decimate_count; //!< Decimate value for oversampled enose readings 00175 double fixed_incT; //!< To force e-nose samples to have fixed time increments 00176 bool first_incT; //!< To force e-nose samples to have fixed time increments 00177 float min_reading; 00178 00179 /** Estimates the gas concentration based on readings and sensor model 00180 */ 00181 void inverse_MOSmodeling ( 00182 const float &reading, 00183 const CPose3D &sensorPose, 00184 const mrpt::system::TTimeStamp ×tamp); 00185 00186 /** Reduce noise by averaging with a mobile window of specific size (winNoise_size) 00187 */ 00188 void noise_filtering ( 00189 const float &reading, 00190 const CPose3D &sensorPose, 00191 const mrpt::system::TTimeStamp ×tamp ); 00192 00193 /** Save the gas distribution estiamtion into a log file for offline representation 00194 */ 00195 void save_log_map( 00196 const mrpt::system::TTimeStamp ×tamp, 00197 const float &reading, 00198 const float &estimation, 00199 const float &k, 00200 const double &yaw, 00201 const float &speed); 00202 00203 }; //End of CMOSmodel class def. 00204 00205 }; // End of class def. 00206 00207 00208 } // End of namespace 00209 } // End of namespace 00210 00211 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |