Main MRPT website > C++ reference
MRPT logo
CBoardENoses.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 CBoardENoses_H
30 #define CBoardENoses_H
31 
35 
38 
39 
40 namespace mrpt
41 {
42  namespace hwdrivers
43  {
44  /** A class for interfacing an e-Noses via a FTDI USB link.
45  * Implemented for the board v1.0 designed by 2007 @ ISA (University of Malaga).
46  *
47  * \code
48  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
49  * -------------------------------------------------------
50  * [supplied_section_name]
51  * USB_serialname=ENOSE001 // USB FTDI pipe: will open only if COM_port_* are not set or empty
52  *
53  * COM_port_WIN = COM1 // Serial port to connect to.
54  * COM_port_LIN = ttyS0
55  *
56  * COM_baudRate = 115200
57  *
58  * ; 3D position (in meters) of the master +slave eNoses
59  * enose_poses_x=<MASTER X> <SLAVE#1 X> <SLAVE#2 X> <SLAVE#3 X>...
60  * enose_poses_y=<MASTER Y> <SLAVE#1 Y> <SLAVE#2 Y> <SLAVE#3 Y>...
61  * enose_poses_z=<MASTER Z> <SLAVE#1 Z> <SLAVE#2 Z> <SLAVE#3 Z>...
62  *
63  * ; 3D pose angles (in degrees) of the master +slave eNoses
64  * enose_poses_yaw=<MASTER YAW> <SLAVE#1 YAW> <SLAVE#2 YAW> <SLAVE#3 YAW>...
65  * enose_poses_pitch=<MASTER PITCH> <SLAVE#1 PITCH> <SLAVE#2 PITCH> <SLAVE#3 PITCH>...
66  * enose_poses_roll=<MASTER ROLL> <SLAVE#1 ROLL> <SLAVE#2 ROLL> <SLAVE#3 ROLL>...
67  *
68  * \endcode
69  *
70  * \ingroup mrpt_hwdrivers_grp
71  */
73  {
75 
76  protected:
77  /** A copy of the device serial number (to open the USB FTDI chip)
78  */
79  std::string m_usbSerialNumber;
82 
83  std::string m_COM_port; //!< If not an empty string (default), will open that serial port, otherwise will try to open USB FTDI device "m_usbSerialNumber"
84  unsigned int m_COM_baud; //!< Default=115200
85 
86 
87  // Only one of these two streams will be !=NULL and open for each specific eNose board!
88  /** FTDI comms pipe (when not in serial port mode) */
90  /** Serial port comms */
92 
93  /** The 3D pose of the master + N slave eNoses on the robot (meters & radians) */
94  std::vector<float> enose_poses_x,enose_poses_y,enose_poses_z,enose_poses_yaw,enose_poses_pitch,enose_poses_roll;
95 
96  /** Tries to connect to the USB device (if disconnected).
97  * \return NULL on error, otherwise a stream to be used for comms.
98  */
99  mrpt::utils::CStream* checkConnectionAndConnect();
100 
101  /** 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)
102  * See hwdrivers::CBoardENoses for the possible parameters
103  */
104  void loadConfig_sensorSpecific(
105  const mrpt::utils::CConfigFileBase &configSource,
106  const std::string &section );
107 
108  public:
109  /** Constructor
110  * \param serialNumberUSBdevice The serial number (text) of the device to open.
111  * The constructor will try to open the device. You can check if it failed calling "isOpen()".
112  */
113  CBoardENoses( );
114 
115  /** Destructor
116  */
117  virtual ~CBoardENoses();
118 
119  /** Set the active chamber (afected by poluted air) on the device
120  * \return true on success, false on communications errors or device not found.
121  */
122  bool setActiveChamber( unsigned char chamber );
123 
124  /** Query the firmware version on the device (can be used to test communications).
125  * \return true on success, false on communications errors or device not found.
126  */
127  bool queryFirmwareVersion( std::string &out_firmwareVersion );
128 
129  /** Request the master eNose the latest readings from all the eNoses.
130  * The output observation contains a valid timestamp and 3D positions if "loadConfig" has been called previously.
131  * \return true if OK, false if there were any error.
132  */
133  bool getObservation( mrpt::slam::CObservationGasSensors &outObservation );
134 
135 
136  /** This method should be called periodically (at least at 1Hz to capture ALL the real-time data)
137  * It is thread safe, i.e. you can call this from one thread, then to other methods from other threads.
138  */
139  void doProcess();
140 
141  /** Tries to open the camera, after setting all the parameters with a call to loadConfig.
142  * \exception This method must throw an exception with a descriptive message if some critical error is found.
143  */
144  virtual void initialize();
145 
146 
147 
148  /** If not an empty string, will open that serial port, otherwise will try to open USB FTDI device "m_usbSerialNumber"
149  * The default is an empty string. Example strings: "COM1", "ttyUSB0", ...
150  */
151  inline void setSerialPort(const std::string &port) { m_COM_port = port; }
152  inline std::string getSerialPort() const { return m_COM_port; }
153 
154  /** Set the serial port baud rate (default: 115200) */
155  inline void setSerialPortBaud(unsigned int baud) { m_COM_baud=baud; }
156  inline unsigned int getSerialPortBaud() const { return m_COM_baud; }
157 
158 
159  }; // end of class
160  } // end of namespace
161 } // end of namespace
162 
163 
164 #endif
165 
166 



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