Main MRPT website > C++ reference
MRPT logo
CPhidgetInterfaceKitProximitySensors.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef CPhidgetInterfaceKitProximitySensors_H
30 #define CPhidgetInterfaceKitProximitySensors_H
31 
33 #include <mrpt/poses/CPoint3D.h>
36 
37 namespace mrpt
38 {
39  namespace hwdrivers
40  {
41  /** \brief : An interface for the phidget Interface kit board (1018).
42  * \class CPhidgetInterfaceKitProximitySensors
43  * \author Adrien BARRAL - Robopec (aba@robopec.com).
44  *
45  * An interface for the Phidgets Interface kit board (part number 1018) on wich it could be plugged either an Sharp IR adaptater board
46  * (phidget's part number : 1101),or a MaxBotix EZ-1 sonar (phidget's part number : 1118).
47  * The configuration file describe what is plugged to this board, and the geometry of the sensors on the robots. See the exemple below.
48  * \code
49  * [PhidgetInterfaceKitProximitySensors]
50  * sensorLabel = FrontProximitySensors
51  * process_rate = 100 // Integer value in Hz (common to all sensors), default value is 50Hz.
52  * displayRecapitulativeInformations = true // default value = false.
53  * serialNumber = 12345 // The interface kit serial number (Integer value), default value is -1.
54  * sensor1 = SHARP-30cm // sharp InfraRed sensor 30cm range (string value). capital to convert raw data to range data (in meters).
55  * pose1_x = 0 // position on the robot (float value in meters)
56  * pose1_y = 0
57  * pose1_z = 0.5
58  * pose1_yaw = -45.0 // Angles in degrees (float value).
59  * pose1_pitch = 0
60  * pose1_roll = 0
61  * //...
62  * sensorn = EZ1 // Maxbotix Ultrasound sonar
63  * posen_x = 0
64  * // ...
65  * \endcode
66  *
67  * 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
68  * anyithing about this sensor in the configuration file.
69  * The following table enumerate the different sensors supported by this class.
70  * \latexonly
71  * \begin{tabular}{|c|c|c}
72  * \hline
73  * Part Number & Config file indentifiant & IR or US
74  * \hline
75  * MaxBotix EZ-1 Sonar Sensor & EZ1 & US \\
76  * GP2D12 & SHARP-30cm & IR \\
77  * GP2Y0A21** & SHARP-80cm & IR \\
78  * \hline
79  * \end{tabular}
80  *
81  * 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
82  * in the worst case 200ms, if the board isn't found, an exception will be thrown.
83  * 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
84  * 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.
85  * \endlatexonly
86  * \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 .}
87  * \ingroup mrpt_hwdrivers_grp
88  */
90 
92  {
94 
95  public:
96  /** Constructor
97  * \param serialNumber The board's serial number. Set -1 to choose the first available board
98  */
100 
101  /** Destructor
102  */
104 
105  /** This method tries to get a set of range measurements from the IR sensors.
106  * \param outThereIsObservation Will be true if an observation was sucessfully received.
107  */
108  void getObservation(mrpt::slam::CObservationRange &outObservation);
109  /** Initialize the sensor according to the parameters previously read in the configuration file.
110  * \exception throw an exception if the board could not be found.
111  * \exception throw an exception if the process rate can't be set on one of the board channel.
112  */
113  void initialize();
114 
115  /** This method should be called periodically. Period depend on the process_rate in the configuration file.
116  */
117  void doProcess();
118 
119  private:
120  /** An 8 dimension vector of boolean value wich store the presence or abscence of a sensor on the phidget interface kit board.
121  */
122  std::vector<bool> m_sensorIsPlugged;
123  /** The minimum range in meters, this field is automaticaly filled according to the sensor part number read in the configuration file.
124  * Size of this vector depend on the number of sensors described in the configuration file.
125  */
126  std::vector<float> m_minRange;
127 
128  /** The maximum range in meters, this field is automaticaly filled according to the sensor part number read in the configuration file.
129  * Size of this vector depend on the number of sensors described in the configuration file.
130  */
131  std::vector<float> m_maxRange;
132 
133  /** The sensor type.
134  */
135  std::vector<SensorType> m_sensorType;
136  /** 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
137  * described in the configuration file.
138  */
139  std::vector<mrpt::math::CPose3D> m_sensorPoses;
140 
141  /** The board serial number read in the configuration file. -1 for any board.
142  */
146 
147  void* m_carteInterfaceKit; //CPhidgetInterfaceKitHandle
148 
149  /** 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)
150  * See hwdrivers::CGPSInterface for the possible parameters
151  */
152  void loadConfig_sensorSpecific( const mrpt::utils::CConfigFileBase &configSource,
153  const std::string &iniSection );
154  }; // end class
155 
156  } // end namespace
157 } // end namespace
158 
159 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013