MRPT  1.9.9
CPhidgetInterfaceKitProximitySensors.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef CPhidgetInterfaceKitProximitySensors_H
11 #define CPhidgetInterfaceKitProximitySensors_H
12 
14 #include <mrpt/poses/CPoint3D.h>
17 
18 namespace mrpt::hwdrivers
19 {
20 /** \brief : An interface for the phidget Interface kit board (1018).
21  * \class CPhidgetInterfaceKitProximitySensors
22  * \author Adrien BARRAL - Robopec (aba@robopec.com).
23  *
24  * An interface for the Phidgets Interface kit board (part number 1018) on wich
25  * it could be plugged either an Sharp IR adaptater board
26  * (phidget's part number : 1101),or a MaxBotix EZ-1 sonar (phidget's part
27  * number : 1118).
28  * The configuration file describe what is plugged to this board, and the
29  * geometry of the sensors on the robots. See the exemple below.
30  * \code
31  * [PhidgetInterfaceKitProximitySensors]
32  * sensorLabel = FrontProximitySensors
33  * process_rate = 100 // Integer value in Hz (common to
34  * all
35  * sensors),
36  * default value is 50Hz.
37  * displayRecapitulativeInformations = true // default value = false.
38  * serialNumber = 12345 // The interface kit serial number
39  * (Integer
40  * value),
41  * default value is -1.
42  * sensor1 = SHARP-30cm // sharp InfraRed sensor 30cm range
43  * (string
44  * value).
45  * capital to convert raw data to range data (in meters).
46  * pose1_x = 0 // position on the robot (float
47  * value
48  * in
49  * meters)
50  * pose1_y = 0
51  * pose1_z = 0.5
52  * pose1_yaw = -45.0 // Angles in degrees (float value).
53  * pose1_pitch = 0
54  * pose1_roll = 0
55  * //...
56  * sensorn = EZ1 // Maxbotix Ultrasound sonar
57  * posen_x = 0
58  * // ...
59  * \endcode
60  *
61  * The maximum number of sensors on this board is 8. Sensor 1 is the first
62  * sensor. If you haven't plugged any sensor on an entry of the board, you
63  * haven't to specify
64  * anyithing about this sensor in the configuration file.
65  * The following table enumerate the different sensors supported by this class.
66  * \latexonly
67  * \begin{tabular}{|c|c|c}
68  * \hline
69  * Part Number & Config file indentifiant & IR or US
70  * \hline
71  * MaxBotix EZ-1 Sonar Sensor & EZ1 & US \\
72  * GP2D12 & SHARP-30cm & IR \\
73  * GP2Y0A21** & SHARP-80cm & IR \\
74  * \hline
75  * \end{tabular}
76  *
77  * This isn't an event based implementation of the phidget library. That means
78  * that when an instanciation of a CPhidgetInterfaceKitProximitySensors is done,
79  * the constructor will block during
80  * in the worst case 200ms, if the board isn't found, an exception will be
81  * thrown.
82  * mrpt::obs::CObservation returned by this class is a CObservationRange.
83  * CObservationrange::minSensorDistance will be the minimum of the minimum of
84  * the sensor distances, e.g if you plug to the interface
85  * kit a GP2D12 (min range 4 cm) and a GP2Y0A21 (min range 8 cm), then
86  * CObservationrange::minSensorDistance = min(0.04,0.08) = 0.04. Respectively
87  * for the maximal range.
88  * \endlatexonly
89  * \warning{The Phidget library use udev. By default, udev require to be root to
90  * be launched, if you want to be able to run a program wich use a phidget board
91  * without be root, you must modify files in /etc/udev/rules.d .}
92  * \ingroup mrpt_hwdrivers_grp
93  */
95 {
98  EZ1,
99  UNPLUGGED
100 };
101 
103  public CGenericSensor
104 {
106 
107  public:
108  /** Constructor
109  * \param serialNumber The board's serial number. Set -1 to choose the
110  * first available board
111  */
113 
114  /** Destructor
115  */
117 
118  /** This method tries to get a set of range measurements from the IR
119  * sensors.
120  * \param outThereIsObservation Will be true if an observation was
121  * sucessfully received.
122  */
123  void getObservation(mrpt::obs::CObservationRange& outObservation);
124  /** Initialize the sensor according to the parameters previously read in the
125  * configuration file.
126  * \exception throw an exception if the board could not be found.
127  * \exception throw an exception if the process rate can't be set on one of
128  * the board channel.
129  */
130  void initialize();
131 
132  /** This method should be called periodically. Period depend on the
133  * process_rate in the configuration file.
134  */
135  void doProcess();
136 
137  private:
138  /** An 8 dimension vector of boolean value wich store the presence or
139  * abscence of a sensor on the phidget interface kit board.
140  */
141  std::vector<bool> m_sensorIsPlugged;
142  /** The minimum range in meters, this field is automaticaly filled according
143  * to the sensor part number read in the configuration file.
144  * Size of this vector depend on the number of sensors described in the
145  * configuration file.
146  */
147  std::vector<float> m_minRange;
148 
149  /** The maximum range in meters, this field is automaticaly filled according
150  * to the sensor part number read in the configuration file.
151  * Size of this vector depend on the number of sensors described in the
152  * configuration file.
153  */
154  std::vector<float> m_maxRange;
155 
156  /** The sensor type.
157  */
158  std::vector<SensorType> m_sensorType;
159  /** The poses of the 8 sensors x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg].
160  * This field is automaticaly filled according to the sensor
161  * described in the configuration file.
162  */
163  std::vector<mrpt::poses::CPose3D> m_sensorPoses;
164 
165  /** The board serial number read in the configuration file. -1 for any
166  * board.
167  */
171 
172  void* m_carteInterfaceKit; // CPhidgetInterfaceKitHandle
173 
174  /** See the class documentation at the top for expected parameters */
176  const mrpt::config::CConfigFileBase& configSource,
177  const std::string& iniSection);
178 }; // end class
179 
180 }
181 #endif
182 
183 
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
This class allows loading and storing values and vectors of different types from a configuration text...
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
: An interface for the phidget Interface kit board (1018).
std::vector< float > m_minRange
The minimum range in meters, this field is automaticaly filled according to the sensor part number re...
std::vector< mrpt::poses::CPose3D > m_sensorPoses
The poses of the 8 sensors x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg].
std::vector< bool > m_sensorIsPlugged
An 8 dimension vector of boolean value wich store the presence or abscence of a sensor on the phidget...
void initialize()
Initialize the sensor according to the parameters previously read in the configuration file.
int m_serialNumber
The board serial number read in the configuration file.
std::vector< float > m_maxRange
The maximum range in meters, this field is automaticaly filled according to the sensor part number re...
void getObservation(mrpt::obs::CObservationRange &outObservation)
This method tries to get a set of range measurements from the IR sensors.
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection)
See the class documentation at the top for expected parameters.
Declares a class derived from "CObservation" that encapsules a single range measurement,...
Versatile class for consistent logging and management of output messages.
GLsizei const GLchar ** string
Definition: glext.h:4101
Contains classes for various device interfaces.



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 814d80880 Fri Aug 24 01:51:28 2018 +0200 at mar 26 may 2026 12:30:59 CEST