Main MRPT website > C++ reference
MRPT logo
CPhidgetInterfaceKitProximitySensors.h
Go to the documentation of this file.
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 CPhidgetInterfaceKitProximitySensors_H
00030 #define CPhidgetInterfaceKitProximitySensors_H
00031 
00032 #include <mrpt/slam/CObservationRange.h>
00033 #include <mrpt/poses/CPoint3D.h>
00034 #include <mrpt/utils/CDebugOutputCapable.h>
00035 #include <mrpt/hwdrivers/CGenericSensor.h>
00036 
00037 namespace mrpt
00038 {
00039         namespace hwdrivers
00040         {
00041                 /** \brief : An interface for the phidget Interface kit board (1018).
00042                  *  \class CPhidgetInterfaceKitProximitySensors
00043                  *  \author Adrien BARRAL - Robopec (aba@robopec.com).
00044                  *
00045                  * An interface for the Phidgets Interface kit board (part number 1018) on wich it could be plugged either an Sharp IR adaptater board
00046              * (phidget's part number : 1101),or a MaxBotix EZ-1 sonar (phidget's part number : 1118).
00047                  * The configuration file describe what is plugged to this board, and the geometry of the sensors on the robots. See the exemple below.
00048                  * \code
00049                  * [PhidgetInterfaceKitProximitySensors]
00050                  * sensorLabel = FrontProximitySensors
00051                  * process_rate = 100                                           // Integer value in Hz (common to all sensors), default value is 50Hz.
00052                  * displayRecapitulativeInformations = true     // default value = false.
00053                  * serialNumber = 12345                                         // The interface kit serial number (Integer value), default value is -1.
00054                  * sensor1 = SHARP-30cm                                         // sharp InfraRed sensor 30cm range (string value). capital to convert raw data to range data (in meters).
00055                  * pose1_x = 0                                                          // position on the robot (float value in meters)
00056                  * pose1_y = 0
00057                  * pose1_z = 0.5
00058                  * pose1_yaw = -45.0                                            // Angles in degrees (float value).
00059                  * pose1_pitch = 0
00060                  * pose1_roll = 0
00061                  *  //...
00062                  * sensorn = EZ1                                                        // Maxbotix Ultrasound sonar
00063                  * posen_x = 0
00064                  * // ...
00065                  * \endcode
00066                  *
00067                  * The maximum number of sensors on this board is 8. Sensor 1 is the first sensor. If you haven't plugged any sensor on an entry of the board, you haven't to specify
00068                  * anyithing about this sensor in the configuration file.
00069                  * The following table enumerate the different sensors supported by this class.
00070                  * \latexonly
00071                  * \begin{tabular}{|c|c|c}
00072              *          \hline
00073                  *              Part Number & Config file indentifiant & IR or US
00074                  *              \hline
00075                  *              MaxBotix EZ-1 Sonar Sensor & EZ1 & US \\
00076                  *              GP2D12 & SHARP-30cm & IR \\
00077                  *              GP2Y0A21** & SHARP-80cm & IR \\
00078                  *              \hline
00079                  * \end{tabular}
00080                  *
00081                  * This isn't an event based implementation of the phidget library. That means that when an instanciation of a CPhidgetInterfaceKitProximitySensors is done, the constructor will block during
00082                  * in the worst case 200ms, if the board isn't found, an exception will be thrown.
00083                  * CObservation returned by this class is a CObservationRange. CObservationrange::minSensorDistance will be the minimum of the minimum of the sensor distances, e.g if you plug to the interface
00084                  * kit a GP2D12 (min range 4 cm) and a GP2Y0A21 (min range 8 cm), then CObservationrange::minSensorDistance = min(0.04,0.08) = 0.04. Respectively for the maximal range.
00085                  * \endlatexonly
00086                  * \warning{The Phidget library use udev. By default, udev require to be root to be launched, if you want to be able to run a program wich use a phidget board without be root, you must modify files in /etc/udev/rules.d .}
00087                   * \ingroup mrpt_hwdrivers_grp
00088                  */
00089                 enum SensorType{SHARP_30cm, SHARP_80cm, EZ1, UNPLUGGED};
00090 
00091                 class HWDRIVERS_IMPEXP CPhidgetInterfaceKitProximitySensors : public utils::CDebugOutputCapable, public CGenericSensor
00092                 {
00093                         DEFINE_GENERIC_SENSOR(CPhidgetInterfaceKitProximitySensors)
00094 
00095                 public:
00096                         /** Constructor
00097                           * \param serialNumber The board's serial number. Set -1 to choose the first available board
00098                           */
00099                         CPhidgetInterfaceKitProximitySensors();
00100 
00101                         /** Destructor
00102                           */
00103                         virtual ~CPhidgetInterfaceKitProximitySensors();
00104 
00105                         /** This method tries to get a set of range measurements from the IR sensors.
00106                           * \param outThereIsObservation Will be true if an observation was sucessfully received.
00107                           */
00108                         void  getObservation(mrpt::slam::CObservationRange      &outObservation);
00109                         /** Initialize the sensor according to the parameters previously read in the configuration file.
00110                          * \exception throw an exception if the board could not be found.
00111                          * \exception throw an exception if the process rate can't be set on one of the board channel.
00112                          */
00113                         void initialize();
00114 
00115                         /** This method should be called periodically. Period depend on the process_rate in the configuration file.
00116                          */
00117                         void  doProcess();
00118 
00119                 private:
00120                         /** An 8 dimension vector of boolean value wich store the presence or abscence of a sensor on the phidget interface kit board.
00121                           */
00122                         std::vector<bool>                       m_sensorIsPlugged;
00123                         /** The minimum range in meters, this field is automaticaly filled according to the sensor part number read in the configuration file.
00124                           * Size of this vector depend on the number of sensors described in the configuration file.
00125                           */
00126                         std::vector<float>                      m_minRange;
00127 
00128                         /** The maximum range in meters, this field is automaticaly filled according to the sensor part number read in the configuration file.
00129                           * Size of this vector depend on the number of sensors described in the configuration file.
00130                           */
00131                         std::vector<float>                      m_maxRange;
00132 
00133                         /** The sensor type.
00134                           */
00135                         std::vector<SensorType>         m_sensorType;
00136                         /** The poses of the 8 sensors x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg]. This field is automaticaly filled according to the sensor
00137                           * described in the configuration file.
00138                           */
00139                         std::vector<mrpt::math::CPose3D>        m_sensorPoses;
00140 
00141                         /** The board serial number read in the configuration file. -1 for any  board.
00142                          */
00143                         int m_serialNumber;
00144                         float m_minOfMinRanges;
00145                         float m_maxOfMaxRanges;
00146 
00147                         void* m_carteInterfaceKit; //CPhidgetInterfaceKitHandle
00148 
00149                         /** Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes)
00150                           *  See hwdrivers::CGPSInterface for the possible parameters
00151                           */
00152                         void  loadConfig_sensorSpecific( const mrpt::utils::CConfigFileBase &configSource,
00153                                                                                          const std::string        &iniSection );
00154                 }; // end class
00155 
00156         } // end namespace
00157 } // end namespace
00158 
00159 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011