Main MRPT website > C++ reference
MRPT logo
CSickLaserUSB.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
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                   * \ingroup mrpt_hwdrivers_grp
00065                   *
00066                   */
00067                 class HWDRIVERS_IMPEXP CSickLaserUSB : public C2DRangeFinderAbstract
00068                 {
00069                         DEFINE_GENERIC_SENSOR(CSickLaserUSB)
00070 
00071                 private:
00072                         CInterfaceFTDI          *m_usbConnection;
00073                         std::string                     m_serialNumber;
00074 
00075                         uint32_t                m_timeStartUI;  //!< Time of the first data packet, for synchronization purposes.
00076                         mrpt::system::TTimeStamp        m_timeStartTT;
00077 
00078                         /** The sensor 6D pose:
00079                           */
00080                         poses::CPose3D          m_sensorPose;
00081 
00082                         bool    checkControllerIsConnected();
00083                         bool    waitContinuousSampleFrame( std::vector<float> &ranges, unsigned char &LMS_status, uint32_t &out_board_timestamp, bool &is_mm_mode );
00084 
00085                 protected:
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::CSickLaserUSB for the possible parameters
00088                           */
00089                         void  loadConfig_sensorSpecific(
00090                                 const mrpt::utils::CConfigFileBase &configSource,
00091                                 const std::string         &iniSection );
00092 
00093                 public:
00094                         /** Constructor
00095                           */
00096                         CSickLaserUSB();
00097 
00098                         /** Destructor
00099                           */
00100                         virtual ~CSickLaserUSB();
00101 
00102                         /** Changes the serial number of the device to open (call prior to 'doProcess')
00103                           */
00104                         void  setDeviceSerialNumber(const std::string &deviceSerialNumber)
00105                         {
00106                                 m_serialNumber = deviceSerialNumber;
00107                         }
00108 
00109                         /** Specific laser scanner "software drivers" must process here new data from the I/O stream, and, if a whole scan has arrived, return it.
00110                           *  This method will be typically called in a different thread than other methods, and will be called in a timely fashion.
00111                           */
00112                         void  doProcessSimple(
00113                                 bool                                                    &outThereIsObservation,
00114                                 mrpt::slam::CObservation2DRangeScan     &outObservation,
00115                                 bool                                                    &hardwareError );
00116 
00117 
00118                         /** Enables the scanning mode (in this class this has no effect).
00119                           * \return If everything works "true", or "false" if there is any error.
00120                           */
00121                         bool  turnOn();
00122 
00123                         /** Disables the scanning mode (in this class this has no effect).
00124                           * \return If everything works "true", or "false" if there is any error.
00125                           */
00126                         bool  turnOff();
00127 
00128                 };      // End of class
00129 
00130         } // End of namespace
00131 } // End of namespace
00132 
00133 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011