Main MRPT website > C++ reference
MRPT logo
CSickLaserUSB.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CSickLaserUSB_H
29 #define CSickLaserUSB_H
30 
33 
34 namespace mrpt
35 {
36  namespace hwdrivers
37  {
38  /** This "software driver" implements the communication protocol for interfacing a SICK LMS2XX laser scanners through a custom USB RS-422 interface board.
39  *
40  * NOTE that this class is for a custom hardware built at our lab (MAPIR, University of Malaga).
41  * For a generic serial interface, see the class CSickLaserSerial.
42  *
43  * 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.
44  * 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.
45  * 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
46  * call "setDeviceSerialNumber". The default serial number is "LASER001"
47  *
48  * Warning: Avoid defining an object of this class in a global scope if you want to catch all potential
49  * exceptions during the constructors (like USB interface DLL not found, etc...)
50  *
51  *
52  * \code
53  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
54  * -------------------------------------------------------
55  * [supplied_section_name]
56  * SICKUSB_serialNumber=LASER001
57  * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters)
58  * pose_y=0
59  * pose_z=0.34
60  * pose_yaw=0 ; Angles in degrees
61  * pose_pitch=0
62  * pose_roll=0
63  * \endcode
64  * \ingroup mrpt_hwdrivers_grp
65  *
66  */
68  {
70 
71  private:
73  std::string m_serialNumber;
74 
75  uint32_t m_timeStartUI; //!< Time of the first data packet, for synchronization purposes.
77 
78  /** The sensor 6D pose:
79  */
81 
82  bool checkControllerIsConnected();
83  bool waitContinuousSampleFrame( std::vector<float> &ranges, unsigned char &LMS_status, uint32_t &out_board_timestamp, bool &is_mm_mode );
84 
85  protected:
86  /** 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)
87  * See hwdrivers::CSickLaserUSB for the possible parameters
88  */
89  void loadConfig_sensorSpecific(
90  const mrpt::utils::CConfigFileBase &configSource,
91  const std::string &iniSection );
92 
93  public:
94  /** Constructor
95  */
96  CSickLaserUSB();
97 
98  /** Destructor
99  */
100  virtual ~CSickLaserUSB();
101 
102  /** Changes the serial number of the device to open (call prior to 'doProcess')
103  */
104  void setDeviceSerialNumber(const std::string &deviceSerialNumber)
105  {
106  m_serialNumber = deviceSerialNumber;
107  }
108 
109  /** Specific laser scanner "software drivers" must process here new data from the I/O stream, and, if a whole scan has arrived, return it.
110  * This method will be typically called in a different thread than other methods, and will be called in a timely fashion.
111  */
112  void doProcessSimple(
113  bool &outThereIsObservation,
114  mrpt::slam::CObservation2DRangeScan &outObservation,
115  bool &hardwareError );
116 
117 
118  /** Enables the scanning mode (in this class this has no effect).
119  * \return If everything works "true", or "false" if there is any error.
120  */
121  bool turnOn();
122 
123  /** Disables the scanning mode (in this class this has no effect).
124  * \return If everything works "true", or "false" if there is any error.
125  */
126  bool turnOff();
127 
128  }; // End of class
129 
130  } // End of namespace
131 } // End of namespace
132 
133 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013