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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019