00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2010 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 00029 #ifndef CBoardENoses_H 00030 #define CBoardENoses_H 00031 00032 #include <mrpt/hwdrivers/CInterfaceFTDIMessages.h> 00033 #include <mrpt/hwdrivers/CGenericSensor.h> 00034 00035 #include <mrpt/slam/CObservationGasSensors.h> 00036 #include <mrpt/utils/CConfigFileBase.h> 00037 00038 00039 namespace mrpt 00040 { 00041 namespace hwdrivers 00042 { 00043 /** A class for interfacing an e-Noses via a FTDI USB link. 00044 * Implemented for the board v1.0 designed by 2007 @ ISA (University of Malaga). 00045 * 00046 * \code 00047 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00048 * ------------------------------------------------------- 00049 * [supplied_section_name] 00050 * USB_serialname=ENOSE001 00051 * 00052 * ; 3D position (in meters) of the master +slave eNoses 00053 * enose_poses_x=<MASTER X> <SLAVE#1 X> <SLAVE#2 X> <SLAVE#3 X>... 00054 * enose_poses_y=<MASTER Y> <SLAVE#1 Y> <SLAVE#2 Y> <SLAVE#3 Y>... 00055 * enose_poses_z=<MASTER Z> <SLAVE#1 Z> <SLAVE#2 Z> <SLAVE#3 Z>... 00056 * 00057 * ; 3D pose angles (in degrees) of the master +slave eNoses 00058 * enose_poses_yaw=<MASTER YAW> <SLAVE#1 YAW> <SLAVE#2 YAW> <SLAVE#3 YAW>... 00059 * enose_poses_pitch=<MASTER PITCH> <SLAVE#1 PITCH> <SLAVE#2 PITCH> <SLAVE#3 PITCH>... 00060 * enose_poses_roll=<MASTER ROLL> <SLAVE#1 ROLL> <SLAVE#2 ROLL> <SLAVE#3 ROLL>... 00061 * 00062 * \endcode 00063 * 00064 */ 00065 class HWDRIVERS_IMPEXP CBoardENoses : public mrpt::hwdrivers::CGenericSensor, public mrpt::hwdrivers::CInterfaceFTDIMessages 00066 { 00067 DEFINE_GENERIC_SENSOR(CBoardENoses) 00068 00069 protected: 00070 /** A copy of the device serial number (to open the USB FTDI chip) 00071 */ 00072 std::string m_usbSerialNumber; 00073 std::string m_sensorLabel; 00074 mrpt::system::TTimeStamp initial_timestamp; 00075 bool first_reading; 00076 00077 /** The 3D pose of the master + N slave eNoses on the robot (meters & radians) 00078 */ 00079 vector_float enose_poses_x,enose_poses_y,enose_poses_z,enose_poses_yaw,enose_poses_pitch,enose_poses_roll; 00080 00081 /** Tries to connect to the USB device (if disconnected). 00082 * \return True on connection OK, false on error. 00083 */ 00084 bool checkConnectionAndConnect(); 00085 00086 /** 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) 00087 * See hwdrivers::CBoardENoses for the possible parameters 00088 */ 00089 void loadConfig_sensorSpecific( 00090 const mrpt::utils::CConfigFileBase &configSource, 00091 const std::string §ion ); 00092 00093 public: 00094 /** Constructor 00095 * \param serialNumberUSBdevice The serial number (text) of the device to open. 00096 * The constructor will try to open the device. You can check if it failed calling "isOpen()". 00097 */ 00098 CBoardENoses( ); 00099 00100 /** Destructor 00101 */ 00102 virtual ~CBoardENoses(); 00103 00104 /** Query the firmware version on the device (can be used to test communications). 00105 * \return true on success, false on communications errors or device not found. 00106 */ 00107 bool queryFirmwareVersion( std::string &out_firmwareVersion ); 00108 00109 /** Request the master eNose the latest readings from all the eNoses. 00110 * The output observation contains a valid timestamp and 3D positions if "loadConfig" has been called previously. 00111 * \return true if OK, false if there were any error. 00112 */ 00113 bool getObservation( mrpt::slam::CObservationGasSensors &outObservation ); 00114 00115 00116 /** This method should be called periodically (at least at 1Hz to capture ALL the real-time data) 00117 * It is thread safe, i.e. you can call this from one thread, then to other methods from other threads. 00118 */ 00119 void doProcess(); 00120 00121 /** Tries to open the camera, after setting all the parameters with a call to loadConfig. 00122 * \exception This method must throw an exception with a descriptive message if some critical error is found. 00123 */ 00124 virtual void initialize(); 00125 00126 00127 00128 }; // end of class 00129 } // end of namespace 00130 } // end of namespace 00131 00132 00133 #endif 00134 00135
| Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010 |
