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 #ifndef CBoardSonars_H 00029 #define CBoardSonars_H 00030 00031 #include <mrpt/hwdrivers/CInterfaceFTDIMessages.h> 00032 #include <mrpt/hwdrivers/CGenericSensor.h> 00033 #include <mrpt/synch.h> 00034 #include <mrpt/utils/CDebugOutputCapable.h> 00035 #include <mrpt/utils/CConfigFileBase.h> 00036 #include <mrpt/slam/CObservationRange.h> 00037 00038 namespace mrpt 00039 { 00040 namespace hwdrivers 00041 { 00042 /** This "software driver" implements the communication protocol for interfacing a Ultrasonic range finder SRF10 through a custom USB board. 00043 * 00044 * In this class the "bind" is ignored since it is designed for USB connections only, thus it internally generate the required object for simplicity of use. 00045 * The serial number of the USB device is used to open it on the first call to "doProcess", thus you must call "loadConfig" before this, or manually 00046 * call "setDeviceSerialNumber". The default serial number is "SONAR001" 00047 * 00048 * Warning: Avoid defining an object of this class in a global scope if you want to catch all potential 00049 * exceptions during the constructors (like USB interface DLL not found, etc...) 00050 * 00051 * \code 00052 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00053 * ------------------------------------------------------- 00054 * [supplied_section_name] 00055 * USB_serialNumber=SONAR001 00056 * gain=6 ; Value between 0 and 16, for analog gains between 40 and 700. 00057 * maxRange=4.0 ; In meters, used for device internal timer. 00058 * minTimeBetweenPings=0.3 ; In seconds 00059 * 00060 * ; The order in which sonars will be fired, indexed by their I2C addresses [0,15] 00061 * ; Up to 16 devices, but you can put any number of devices (from 1 to 16). 00062 * firingOrder=0 1 2 3 00063 * 00064 * 00065 * ¡¡¡FALTA PONER UNA ESTRUCTURILLA PARA ALMACENAR LA POSE3D DE LOS 16 SONARES SOBRE EL ROBOT!!! 00066 * 00067 * \endcode 00068 * 00069 */ 00070 class HWDLLIMPEXP CBoardSonars : public hwdrivers::CInterfaceFTDIMessages, public CGenericSensor 00071 { 00072 DEFINE_GENERIC_SENSOR(CBoardSonars) 00073 00074 public: 00075 /** Constructor 00076 */ 00077 CBoardSonars(); 00078 00079 /** Destructor 00080 */ 00081 ~CBoardSonars(){} 00082 00083 /** Query the firmware version on the device (can be used to test communications). 00084 * \return true on success, false on communications errors or device not found. 00085 */ 00086 bool queryFirmwareVersion( std::string &out_firmwareVersion ); 00087 00088 /** Request the latest range measurements. 00089 * \return true on success, false on communications errors or device not found. 00090 */ 00091 bool getObservation( mrpt::slam::CObservationRange &obs ); 00092 00093 /** Requests a command of "change address" for a given SRF10 device. 00094 * currentAddress and newAddress are the I2C addresses in the range 0 to 15 (mapped to 0xE0 to 0xFE internally). 00095 * \return true on success, false on communications errors or device not found. 00096 */ 00097 bool programI2CAddress( uint8_t currentAddress, uint8_t newAddress ); 00098 00099 /** This method should be called periodically (at least at 1Hz to capture ALL the real-time data) 00100 * It is thread safe, i.e. you can call this from one thread, then to other methods from other threads.rip 00101 */ 00102 void doProcess(); 00103 00104 protected: 00105 /** A copy of the device serial number (to open the USB FTDI chip) 00106 */ 00107 std::string m_usbSerialNumber; 00108 00109 /** A value between 0 and 16, for gains between 40 and 700 (not linear). 00110 */ 00111 uint8_t m_gain; 00112 00113 /** The maximum range in meters, used for the internal device timer (value between 4cm and 11m). 00114 */ 00115 float m_maxRange; 00116 00117 /** The order in which sonars will be fired, indexed by their I2C addresses [0,15]. 00118 * Up to 16 devices, but you can put any number of devices (from 1 to 16). 00119 */ 00120 std::vector<int32_t> m_firingOrder; 00121 00122 /** The individual gains of the sonars, indexed by their I2C addresses [0,15]. 00123 * Up to 16 devices, but you can put any number of devices (from 1 to 16). 00124 */ 00125 std::map<uint16_t,int32_t> m_sonarGains; 00126 //std::vector<int32_t> m_sonarGains; 00127 00128 /** The poses of the sonars: x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg] 00129 * Up to 16 devices, but you can put any number of devices (from 1 to 16). 00130 */ 00131 //std::vector<mrpt::math::TPose3D> m_sonarPoses; 00132 std::map<uint16_t,mrpt::math::TPose3D> m_sonarPoses; 00133 00134 /** The minimum time between sonar pings (in seconds). 00135 */ 00136 float m_minTimeBetweenPings; 00137 00138 /** Tries to connect to the USB device (if disconnected). 00139 * \return True on connection OK, false on error. 00140 */ 00141 bool checkConnectionAndConnect(); 00142 00143 /** Sends the configuration (max range, gain,...) to the USB board. Used internally after a successfull connection. 00144 * \return true on success, false on communications errors or device not found. 00145 */ 00146 bool sendConfigCommands(); 00147 00148 /** Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, 00149 * loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) 00150 * See hwdrivers::CBoardSonars for the possible parameters 00151 */ 00152 void loadConfig_sensorSpecific( const mrpt::utils::CConfigFileBase &configSource, 00153 const std::string &iniSection ); 00154 00155 00156 00157 }; // End of class 00158 } // End of namespace 00159 } // End of namespace 00160 00161 00162 #endif
| Page generated by Doxygen 1.6.2 for MRPT 0.8.1 SVN:exported at Mon Feb 15 22:01:07 UTC 2010 |
