00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 University of Malaga | 00007 | | 00008 | This software was written by the Perception and Robotics | 00009 | research group, 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 LMS200 laser scanners through a custom USB RS-422 interface board. 00039 * 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. 00040 * 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. 00041 * 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 00042 * call "setDeviceSerialNumber". The default serial number is "LASER001" 00043 * 00044 * Warning: Avoid defining an object of this class in a global scope if you want to catch all potential 00045 * exceptions during the constructors (like USB interface DLL not found, etc...) 00046 * 00047 * 00048 * \code 00049 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00050 * ------------------------------------------------------- 00051 * [supplied_section_name] 00052 * SICKUSB_serialNumber=LASER001 00053 * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters) 00054 * pose_y=0 00055 * pose_z=0.34 00056 * pose_yaw=0 ; Angles in degrees 00057 * pose_pitch=0 00058 * pose_roll=0 00059 * \endcode 00060 * 00061 */ 00062 class HWDLLIMPEXP CSickLaserUSB : public C2DRangeFinderAbstract 00063 { 00064 DEFINE_GENERIC_SENSOR(CSickLaserUSB) 00065 00066 private: 00067 CInterfaceFTDI *m_usbConnection; 00068 std::string m_serialNumber; 00069 std::string m_sensorLabel; 00070 00071 uint32_t m_timeStartUI; //!< Time of the first data packet, for synchronization purposes. 00072 mrpt::system::TTimeStamp m_timeStartTT; 00073 00074 /** The sensor 6D pose: 00075 */ 00076 poses::CPose3D m_sensorPose; 00077 00078 static int CRC16_GEN_POL; 00079 00080 00081 bool checkControllerIsConnected(); 00082 bool waitContinuousSampleFrame( vector_float &ranges, unsigned char &LMS_status, uint32_t &out_board_timestamp, bool &is_mm_mode ); 00083 uint16_t computeCRC(unsigned char *data, unsigned long len); 00084 00085 public: 00086 /** Constructor 00087 */ 00088 CSickLaserUSB(); 00089 00090 /** Destructor 00091 */ 00092 virtual ~CSickLaserUSB(); 00093 00094 /** Changes the serial number of the device to open (call prior to 'doProcess') 00095 */ 00096 void setDeviceSerialNumber(const std::string &deviceSerialNumber) 00097 { 00098 m_serialNumber = deviceSerialNumber; 00099 } 00100 00101 /** Specific laser scanner "software drivers" must process here new data from the I/O stream, and, if a whole scan has arrived, return it. 00102 * This method will be typically called in a different thread than other methods, and will be called in a timely fashion. 00103 */ 00104 void doProcessSimple( 00105 bool &outThereIsObservation, 00106 mrpt::slam::CObservation2DRangeScan &outObservation, 00107 bool &hardwareError ); 00108 00109 /** 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) 00110 * See hwdrivers::CSickLaserUSB for the possible parameters 00111 */ 00112 void loadConfig( 00113 const mrpt::utils::CConfigFileBase &configSource, 00114 const std::string &iniSection ); 00115 00116 /** Enables the scanning mode (in this class this has no effect). 00117 * \return If everything works "true", or "false" if there is any error. 00118 */ 00119 bool turnOn(); 00120 00121 /** Disables the scanning mode (in this class this has no effect). 00122 * \return If everything works "true", or "false" if there is any error. 00123 */ 00124 bool turnOff(); 00125 00126 }; // End of class 00127 00128 } // End of namespace 00129 } // End of namespace 00130 00131 #endif
Page generated by Doxygen 1.5.9 for MRPT 0.7.1 SVN: at Mon Aug 17 22:21:34 EDT 2009 |