00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2011 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 CSickLaserUSB_H 00029 #define CSickLaserUSB_H 00030 00031 #include <mrpt/hwdrivers/C2DRangeFinderAbstract.h> 00032 #include <mrpt/hwdrivers/CInterfaceFTDI.h> 00033 00034 namespace mrpt 00035 { 00036 namespace hwdrivers 00037 { 00038 /** This "software driver" implements the communication protocol for interfacing a SICK LMS2XX laser scanners through a custom USB RS-422 interface board. 00039 * 00040 * NOTE that this class is for a custom hardware built at our lab (MAPIR, University of Malaga). 00041 * For a generic serial interface, see the class CSickLaserSerial. 00042 * 00043 * This class does not need to be bind, i.e. you do not need to call C2DRangeFinderAbstract::bindIO. However, calling it will have not effect. 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 "LASER001" 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 * 00052 * \code 00053 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00054 * ------------------------------------------------------- 00055 * [supplied_section_name] 00056 * SICKUSB_serialNumber=LASER001 00057 * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters) 00058 * pose_y=0 00059 * pose_z=0.34 00060 * pose_yaw=0 ; Angles in degrees 00061 * pose_pitch=0 00062 * pose_roll=0 00063 * \endcode 00064 * 00065 */ 00066 class HWDRIVERS_IMPEXP CSickLaserUSB : public C2DRangeFinderAbstract 00067 { 00068 DEFINE_GENERIC_SENSOR(CSickLaserUSB) 00069 00070 private: 00071 CInterfaceFTDI *m_usbConnection; 00072 std::string m_serialNumber; 00073 00074 uint32_t m_timeStartUI; //!< Time of the first data packet, for synchronization purposes. 00075 mrpt::system::TTimeStamp m_timeStartTT; 00076 00077 /** The sensor 6D pose: 00078 */ 00079 poses::CPose3D m_sensorPose; 00080 00081 bool checkControllerIsConnected(); 00082 bool waitContinuousSampleFrame( std::vector<float> &ranges, unsigned char &LMS_status, uint32_t &out_board_timestamp, bool &is_mm_mode ); 00083 00084 protected: 00085 /** 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) 00086 * See hwdrivers::CSickLaserUSB for the possible parameters 00087 */ 00088 void loadConfig_sensorSpecific( 00089 const mrpt::utils::CConfigFileBase &configSource, 00090 const std::string &iniSection ); 00091 00092 public: 00093 /** Constructor 00094 */ 00095 CSickLaserUSB(); 00096 00097 /** Destructor 00098 */ 00099 virtual ~CSickLaserUSB(); 00100 00101 /** Changes the serial number of the device to open (call prior to 'doProcess') 00102 */ 00103 void setDeviceSerialNumber(const std::string &deviceSerialNumber) 00104 { 00105 m_serialNumber = deviceSerialNumber; 00106 } 00107 00108 /** Specific laser scanner "software drivers" must process here new data from the I/O stream, and, if a whole scan has arrived, return it. 00109 * This method will be typically called in a different thread than other methods, and will be called in a timely fashion. 00110 */ 00111 void doProcessSimple( 00112 bool &outThereIsObservation, 00113 mrpt::slam::CObservation2DRangeScan &outObservation, 00114 bool &hardwareError ); 00115 00116 00117 /** Enables the scanning mode (in this class this has no effect). 00118 * \return If everything works "true", or "false" if there is any error. 00119 */ 00120 bool turnOn(); 00121 00122 /** Disables the scanning mode (in this class this has no effect). 00123 * \return If everything works "true", or "false" if there is any error. 00124 */ 00125 bool turnOff(); 00126 00127 }; // End of class 00128 00129 } // End of namespace 00130 } // End of namespace 00131 00132 #endif
Page generated by Doxygen 1.7.1 for MRPT 0.9.4 SVN: at Mon Jan 10 23:33:19 UTC 2011 |