Main MRPT website > C++ reference
MRPT logo
CBoardIR.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 CBoardIR_H
30 #define CBoardIR_H
31 
33 #include <mrpt/poses/CPoint3D.h>
37 
38 namespace mrpt
39 {
40  namespace slam { class CObservationGPS; }
41 
42  namespace hwdrivers
43  {
44  /** A parser of NMEA commands, for connecting to a GPS by a serial port.
45  * This class also supports more advanced GPS equipped with RTK corrections. See the JAVAD/TopCon extra initialization parameters.
46  *
47  * \code
48  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
49  * -------------------------------------------------------
50  * [supplied_section_name]
51  * COM_port_WIN = COM3
52  * COM_port_LIN = ttyS0
53  * baudRate = 4800 // The baudrate of the communications (typ. 4800 bauds)
54  * pose_x = 0 // 3D position of the sensed point relative to the robot (meters)
55  * pose_y = 0
56  * pose_z = 0
57  * customInit = // See below for possible values
58  *
59  * // The next parameters are optional and will be used only
60  * // if customInit=="JAVAD" to enable/configure the usage of RTK corrections:
61  * //JAVAD_rtk_src_port=/dev/ser/b
62  * //JAVAD_rtk_src_baud=9600
63  * //JAVAD_rtk_format=cmr
64  *
65  * \endcode
66  *
67  * - customInit: Custom commands to send, depending on the sensor. Valid values are:
68  * - "": Empty string
69  * - "JAVAD": JAVAD or TopCon devices. Extra initialization commands will be sent.
70  * - "TopCon": A synonymous with "JAVAD".
71  *
72  * VERSIONS HISTORY:
73  * -9/JUN/2006: First version (JLBC)
74  * -4/JUN/2008: Added virtual methods for device-specific initialization commands.
75  * -10/JUN/2008: Converted into CGenericSensor class (there are no inhirited classes anymore).
76  * \ingroup mrpt_hwdrivers_grp
77  */
79  {
81 
82  public:
83  /** Constructor
84  * \param BUFFER_LENGTH The size of the communications buffer (default value should be fine always)
85  */
86  CBoardIR( int BUFFER_LENGTH = 13 );
87 
88  /** Destructor
89  */
90  virtual ~CBoardIR();
91 
92  /** This method tries to get a set of range measurements from the IR sensors.
93  * \param outObservation The output observation
94  * \param outThereIsObservation Will be true if an observation was sucessfully received.
95  * \param hardwareError Will be true if there's some important error, e.g. serial port can't be open.
96  */
97  void getObservation(
98  bool &outThereIsObservation,
99  mrpt::slam::CObservationRange &outObservation,
100  bool &hardwareError );
101 
102  /** This method should be called periodically (at least at 1Hz to capture ALL the real-time data)
103  * It is thread safe, i.e. you can call this from one thread, then to other methods from other threads.
104  * This method processes data from the GPS and update the object state accordingly.
105  */
106  void doProcess();
107 
108  void setSerialPortName(const std::string &COM_port); //!< Set the serial port to use (COM1, ttyUSB0, etc).
109  std::string getSerialPortName() const; //!< Get the serial port to use (COM1, ttyUSB0, etc).
110 
111  protected:
112  bool OnConnectionEstablished();
113 
115 
117 
118  std::string m_customInit;
119 
120  /** The minimum range in meters (10cm).
121  */
122  float m_minRange;
123 
124  /** The maximum range in meters (80cm).
125  */
126  float m_maxRange;
127 
128  /** The poses of the IR: x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg]
129  * Up to 6 devices, but you can put any number of devices (from 1 to 6).
130  */
131  std::map<uint16_t,mrpt::math::TPose3D> m_IRPoses;
132 
133  /** 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)
134  * See hwdrivers::CGPSInterface for the possible parameters
135  */
136  void loadConfig_sensorSpecific(
137  const mrpt::utils::CConfigFileBase &configSource,
138  const std::string &iniSection );
139 
140  private:
141  std::string m_COMname;
143 
144  /** Returns true if the COM port is already open, or try to open it in other case.
145  * \return true if everything goes OK, or false if there are problems opening the port.
146  */
147  bool tryToOpenTheCOM();
148 
149  }; // end class
150 
151  } // end namespace
152 } // end namespace
153 
154 #endif



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