00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 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 */ 00047 class OBS_IMPEXP CObservationGasSensors : public CObservation 00048 { 00049 // This must be added to any CSerializable derived class: 00050 DEFINE_SERIALIZABLE( CObservationGasSensors ) 00051 00052 public: 00053 /** Constructor. 00054 */ 00055 CObservationGasSensors( ); 00056 00057 /** The structure for each e-nose 00058 */ 00059 struct OBS_IMPEXP TObservationENose 00060 { 00061 TObservationENose() : 00062 eNosePoseOnTheRobot(), 00063 readingsVoltage(), 00064 sensorTypes(), 00065 hasTemperature(false), 00066 temperature() 00067 {} 00068 00069 /** The pose of the sensors on the robot 00070 */ 00071 math::TPose3D eNosePoseOnTheRobot; 00072 00073 /** The set of readings (in volts) from the array of sensors (size of "sensorTypes" is the same that the size of "readingsVoltage") 00074 */ 00075 std::vector<float> readingsVoltage; 00076 00077 /** The kind of sensors in the array (size of "sensorTypes" is the same that the size of "readingsVoltage") 00078 * The meaning of values for types of sensors is as follows: 00079 * 0x0000 : No sensor installed in this slot 00080 * 0x2600 : Figaro TGS 2600 00081 * 0x2602 : Figaro TGS 2602 00082 * 0x2620 : Figaro TGS 2620 00083 * 0x4161 : Figaro TGS 4161 00084 */ 00085 vector_int sensorTypes; 00086 00087 /** Must be true for "temperature" to contain a valid measurement 00088 */ 00089 bool hasTemperature; 00090 00091 /** Sensed temperature in Celcius (valid if hasTemperature=true only) 00092 */ 00093 float temperature; 00094 00095 /** True if the input to this chamber/enose is poluted air, False if clean air 00096 */ 00097 bool isActive; 00098 00099 }; 00100 00101 /** One entry per e-nose on the robot. 00102 */ 00103 std::vector<TObservationENose> m_readings; 00104 00105 /** A general method to retrieve the sensor pose on the robot. 00106 * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases. 00107 * \sa setSensorPose 00108 */ 00109 void getSensorPose( CPose3D &out_sensorPose ) const; 00110 00111 00112 /** A general method to change the sensor pose on the robot. 00113 * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases. 00114 * \sa getSensorPose 00115 */ 00116 void setSensorPose( const CPose3D &newSensorPose ); 00117 00118 00119 /** Declares a class within "CObservationGasSensors" that represents a set of gas concentration readings from the modelation of a MOS gas sensor readings. 00120 * This class provides the parameters and functions to simulate the inverse model of a MOS gas sensor. 00121 * 00122 * \sa CObservationGasSensors 00123 */ 00124 class OBS_IMPEXP CMOSmodel 00125 { 00126 00127 public: 00128 /** Constructor 00129 */ 00130 CMOSmodel(); 00131 ~CMOSmodel(); 00132 00133 /** @name MOS-model parameters 00134 * @{ */ 00135 00136 size_t winNoise_size; //!< The size of the mobile average window used to reduce noise on sensor reagings. 00137 int decimate_value; //!< [useMOSmodel] The decimate frecuency applied after noise filtering 00138 float tauR; //!< Tau value for the rise (tauR) sensor phase. 00139 unsigned int lastObservations_size; //!< The number of observations to keep in m_lastObservations (Must be > max(delay) ) 00140 vector_float calibrated_tauD_voltages; //!< Calibrated values of K= 1/tauD for different volatile concentrations 00141 vector_float calibrated_tauD_values; //!< Calibrated values of K= 1/tauD for different volatile concentrations 00142 vector_float calibrated_delay_RobotSpeeds; //!< Calibrated values of the delay for different robot speeds 00143 vector_float calibrated_delay_values; //!< Calibrated values of the delay for different robot speeds 00144 bool save_maplog; //!< If true save generated gas map as a log file 00145 00146 /** @} */ 00147 00148 /** Obtain an estimation of the gas distribution based on raw sensor readings */ 00149 bool get_GasDistribution_estimation( 00150 float &reading, 00151 CPose3D &sensorPose, 00152 const mrpt::system::TTimeStamp ×tamp ); 00153 00154 protected: 00155 00156 /** The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1) 00157 */ 00158 struct OBS_IMPEXP TdataMap 00159 { 00160 float reading; 00161 mrpt::system::TTimeStamp timestamp; 00162 float k; 00163 CPose3D sensorPose; 00164 float estimation; 00165 float reading_filtered; 00166 float speed; 00167 }; 00168 00169 TdataMap last_Obs, temporal_Obs; //!< The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (useMOSmodel =1) 00170 std::vector<TdataMap> m_lastObservations; //!< The last N GasObservations, used for the MOS MODEL estimation. 00171 std::vector<TdataMap> m_antiNoise_window; //!< Vector to temporally store and averge readings to reduce noise 00172 std::ofstream *m_debug_dump; //!< Ofstream to save to file option "save_maplog" 00173 uint16_t decimate_count; //!< Decimate value for oversampled enose readings 00174 double fixed_incT; //!< To force e-nose samples to have fixed time increments 00175 bool first_incT; //!< To force e-nose samples to have fixed time increments 00176 float min_reading; 00177 00178 /** Estimates the gas concentration based on readings and sensor model 00179 */ 00180 void inverse_MOSmodeling ( 00181 const float &reading, 00182 const CPose3D &sensorPose, 00183 const mrpt::system::TTimeStamp ×tamp); 00184 00185 /** Reduce noise by averaging with a mobile window of specific size (winNoise_size) 00186 */ 00187 void noise_filtering ( 00188 const float &reading, 00189 const CPose3D &sensorPose, 00190 const mrpt::system::TTimeStamp ×tamp ); 00191 00192 /** Save the gas distribution estiamtion into a log file for offline representation 00193 */ 00194 void save_log_map( 00195 const mrpt::system::TTimeStamp ×tamp, 00196 const float &reading, 00197 const float &estimation, 00198 const float &k, 00199 const double &yaw, 00200 const float &speed); 00201 00202 }; //End of CMOSmodel class def. 00203 00204 }; // End of class def. 00205 00206 00207 } // End of namespace 00208 } // End of namespace 00209 00210 #endif
Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:30:30 UTC 2011 |