Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 4bc66056a634db26a1f4d0845dc41ca6 > files > 590

mrpt-doc-0.9.5-0.1.20110925svn2670.fc16.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>CGenericSensor.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<div align="left"><a href="http://www.mrpt.org/">Main MRPT website</a> &gt; <b>C++ reference</b> </div>
<div align="right">
<a href="index.html"><img border="0" src="mrpt_logo.png" alt="MRPT logo"></a>
</div>
<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
          <div class="left">
            <form id="FSearchBox" action="search.php" method="get">
              <img id="MSearchSelect" src="search/mag.png" alt=""/>
              <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" 
                     onfocus="searchBox.OnSearchFieldFocus(true)" 
                     onblur="searchBox.OnSearchFieldFocus(false)"/>
            </form>
          </div><div class="right"></div>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">CGenericSensor.h</div>  </div>
</div>
<div class="contents">
<a href="_c_generic_sensor_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* +---------------------------------------------------------------------------+</span>
<a name="l00002"></a>00002 <span class="comment">   |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |</span>
<a name="l00003"></a>00003 <span class="comment">   |                                                                           |</span>
<a name="l00004"></a>00004 <span class="comment">   |                       http://www.mrpt.org/                                |</span>
<a name="l00005"></a>00005 <span class="comment">   |                                                                           |</span>
<a name="l00006"></a>00006 <span class="comment">   |   Copyright (C) 2005-2011  University of Malaga                           |</span>
<a name="l00007"></a>00007 <span class="comment">   |                                                                           |</span>
<a name="l00008"></a>00008 <span class="comment">   |    This software was written by the Machine Perception and Intelligent    |</span>
<a name="l00009"></a>00009 <span class="comment">   |      Robotics Lab, University of Malaga (Spain).                          |</span>
<a name="l00010"></a>00010 <span class="comment">   |    Contact: Jose-Luis Blanco  &lt;jlblanco@ctima.uma.es&gt;                     |</span>
<a name="l00011"></a>00011 <span class="comment">   |                                                                           |</span>
<a name="l00012"></a>00012 <span class="comment">   |  This file is part of the MRPT project.                                   |</span>
<a name="l00013"></a>00013 <span class="comment">   |                                                                           |</span>
<a name="l00014"></a>00014 <span class="comment">   |     MRPT is free software: you can redistribute it and/or modify          |</span>
<a name="l00015"></a>00015 <span class="comment">   |     it under the terms of the GNU General Public License as published by  |</span>
<a name="l00016"></a>00016 <span class="comment">   |     the Free Software Foundation, either version 3 of the License, or     |</span>
<a name="l00017"></a>00017 <span class="comment">   |     (at your option) any later version.                                   |</span>
<a name="l00018"></a>00018 <span class="comment">   |                                                                           |</span>
<a name="l00019"></a>00019 <span class="comment">   |   MRPT is distributed in the hope that it will be useful,                 |</span>
<a name="l00020"></a>00020 <span class="comment">   |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |</span>
<a name="l00021"></a>00021 <span class="comment">   |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |</span>
<a name="l00022"></a>00022 <span class="comment">   |     GNU General Public License for more details.                          |</span>
<a name="l00023"></a>00023 <span class="comment">   |                                                                           |</span>
<a name="l00024"></a>00024 <span class="comment">   |     You should have received a copy of the GNU General Public License     |</span>
<a name="l00025"></a>00025 <span class="comment">   |     along with MRPT.  If not, see &lt;http://www.gnu.org/licenses/&gt;.         |</span>
<a name="l00026"></a>00026 <span class="comment">   |                                                                           |</span>
<a name="l00027"></a>00027 <span class="comment">   +---------------------------------------------------------------------------+ */</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#ifndef CGenericSensor_H</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define CGenericSensor_H</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="_c_config_file_base_8h.html">mrpt/utils/CConfigFileBase.h</a>&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;<a class="code" href="_c_observation_8h.html">mrpt/slam/CObservation.h</a>&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;<a class="code" href="synch_8h.html">mrpt/synch.h</a>&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;<a class="code" href="threads_8h.html">mrpt/system/threads.h</a>&gt;</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;<a class="code" href="hwdrivers_2include_2mrpt_2hwdrivers_2link__pragmas_8h.html">mrpt/hwdrivers/link_pragmas.h</a>&gt;</span>
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <span class="keyword">namespace </span>mrpt
<a name="l00041"></a>00041 {<span class="comment"></span>
<a name="l00042"></a>00042 <span class="comment">        /**   Contains classes for various device interfaces.</span>
<a name="l00043"></a>00043 <span class="comment">         * \ingroup mrpt_hwdrivers_grp</span>
<a name="l00044"></a>00044 <span class="comment">         */</span>
<a name="l00045"></a>00045         <span class="keyword">namespace </span>hwdrivers
<a name="l00046"></a>00046         {
<a name="l00047"></a><a class="code" href="namespacemrpt_1_1hwdrivers.html#a3f369b2dbc16368a52f0ddab62ba5702">00047</a>                 <span class="keyword">class </span><a class="code" href="hwdrivers__impexp_8h.html#a5bcf681973c7e4e76310bd0791f1b612">HWDRIVERS_IMPEXP</a> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html" title="A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...">CGenericSensor</a>;
<a name="l00048"></a>00048 <span class="comment"></span>
<a name="l00049"></a>00049 <span class="comment">                /** A structure for runtime ID class type information in the context of hwdrivers::CGenericSensor.</span>
<a name="l00050"></a>00050 <span class="comment">                  */</span>
<a name="l00051"></a>00051                 <span class="keyword">struct </span><a class="code" href="hwdrivers__impexp_8h.html#a5bcf681973c7e4e76310bd0791f1b612">HWDRIVERS_IMPEXP</a> <a class="code" href="structmrpt_1_1hwdrivers_1_1_t_sensor_class_id.html" title="A structure for runtime ID class type information in the context of hwdrivers::CGenericSensor.">TSensorClassId</a>
<a name="l00052"></a>00052                 {
<a name="l00053"></a><a class="code" href="structmrpt_1_1hwdrivers_1_1_t_sensor_class_id.html#acc14ddc75ce71d65424c1558ff3ffc3f">00053</a>                         <span class="keyword">const</span> <span class="keywordtype">char</span>*                     <a class="code" href="structmrpt_1_1hwdrivers_1_1_t_sensor_class_id.html#acc14ddc75ce71d65424c1558ff3ffc3f" title="Class name.">className</a>;                                              <span class="comment">//!&lt; Class name</span>
<a name="l00054"></a><a class="code" href="structmrpt_1_1hwdrivers_1_1_t_sensor_class_id.html#a75a2bab4577f7009dc9ae39e68b1f33c">00054</a> <span class="comment"></span>                        <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html" title="A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...">CGenericSensor</a>*         (*ptrCreateObject)();                   <span class="comment">//!&lt; Pointer to class constructor</span>
<a name="l00055"></a>00055 <span class="comment"></span>                };
<a name="l00056"></a>00056 
<a name="l00057"></a><a class="code" href="namespacemrpt_1_1hwdrivers.html#a71aef48ea8dd23e43c706cc1a3ae0e74">00057</a>                 <span class="keyword">typedef</span> stlplus::smart_ptr&lt;CGenericSensor&gt;      <a class="code" href="namespacemrpt_1_1hwdrivers.html#a71aef48ea8dd23e43c706cc1a3ae0e74">CGenericSensorPtr</a>;
<a name="l00058"></a>00058 <span class="comment"></span>
<a name="l00059"></a>00059 <span class="comment">                /** A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabber.</span>
<a name="l00060"></a>00060 <span class="comment">                  *  Derived classes should be designed with the following execution flow in mind:</span>
<a name="l00061"></a>00061 <span class="comment">                  *             - Object constructor</span>
<a name="l00062"></a>00062 <span class="comment">                  *             - CGenericSensor::loadConfig: The following parameters are common to all sensors in rawlog-grabber (they are automatically loaded by rawlog-grabber) - see each class documentation for additional parameters:</span>
<a name="l00063"></a>00063 <span class="comment">                  *                     - &quot;process_rate&quot;: (Mandatory) The rate in Hertz (Hz) at which the sensor thread should invoke &quot;doProcess&quot;.</span>
<a name="l00064"></a>00064 <span class="comment">                  *                     - &quot;max_queue_len&quot;: (Optional) The maximum number of objects in the observations queue (default is 200). If overflow occurs, an error message will be issued at run-time.</span>
<a name="l00065"></a>00065 <span class="comment">                  *                     - &quot;grab_decimation&quot;: (Optional) Grab only 1 out of N observations captured by the sensor (default is 1, i.e. do not decimate).</span>
<a name="l00066"></a>00066 <span class="comment">                  *             - CGenericSensor::initialize</span>
<a name="l00067"></a>00067 <span class="comment">                  *             - CGenericSensor::doProcess</span>
<a name="l00068"></a>00068 <span class="comment">                  *             - CGenericSensor::getObservations</span>
<a name="l00069"></a>00069 <span class="comment">                  *</span>
<a name="l00070"></a>00070 <span class="comment">                  *  Notice that there are helper methods for managing the internal list of objects (see CGenericSensor::appendObservation).</span>
<a name="l00071"></a>00071 <span class="comment">                  *</span>
<a name="l00072"></a>00072 <span class="comment">                  *  &lt;b&gt;Class Factory:&lt;/b&gt; This is also a factory of derived classes, through the static method CGenericSensor::createSensor</span>
<a name="l00073"></a>00073 <span class="comment">                  *</span>
<a name="l00074"></a>00074 <span class="comment">                  *</span>
<a name="l00075"></a>00075 <span class="comment">                  *  For more details on RawLogGrabber refer to the wiki page:</span>
<a name="l00076"></a>00076 <span class="comment">                  *    http://www.mrpt.org/Application:RawLogGrabber</span>
<a name="l00077"></a>00077 <span class="comment">                  * \ingroup mrpt_hwdrivers_grp</span>
<a name="l00078"></a>00078 <span class="comment">                  */</span>
<a name="l00079"></a>00079                 <span class="keyword">class </span><a class="code" href="hwdrivers__impexp_8h.html#a5bcf681973c7e4e76310bd0791f1b612">HWDRIVERS_IMPEXP</a> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html" title="A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...">CGenericSensor</a>: <span class="keyword">public</span> mrpt::utils::<a class="code" href="classmrpt_1_1utils_1_1_c_uncopiable.html" title="The base class of classes that cannot be copied: compile-time errors will be issued on any copy opera...">CUncopiable</a>
<a name="l00080"></a>00080                 {
<a name="l00081"></a>00081                 <span class="keyword">public</span>:
<a name="l00082"></a>00082                         <span class="keyword">virtual</span> <span class="keyword">const</span> mrpt<a class="code" href="structmrpt_1_1hwdrivers_1_1_t_sensor_class_id.html" title="A structure for runtime ID class type information in the context of hwdrivers::CGenericSensor.">::hwdrivers::TSensorClassId</a>* GetRuntimeClass() <span class="keyword">const</span> = 0;
<a name="l00083"></a>00083 
<a name="l00084"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#af237beee1de7f3e5733e305921695b30">00084</a>                         <span class="keyword">typedef</span> std<a class="code" href="classstd_1_1multimap.html">::multimap&lt; mrpt::system::TTimeStamp, mrpt::utils::CSerializablePtr &gt;</a> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#af237beee1de7f3e5733e305921695b30">TListObservations</a>;
<a name="l00085"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a78712e0c40c510978fb8589774056ab3">00085</a>                         <span class="keyword">typedef</span> std::pair&lt; mrpt::system::TTimeStamp, mrpt::utils::CSerializablePtr &gt; <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a78712e0c40c510978fb8589774056ab3">TListObsPair</a>;
<a name="l00086"></a>00086 <span class="comment"></span>
<a name="l00087"></a>00087 <span class="comment">                        /** The current state of the sensor</span>
<a name="l00088"></a>00088 <span class="comment">                          * \sa CGenericSensor::getState</span>
<a name="l00089"></a>00089 <span class="comment">                          */</span>
<a name="l00090"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a44262a8f1ffcc87871fbd717d3fc2cab">00090</a>                         <span class="keyword">enum</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a44262a8f1ffcc87871fbd717d3fc2cab" title="The current state of the sensor.">TSensorState</a>
<a name="l00091"></a>00091                         {
<a name="l00092"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a44262a8f1ffcc87871fbd717d3fc2caba0e2689514dd41d48164e021013549a44">00092</a>                                 ssInitializing = 0,
<a name="l00093"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a44262a8f1ffcc87871fbd717d3fc2cabaacc62e94572e3cd3b4b08caad173a489">00093</a>                                 <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a44262a8f1ffcc87871fbd717d3fc2cabaacc62e94572e3cd3b4b08caad173a489">ssWorking</a>,
<a name="l00094"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a44262a8f1ffcc87871fbd717d3fc2caba8f76c8318736df85b6805ca460f8d262">00094</a>                                 ssError
<a name="l00095"></a>00095                         };
<a name="l00096"></a>00096 <span class="comment"></span>
<a name="l00097"></a>00097 <span class="comment">                        /** The current state of the sensor  */</span>
<a name="l00098"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a0bd667caedc6a313d96c232bf75ba577">00098</a>                         <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a44262a8f1ffcc87871fbd717d3fc2cab" title="The current state of the sensor.">TSensorState</a> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a0bd667caedc6a313d96c232bf75ba577" title="The current state of the sensor.">getState</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_state; }
<a name="l00099"></a>00099 
<a name="l00100"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a8a05c268aef7ecada94a0014a2b294f7">00100</a>                         <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a8a05c268aef7ecada94a0014a2b294f7">getProcessRate</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_process_rate; }
<a name="l00101"></a>00101 
<a name="l00102"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#af3cd061ca684e7ddf5949ed78fced7c9">00102</a>                         <span class="keyword">inline</span> std<a class="code" href="classstd_1_1string.html" title="STL class.">::string</a> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#af3cd061ca684e7ddf5949ed78fced7c9">getSensorLabel</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_sensorLabel; }
<a name="l00103"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a044c1340c4b90957250f63fa89189036">00103</a>                         <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a044c1340c4b90957250f63fa89189036">setSensorLabel</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>&amp; sensorLabel) { m_sensorLabel=sensorLabel; }
<a name="l00104"></a>00104 <span class="comment"></span>
<a name="l00105"></a>00105 <span class="comment">                        /** Register a class into the internal list of &quot;CGenericSensor&quot; descendents.</span>
<a name="l00106"></a>00106 <span class="comment">                          *  Used internally in the macros DEFINE_GENERIC_SENSOR, etc...</span>
<a name="l00107"></a>00107 <span class="comment">                          *</span>
<a name="l00108"></a>00108 <span class="comment">                          *  Can be used as &quot;CGenericSensor::registerClass( SENSOR_CLASS_ID(CMySensor) );&quot; if</span>
<a name="l00109"></a>00109 <span class="comment">                          *    building custom sensors outside mrpt libraries in user code.</span>
<a name="l00110"></a>00110 <span class="comment">                          */</span>
<a name="l00111"></a>00111                         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="group__mrpt__base__grp.html#ga5af77a9809680e1559cde8167361518e" title="Register a class into the MRPT internal list of &quot;CSerializable&quot; descendents.">registerClass</a>(<span class="keyword">const</span> <a class="code" href="structmrpt_1_1hwdrivers_1_1_t_sensor_class_id.html" title="A structure for runtime ID class type information in the context of hwdrivers::CGenericSensor.">TSensorClassId</a>* pNewClass);
<a name="l00112"></a>00112 
<a name="l00113"></a>00113                 <span class="keyword">private</span>:
<a name="l00114"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a9ff93d86c4c09a910142155f6f789eea">00114</a>                         synch::CCriticalSection                 <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a9ff93d86c4c09a910142155f6f789eea" title="The critical section for m_objList.">m_csObjList</a>;            <span class="comment">//!&lt; The critical section for m_objList</span>
<a name="l00115"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a48c282eda678708c3a8afdf84529dfab">00115</a> <span class="comment"></span>                        <a class="code" href="classstd_1_1multimap.html">TListObservations</a>                               <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a48c282eda678708c3a8afdf84529dfab" title="The queue of objects to be returned by getObservations.">m_objList</a>;              <span class="comment">//!&lt; The queue of objects to be returned by getObservations</span>
<a name="l00116"></a>00116 <span class="comment"></span><span class="comment"></span>
<a name="l00117"></a>00117 <span class="comment">                        /** Used in registerClass */</span>
<a name="l00118"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#ac2a876b33fd0f1d93ee0ecdb252b0985">00118</a>                         <span class="keyword">static</span> std<a class="code" href="classstd_1_1map.html">::map&lt; std::string , const TSensorClassId *&gt;</a>  <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#ac2a876b33fd0f1d93ee0ecdb252b0985" title="Used in registerClass.">m_knownClasses</a>;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 
<a name="l00121"></a>00121                 <span class="keyword">protected</span>:<span class="comment"></span>
<a name="l00122"></a>00122 <span class="comment">                        /** @name Common settings to any sensor, loaded in &quot;loadConfig&quot;</span>
<a name="l00123"></a>00123 <span class="comment">                            @{ */</span>
<a name="l00124"></a>00124 
<a name="l00125"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a77094b791971e8f42b94de34f4adb0f7">00125</a>                         <span class="keywordtype">double</span>  <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a77094b791971e8f42b94de34f4adb0f7" title="See CGenericSensor.">m_process_rate</a>;  <span class="comment">//!&lt; See CGenericSensor</span>
<a name="l00126"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a6f35448579bd4d27cd4f4685b31a8cc0">00126</a> <span class="comment"></span>                        <span class="keywordtype">size_t</span>  <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a6f35448579bd4d27cd4f4685b31a8cc0" title="See CGenericSensor.">m_max_queue_len</a>; <span class="comment">//!&lt; See CGenericSensor</span>
<a name="l00127"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a587daaab2cb302eb4cc72eb1396d5f21">00127</a> <span class="comment"></span>                        <span class="keywordtype">size_t</span>  <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a587daaab2cb302eb4cc72eb1396d5f21" title="If set to N&gt;=2, only 1 out of N observations will be saved to m_objList.">m_grab_decimation</a>;      <span class="comment">//!&lt; If set to N&gt;=2, only 1 out of N observations will be saved to m_objList.</span>
<a name="l00128"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#accd4de8daeb5966c191fbc62a5d90355">00128</a> <span class="comment"></span>                        std<a class="code" href="classstd_1_1string.html" title="STL class.">::string</a>  <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#accd4de8daeb5966c191fbc62a5d90355" title="See CGenericSensor.">m_sensorLabel</a>; <span class="comment">//!&lt; See CGenericSensor</span>
<a name="l00129"></a>00129 <span class="comment"></span><span class="comment"></span>
<a name="l00130"></a>00130 <span class="comment">                        /** @} */</span>
<a name="l00131"></a>00131 
<a name="l00132"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a564a6c2bc7f1baaea9a9d90112a7b376">00132</a>                         <span class="keywordtype">size_t</span>  <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a564a6c2bc7f1baaea9a9d90112a7b376" title="Used when &quot;m_grab_decimation&quot; is enabled.">m_grab_decimation_counter</a>; <span class="comment">//!&lt; Used when &quot;m_grab_decimation&quot; is enabled</span>
<a name="l00133"></a>00133 <span class="comment"></span>
<a name="l00134"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#ab3e8a003783acd03bfd64716640fd67c">00134</a>                         <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a44262a8f1ffcc87871fbd717d3fc2cab" title="The current state of the sensor.">TSensorState</a>    <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#ab3e8a003783acd03bfd64716640fd67c">m_state</a>;
<a name="l00135"></a>00135 
<a name="l00136"></a>00136                         <span class="comment">// === Data for off-rawlog file external image directory ====</span>
<a name="l00137"></a>00137                         <span class="comment">//  Only used by a few sensor classes.</span>
<a name="l00138"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a06fe84426b813b9c1966c12bb69e6ee6">00138</a>                         std<a class="code" href="classstd_1_1string.html" title="STL class.">::string</a>                     <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a06fe84426b813b9c1966c12bb69e6ee6" title="The path where to save off-rawlog images: empty means save images embedded in the rawlog...">m_path_for_external_images</a>; <span class="comment">//!&lt; The path where to save off-rawlog images: empty means save images embedded in the rawlog.</span>
<a name="l00139"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a7d153c5247b0180b6b9df5054d67b183">00139</a> <span class="comment"></span>                        std<a class="code" href="classstd_1_1string.html" title="STL class.">::string</a>                     <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a7d153c5247b0180b6b9df5054d67b183" title="The extension (&quot;jpg&quot;,&quot;gif&quot;,&quot;png&quot;,...) that determines the format of images saved externally.">m_external_images_format</a>; <span class="comment">//!&lt; The extension (&quot;jpg&quot;,&quot;gif&quot;,&quot;png&quot;,...) that determines the format of images saved externally \sa setPathForExternalImages</span>
<a name="l00140"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#aeac331931fce4890793cd7f1b5f6eb3e">00140</a> <span class="comment"></span>                        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>            <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#aeac331931fce4890793cd7f1b5f6eb3e" title="For JPEG images, the quality (default=95%).">m_external_images_jpeg_quality</a>; <span class="comment">//!&lt; For JPEG images, the quality (default=95%).</span>
<a name="l00141"></a>00141 <span class="comment"></span>                        <span class="comment">// ======================================</span>
<a name="l00142"></a>00142 <span class="comment"></span>
<a name="l00143"></a>00143 <span class="comment">                        /** This method must be called by derived classes to enqueue a new observation in the list to be returned by getObservations.</span>
<a name="l00144"></a>00144 <span class="comment">                          *  Passed objects must be created in dynamic memory and a smart pointer passed. Example of creation:</span>
<a name="l00145"></a>00145 <span class="comment">                          \code</span>
<a name="l00146"></a>00146 <span class="comment">                                CObservationGPSPtr  o = CObservationGPSPtr( new CObservationGPS() );</span>
<a name="l00147"></a>00147 <span class="comment">                                o-&gt; .... // Set data</span>
<a name="l00148"></a>00148 <span class="comment">                                appendObservation(o);</span>
<a name="l00149"></a>00149 <span class="comment">                          \endcode</span>
<a name="l00150"></a>00150 <span class="comment">                          * If several observations are passed at once in the vector, they&#39;ll be considered as a block regarding the grabbing decimation factor.</span>
<a name="l00151"></a>00151 <span class="comment">                          */</span>
<a name="l00152"></a>00152                         <span class="keywordtype">void</span> appendObservations( <span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html" title="STL class.">std::vector&lt;mrpt::utils::CSerializablePtr&gt;</a> &amp;obj);
<a name="l00153"></a>00153 <span class="comment"></span>
<a name="l00154"></a>00154 <span class="comment">                        //! Like appendObservations() but for just one observation.</span>
<a name="l00155"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a03bf6784838d6418f4fe485933a1ab0c">00155</a> <span class="comment"></span>                        <span class="keywordtype">void</span> appendObservation( <span class="keyword">const</span> <a class="code" href="structmrpt_1_1utils_1_1_c_serializable_ptr.html">mrpt::utils::CSerializablePtr</a> &amp;obj)
<a name="l00156"></a>00156                         {
<a name="l00157"></a>00157                                 appendObservations(<a class="code" href="classstd_1_1vector.html" title="STL class.">std::vector&lt;mrpt::utils::CSerializablePtr&gt;</a>(1, obj));
<a name="l00158"></a>00158                         }
<a name="l00159"></a>00159 <span class="comment"></span>
<a name="l00160"></a>00160 <span class="comment">                        /** Auxiliary structure used for CSerializable runtime class ID support.</span>
<a name="l00161"></a>00161 <span class="comment">                          */</span>
<a name="l00162"></a>00162                         <span class="keyword">struct </span>CLASSINIT_GENERIC_SENSOR
<a name="l00163"></a>00163                         {
<a name="l00164"></a><a class="code" href="structmrpt_1_1hwdrivers_1_1_c_generic_sensor_1_1_c_l_a_s_s_i_n_i_t___g_e_n_e_r_i_c___s_e_n_s_o_r.html#a1ca522598172be3e6c42d3fa3f1e15cb">00164</a>                                 <a class="code" href="structmrpt_1_1hwdrivers_1_1_c_generic_sensor_1_1_c_l_a_s_s_i_n_i_t___g_e_n_e_r_i_c___s_e_n_s_o_r.html" title="Auxiliary structure used for CSerializable runtime class ID support.">CLASSINIT_GENERIC_SENSOR</a>(<span class="keyword">const</span> <a class="code" href="structmrpt_1_1hwdrivers_1_1_t_sensor_class_id.html" title="A structure for runtime ID class type information in the context of hwdrivers::CGenericSensor.">TSensorClassId</a>* pNewClass)
<a name="l00165"></a>00165                                 {
<a name="l00166"></a>00166                                         <a class="code" href="group__mrpt__base__grp.html#ga5af77a9809680e1559cde8167361518e" title="Register a class into the MRPT internal list of &quot;CSerializable&quot; descendents.">CGenericSensor::registerClass</a>(pNewClass);
<a name="l00167"></a>00167                                 }
<a name="l00168"></a>00168                         };
<a name="l00169"></a>00169 <span class="comment"></span>
<a name="l00170"></a>00170 <span class="comment">                        /** Loads specific configuration for the device from a given source of configuration parameters, for example, an &quot;.ini&quot; file, loading from the section &quot;[iniSection]&quot; (see utils::CConfigFileBase and derived classes)</span>
<a name="l00171"></a>00171 <span class="comment">                          *  \exception This method must throw an exception with a descriptive message if some critical parameter is missing or has an invalid value.</span>
<a name="l00172"></a>00172 <span class="comment">                          */</span>
<a name="l00173"></a>00173                         <span class="keyword">virtual</span> <span class="keywordtype">void</span>  loadConfig_sensorSpecific(
<a name="l00174"></a>00174                                 <span class="keyword">const</span> <a class="code" href="classmrpt_1_1utils_1_1_c_config_file_base.html" title="This class allows loading and storing values and vectors of different types from a configuration text...">mrpt::utils::CConfigFileBase</a> &amp;configSource,
<a name="l00175"></a>00175                                 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>                       &amp;section ) = 0;
<a name="l00176"></a>00176 
<a name="l00177"></a>00177                 <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00178"></a>00178 <span class="comment">                        /** Creates a sensor by a name of the class.</span>
<a name="l00179"></a>00179 <span class="comment">                          *  Typically the user may want to create a smart pointer around the returned pointer, whis is made with:</span>
<a name="l00180"></a>00180 <span class="comment">                          *  \code</span>
<a name="l00181"></a>00181 <span class="comment">                          *   CGenericSensorPtr sensor = CGenericSensorPtr( CGenericSensor::createSensor(&quot;XXX&quot;) );</span>
<a name="l00182"></a>00182 <span class="comment">                          *  \endcode</span>
<a name="l00183"></a>00183 <span class="comment">                          * \return A pointer to a new class, or NULL if class name is unknown.</span>
<a name="l00184"></a>00184 <span class="comment">                          */</span>
<a name="l00185"></a>00185                         <span class="keyword">static</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html" title="A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...">CGenericSensor</a>* createSensor(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a> &amp;className);
<a name="l00186"></a>00186 <span class="comment"></span>
<a name="l00187"></a>00187 <span class="comment">                        /** Just like createSensor, but returning a smart pointer to the newly created sensor object. */</span>
<a name="l00188"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#aff4e4450e420bf60a2487ab0cff91907">00188</a>                         <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="classstlplus_1_1smart__ptr.html">CGenericSensorPtr</a> createSensorPtr(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a> &amp;className)
<a name="l00189"></a>00189                         {
<a name="l00190"></a>00190                                 <span class="keywordflow">return</span> <a class="code" href="namespacemrpt_1_1hwdrivers.html#a71aef48ea8dd23e43c706cc1a3ae0e74">CGenericSensorPtr</a>(createSensor(className));
<a name="l00191"></a>00191                         }
<a name="l00192"></a>00192 <span class="comment"></span>
<a name="l00193"></a>00193 <span class="comment">                        /** Constructor */</span>
<a name="l00194"></a>00194                         <a class="code" href="namespacemrpt_1_1hwdrivers.html#a3f369b2dbc16368a52f0ddab62ba5702">CGenericSensor</a>( );
<a name="l00195"></a>00195 <span class="comment"></span>
<a name="l00196"></a>00196 <span class="comment">                        /** Destructor */</span>
<a name="l00197"></a>00197                         <span class="keyword">virtual</span> ~<a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html" title="A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...">CGenericSensor</a>();
<a name="l00198"></a>00198 <span class="comment"></span>
<a name="l00199"></a>00199 <span class="comment">                        /** Loads the generic settings common to any sensor (See CGenericSensor), then call to &quot;loadConfig_sensorSpecific&quot;</span>
<a name="l00200"></a>00200 <span class="comment">                          *  \exception This method throws an exception with a descriptive message if some critical parameter is missing or has an invalid value.</span>
<a name="l00201"></a>00201 <span class="comment">                          */</span>
<a name="l00202"></a>00202                         <span class="keywordtype">void</span>  loadConfig(
<a name="l00203"></a>00203                                 <span class="keyword">const</span> <a class="code" href="classmrpt_1_1utils_1_1_c_config_file_base.html" title="This class allows loading and storing values and vectors of different types from a configuration text...">mrpt::utils::CConfigFileBase</a> &amp;configSource,
<a name="l00204"></a>00204                                 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>                       &amp;section );
<a name="l00205"></a>00205 <span class="comment"></span>
<a name="l00206"></a>00206 <span class="comment">                        /** This method can or cannot be implemented in the derived class, depending on the need for it.</span>
<a name="l00207"></a>00207 <span class="comment">                          *  \exception This method must throw an exception with a descriptive message if some critical error is found.</span>
<a name="l00208"></a>00208 <span class="comment">                          */</span>
<a name="l00209"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a775782a8fef4c5cd11265024431ed8c3">00209</a>                         <span class="keyword">virtual</span> <span class="keywordtype">void</span> initialize()
<a name="l00210"></a>00210                         {  }    <span class="comment">// Default method does nothing.</span>
<a name="l00211"></a>00211 <span class="comment"></span>
<a name="l00212"></a>00212 <span class="comment">                        /** This method will be invoked at a minimum rate of &quot;process_rate&quot; (Hz)</span>
<a name="l00213"></a>00213 <span class="comment">                          *  \exception This method must throw an exception with a descriptive message if some critical error is found.</span>
<a name="l00214"></a>00214 <span class="comment">                          */</span>
<a name="l00215"></a>00215                         <span class="keyword">virtual</span> <span class="keywordtype">void</span> doProcess() = 0;
<a name="l00216"></a>00216 <span class="comment"></span>
<a name="l00217"></a>00217 <span class="comment">                        /** Returns a list of enqueued objects, emptying it (thread-safe). The objects must be freed by the invoker.</span>
<a name="l00218"></a>00218 <span class="comment">                          */</span>
<a name="l00219"></a>00219                         <span class="keywordtype">void</span> getObservations( TListObservations         &amp;lstObjects );
<a name="l00220"></a>00220 <span class="comment"></span>
<a name="l00221"></a>00221 <span class="comment">                        /**  Set the path where to save off-rawlog image files (will be ignored in those sensors where this is not applicable).</span>
<a name="l00222"></a>00222 <span class="comment">                          *  An  empty string (the default value at construction) means to save images embedded in the rawlog, instead of on separate files.</span>
<a name="l00223"></a>00223 <span class="comment">                          * \exception std::exception If the directory doesn&#39;t exists and cannot be created.</span>
<a name="l00224"></a>00224 <span class="comment">                          */</span>
<a name="l00225"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#afa55ff06dbf360c8f631d371d6ebe35d">00225</a>                         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#afa55ff06dbf360c8f631d371d6ebe35d" title="Set the path where to save off-rawlog image files (will be ignored in those sensors where this is not...">setPathForExternalImages</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a> &amp;directory ) {
<a name="l00226"></a>00226                                 <span class="comment">// In this base class, the default is to ignore image paths.</span>
<a name="l00227"></a>00227                         }
<a name="l00228"></a>00228 <span class="comment"></span>
<a name="l00229"></a>00229 <span class="comment">                        /**  Set the extension (&quot;jpg&quot;,&quot;gif&quot;,&quot;png&quot;,...) that determines the format of images saved externally</span>
<a name="l00230"></a>00230 <span class="comment">                          *   The default is &quot;jpg&quot;.</span>
<a name="l00231"></a>00231 <span class="comment">                          * \sa setPathForExternalImages, setExternalImageJPEGQuality</span>
<a name="l00232"></a>00232 <span class="comment">                          */</span>
<a name="l00233"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#aff4b208b901763557196b9326901c582">00233</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#aff4b208b901763557196b9326901c582" title="Set the extension (&quot;jpg&quot;,&quot;gif&quot;,&quot;png&quot;,...) that determines the format of images saved externally The d...">setExternalImageFormat</a>( <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a> &amp;ext ) {
<a name="l00234"></a>00234                                 m_external_images_format = ext;
<a name="l00235"></a>00235                         }
<a name="l00236"></a>00236 <span class="comment"></span>
<a name="l00237"></a>00237 <span class="comment">                        /** The quality of JPEG compression, when external images is enabled and the format is &quot;jpg&quot;. \sa setExternalImageFormat */</span>
<a name="l00238"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#aca05f7ee991ee112b5e9f8f289a9ee94">00238</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#aca05f7ee991ee112b5e9f8f289a9ee94" title="The quality of JPEG compression, when external images is enabled and the format is &quot;jpg&quot;...">setExternalImageJPEGQuality</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> quality) {
<a name="l00239"></a>00239                                 m_external_images_jpeg_quality = quality;
<a name="l00240"></a>00240                         }
<a name="l00241"></a><a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a9d5aecec9f302feede271c9f1425a323">00241</a>                         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classmrpt_1_1hwdrivers_1_1_c_generic_sensor.html#a9d5aecec9f302feede271c9f1425a323">getExternalImageJPEGQuality</a>()<span class="keyword">const  </span>{
<a name="l00242"></a>00242                                 <span class="keywordflow">return</span> m_external_images_jpeg_quality;
<a name="l00243"></a>00243                         }
<a name="l00244"></a>00244 
<a name="l00245"></a>00245                 }; <span class="comment">// end of class</span>
<a name="l00246"></a>00246 
<a name="l00247"></a>00247 
<a name="l00248"></a><a class="code" href="_c_generic_sensor_8h.html#a9f1b606f47df314fba2e4a2509e02546">00248</a> <span class="preprocessor">                #define SENSOR_CLASS_ID(class_name) \</span>
<a name="l00249"></a>00249 <span class="preprocessor">                        static_cast&lt;const mrpt::hwdrivers::TSensorClassId*&gt;(&amp; mrpt::hwdrivers::class_name::class##class_name)</span>
<a name="l00250"></a>00250 <span class="preprocessor"></span>
<a name="l00251"></a><a class="code" href="_c_generic_sensor_8h.html#ad129b71e6d398e603d9444fe527120c4">00251</a> <span class="preprocessor">                #define SENSOR_IS_CLASS( ptrObj, class_name )  (ptrObj-&gt;GetRuntimeClass()==SENSOR_CLASS_ID(class_name))</span>
<a name="l00252"></a>00252 <span class="preprocessor"></span>
<a name="l00253"></a>00253 <span class="comment"></span>
<a name="l00254"></a>00254 <span class="comment">                /** This declaration must be inserted in all CGenericSensor classes definition, within the class declaration.</span>
<a name="l00255"></a>00255 <span class="comment">                  */</span>
<a name="l00256"></a><a class="code" href="_c_generic_sensor_8h.html#ab8b72c811c520eb036fa4080d9cd9d1d">00256</a> <span class="preprocessor">                #define DEFINE_GENERIC_SENSOR(class_name) \</span>
<a name="l00257"></a>00257 <span class="preprocessor">                protected: \</span>
<a name="l00258"></a>00258 <span class="preprocessor">                        static mrpt::hwdrivers::CGenericSensor::CLASSINIT_GENERIC_SENSOR _init_##class_name;\</span>
<a name="l00259"></a>00259 <span class="preprocessor">                public: \</span>
<a name="l00260"></a>00260 <span class="preprocessor">                        static  mrpt::hwdrivers::TSensorClassId class##class_name; \</span>
<a name="l00261"></a>00261 <span class="preprocessor">                        virtual const mrpt::hwdrivers::TSensorClassId* GetRuntimeClass() const; \</span>
<a name="l00262"></a>00262 <span class="preprocessor">                        static  mrpt::hwdrivers::CGenericSensor* CreateObject(); \</span>
<a name="l00263"></a>00263 <span class="preprocessor">                        static void doRegister() \</span>
<a name="l00264"></a>00264 <span class="preprocessor">                        {       CGenericSensor::registerClass( SENSOR_CLASS_ID( class_name ) ); }</span>
<a name="l00265"></a>00265 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00266"></a>00266 <span class="comment">                /** This must be inserted in all CGenericSensor classes implementation files:</span>
<a name="l00267"></a>00267 <span class="comment">                  */</span>
<a name="l00268"></a><a class="code" href="_c_generic_sensor_8h.html#ac3c515c8c914f6b6e838ac586526f179">00268</a> <span class="preprocessor">                #define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace) \</span>
<a name="l00269"></a>00269 <span class="preprocessor">                        mrpt::hwdrivers::CGenericSensor* NameSpace::class_name::CreateObject() \</span>
<a name="l00270"></a>00270 <span class="preprocessor">                                { return static_cast&lt;hwdrivers::CGenericSensor*&gt;( new NameSpace::class_name ); } \</span>
<a name="l00271"></a>00271 <span class="preprocessor">                        mrpt::hwdrivers::TSensorClassId NameSpace::class_name::class##class_name = { \</span>
<a name="l00272"></a>00272 <span class="preprocessor">                                #class_name, NameSpace::class_name::CreateObject }; \</span>
<a name="l00273"></a>00273 <span class="preprocessor">                        const mrpt::hwdrivers::TSensorClassId* NameSpace::class_name::GetRuntimeClass() const \</span>
<a name="l00274"></a>00274 <span class="preprocessor">                                { return SENSOR_CLASS_ID(class_name); }</span>
<a name="l00275"></a>00275 <span class="preprocessor"></span>
<a name="l00276"></a>00276 
<a name="l00277"></a>00277         } <span class="comment">// end of namespace</span>
<a name="l00278"></a>00278 } <span class="comment">// end of namespace</span>
<a name="l00279"></a>00279 
<a name="l00280"></a>00280 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<br><hr><br> <table border="0" width="100%"> <tr> <td> Page generated by <a href="http://www.doxygen.org" target="_blank">Doxygen 1.7.5</a> for MRPT 0.9.5 SVN: at Sun Sep 25 17:20:18 UTC 2011</td><td></td> <td width="100"> </td> <td width="150">  </td></tr> </table>  </body></html>