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://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 
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                  */
00088                 enum SensorType{SHARP_30cm, SHARP_80cm, EZ1, UNPLUGGED};
00089 
00090                 class HWDRIVERS_IMPEXP CPhidgetInterfaceKitProximitySensors : public utils::CDebugOutputCapable, public CGenericSensor
00091                 {
00092                         DEFINE_GENERIC_SENSOR(CPhidgetInterfaceKitProximitySensors)
00093 
00094                 public:
00095                         /** Constructor
00096                           * \param serialNumber The board's serial number. Set -1 to choose the first available board
00097                           */
00098                         CPhidgetInterfaceKitProximitySensors();
00099 
00100                         /** Destructor
00101                           */
00102                         virtual ~CPhidgetInterfaceKitProximitySensors();
00103 
00104                         /** This method tries to get a set of range measurements from the IR sensors.
00105                           * \param outThereIsObservation Will be true if an observation was sucessfully received.
00106                           */
00107                         void  getObservation(mrpt::slam::CObservationRange      &outObservation);
00108                         /** Initialize the sensor according to the parameters previously read in the configuration file.
00109                          * \exception throw an exception if the board could not be found.
00110                          * \exception throw an exception if the process rate can't be set on one of the board channel.
00111                          */
00112                         void initialize();
00113 
00114                         /** This method should be called periodically. Period depend on the process_rate in the configuration file.
00115                          */
00116                         void  doProcess();
00117 
00118                 private:
00119                         /** An 8 dimension vector of boolean value wich store the presence or abscence of a sensor on the phidget interface kit board.
00120                           */
00121                         std::vector<bool>                       m_sensorIsPlugged;
00122                         /** The minimum range in meters, this field is automaticaly filled according to the sensor part number read in the configuration file.
00123                           * Size of this vector depend on the number of sensors described in the configuration file.
00124                           */
00125                         std::vector<float>                      m_minRange;
00126 
00127                         /** The maximum range in meters, this field is automaticaly filled according to the sensor part number read in the configuration file.
00128                           * Size of this vector depend on the number of sensors described in the configuration file.
00129                           */
00130                         std::vector<float>                      m_maxRange;
00131 
00132                         /** The sensor type.
00133                           */
00134                         std::vector<SensorType>         m_sensorType;
00135                         /** 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
00136                           * described in the configuration file.
00137                           */
00138                         std::vector<mrpt::math::CPose3D>        m_sensorPoses;
00139 
00140                         /** The board serial number read in the configuration file. -1 for any  board.
00141                          */
00142                         int m_serialNumber;
00143                         float m_minOfMinRanges;
00144                         float m_maxOfMaxRanges;
00145 
00146                         void* m_carteInterfaceKit; //CPhidgetInterfaceKitHandle
00147 
00148                         /** 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)
00149                           *  See hwdrivers::CGPSInterface for the possible parameters
00150                           */
00151                         void  loadConfig_sensorSpecific( const mrpt::utils::CConfigFileBase &configSource,
00152                                                                                          const std::string        &iniSection );
00153                 }; // end class
00154 
00155         } // end namespace
00156 } // end namespace
00157 
00158 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011