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 00029 #ifndef CGasConcentrationGridMap2D_H 00030 #define CGasConcentrationGridMap2D_H 00031 00032 #include <mrpt/slam/CRandomFieldGridMap2D.h> 00033 #include <mrpt/slam/CObservationGasSensors.h> 00034 00035 #include <mrpt/maps/link_pragmas.h> 00036 00037 namespace mrpt 00038 { 00039 namespace slam 00040 { 00041 using namespace mrpt::utils; 00042 using namespace mrpt::poses; 00043 using namespace mrpt::math; 00044 00045 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CGasConcentrationGridMap2D , CRandomFieldGridMap2D, MAPS_IMPEXP ) 00046 00047 typedef TRandomFieldCell TGasConcentrationCell; //!< Defined for backward compatibility only (mrpt <0.9.5) 00048 00049 /** CGasConcentrationGridMap2D represents a PDF of gas concentrations over a 2D area. 00050 * 00051 * There are a number of methods available to build the gas grid-map, depending on the value of 00052 * "TMapRepresentation maptype" passed in the constructor (see base class mrpt::slam::CRandomFieldGridMap2D). 00053 * 00054 * \sa mrpt::slam::CRandomFieldGridMap2D, mrpt::slam::CMetricMap, mrpt::utils::CDynamicGrid, The application icp-slam, mrpt::slam::CMultiMetricMap 00055 * \ingroup mrpt_maps_grp 00056 */ 00057 class MAPS_IMPEXP CGasConcentrationGridMap2D : public CRandomFieldGridMap2D 00058 { 00059 // This must be added to any CSerializable derived class: 00060 DEFINE_SERIALIZABLE( CGasConcentrationGridMap2D ) 00061 public: 00062 00063 /** Constructor 00064 */ 00065 CGasConcentrationGridMap2D( 00066 TMapRepresentation mapType = mrAchim, 00067 float x_min = -2, 00068 float x_max = 2, 00069 float y_min = -2, 00070 float y_max = 2, 00071 float resolution = 0.1 00072 ); 00073 00074 /** Destructor */ 00075 virtual ~CGasConcentrationGridMap2D(); 00076 00077 /** Computes the likelihood that a given observation was taken from a given pose in the world being modeled with this map. 00078 * 00079 * \param takenFrom The robot's pose the observation is supposed to be taken from. 00080 * \param obs The observation. 00081 * \return This method returns a likelihood in the range [0,1]. 00082 * 00083 * \sa Used in particle filter algorithms, see: CMultiMetricMapPDF::update 00084 */ 00085 virtual double computeObservationLikelihood( const CObservation *obs, const CPose3D &takenFrom ); 00086 00087 00088 /** Parameters related with inserting observations into the map: 00089 */ 00090 struct MAPS_IMPEXP TInsertionOptions : 00091 public utils::CLoadableOptions, 00092 public TInsertionOptionsCommon 00093 { 00094 TInsertionOptions(); //!< Default values loader 00095 00096 /** See utils::CLoadableOptions */ 00097 void loadFromConfigFile( 00098 const mrpt::utils::CConfigFileBase &source, 00099 const std::string §ion); 00100 00101 void dumpToTextStream(CStream &out) const; //!< See utils::CLoadableOptions 00102 00103 /** @name For all mapping methods 00104 @{ */ 00105 uint16_t sensorType; //!< The sensor type for the gas concentration map (0x0000 ->mean of all installed sensors, 0x2600, 0x6810, ...) 00106 /** @} */ 00107 00108 /** @name Parameters of the "MOS model" 00109 @{ */ 00110 bool useMOSmodel; //!< If true use MOS model before map algorithm 00111 00112 float tauR; //!< Tau values for the rise sensor's phases. 00113 float tauD; //!< Tau values for the decay (tauD) sensor's phases. 00114 00115 uint16_t lastObservations_size; //!< The number of observations to keep in m_lastObservations 00116 size_t winNoise_size; //!< The number of observations used to reduce noise on signal. 00117 uint16_t decimate_value; //!< The decimate frecuency applied after noise filtering 00118 00119 vector_float calibrated_tauD_voltages; //!< Measured values of K= 1/tauD for different volatile concentrations 00120 vector_float calibrated_tauD_values; 00121 00122 vector_float calibrated_delay_RobotSpeeds; //!< Measured values of the delay (memory effect) for different robot speeds 00123 vector_float calibrated_delay_values; 00124 00125 uint16_t enose_id; //!< id for the enose used to generate this map (must be < gasGrid_count) 00126 bool save_maplog; //!< If true save generated gas map as a log file 00127 /** @} */ // end: Parameters of the "MOS model" 00128 00129 } insertionOptions; 00130 00131 00132 /** Returns an image just as described in \a saveAsBitmapFile */ 00133 virtual void getAsBitmapFile(mrpt::utils::CImage &out_img) const; 00134 00135 /** The implementation in this class just calls all the corresponding method of the contained metric maps. 00136 */ 00137 virtual void saveMetricMapRepresentationToFile( 00138 const std::string &filNamePrefix 00139 ) const; 00140 00141 /** Save a matlab ".m" file which represents as 3D surfaces the mean and a given confidence level for the concentration of each cell. 00142 * This method can only be called in a KF map model. 00143 */ 00144 virtual void saveAsMatlab3DGraph(const std::string &filName) const; 00145 00146 /** Returns a 3D object representing the map. 00147 */ 00148 virtual void getAs3DObject ( mrpt::opengl::CSetOfObjectsPtr &outObj ) const; 00149 00150 protected: 00151 00152 /** Get the part of the options common to all CRandomFieldGridMap2D classes */ 00153 virtual CRandomFieldGridMap2D::TInsertionOptionsCommon * getCommonInsertOptions() { 00154 return &insertionOptions; 00155 } 00156 00157 /** The content of each m_lastObservations in the estimation when using the option : MOS_MODEl (insertionOptions.useMOSmodel =1) 00158 */ 00159 struct MAPS_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 /** [useMOSmodel] The last N GasObservations, used for the MOS MODEL estimation. */ 00171 TdataMap m_new_Obs, m_new_ANS; 00172 std::vector<TdataMap> m_lastObservations; 00173 std::vector<TdataMap> m_antiNoise_window; 00174 00175 /** [useMOSmodel] Ofstream to save to file option "save_maplog" 00176 */ 00177 std::ofstream *m_debug_dump; 00178 00179 /** [useMOSmodel] Decimate value for oversampled enose readings 00180 */ 00181 uint16_t decimate_count; 00182 00183 /** [useMOSmodel] To force e-nose samples to have fixed time increments 00184 */ 00185 double fixed_incT; 00186 bool first_incT; 00187 00188 /** Estimates the gas concentration based on readings and sensor model 00189 */ 00190 void CGasConcentration_estimation ( 00191 float reading, 00192 const CPose3D &sensorPose, 00193 const mrpt::system::TTimeStamp timestamp); 00194 00195 /** Reduce noise by averaging with a mobile window 00196 */ 00197 void noise_filtering ( 00198 float reading, 00199 const CPose3D &sensorPose, 00200 const mrpt::system::TTimeStamp timestamp ); 00201 00202 /** Save the GAS_MAP generated into a log file for offline representation 00203 */ 00204 void save_log_map( 00205 const mrpt::system::TTimeStamp timestamp, 00206 const float reading, 00207 const float estimation, 00208 const float k, 00209 const double yaw, 00210 const float speed); 00211 00212 00213 /** Erase all the contents of the map */ 00214 virtual void internal_clear(); 00215 00216 /** Insert the observation information into this map. This method must be implemented 00217 * in derived classes. 00218 * \param obs The observation 00219 * \param robotPose The 3D pose of the robot mobile base in the map reference system, or NULL (default) if you want to use CPose2D(0,0,deg) 00220 * 00221 * \sa CObservation::insertObservationInto 00222 */ 00223 virtual bool internal_insertObservation( const CObservation *obs, const CPose3D *robotPose = NULL ); 00224 00225 }; 00226 00227 } // End of namespace 00228 00229 } // End of namespace 00230 00231 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |