Main MRPT website > C++ reference
MRPT logo
CLMS100eth.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 
29 #ifndef CLMS100ETH_H
30 #define CLMS100ETH_H
31 
32 #include <mrpt/utils.h>
34 
35 namespace mrpt
36 {
37  namespace hwdrivers
38  {
39  using namespace std;
40  using namespace mrpt::hwdrivers;
41  using namespace mrpt::utils;
42  using namespace mrpt::slam;
43 
44  /** This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scanners through an ethernet controller.
45  * This class does not need to be bind, i.e. you do not need to call C2DRangeFinderAbstract::bindIO.
46  * Connection is established when user call the turnOn() method. You can pass to the class's constructor the LMS100 's ip address and port.
47  * Device will be configured with the following parameters :
48  * - Start Angle : -45 deg (imposed by hardware)
49  * - Stop Angle : +225 deg (imposed by hardware)
50  * - Apperture : 270 deg (imposed by hardware)
51  * - Angular resolution : 0.25 deg
52  * - Scan frequency : 25 Hz
53  * - Max Range : 20m (imposed by hardware).
54  *
55  * <b>Important note:</b> SICK LMS 1xx devices have two levels of configuration. In its present implementation, this class only handles one of them, so
56  * <b>before using this class</b>, you must "pre-configure" your scanner with the SICK's software "SOAP" (this software ships with the device),
57  * and set the framerate with this software. Of course, you have to pre-configure the device just once, then save that configuration in its flash memory.
58  *
59  * To get a laser scan you must proceed like that :
60  * \code
61  * CLMS200Eth laser(string("192.168.0.10"), 1234);
62  * laser.turnOn();
63  * bool isOutObs, hardwareError;
64  * CObservation2DRangeScan outObs;
65  * laser.doProcessSimple(isOutObs, outObs, hardwareError);
66  * \endcode
67  *
68  * The sensor pose on the vehicle could be loaded from an ini configuration file with :
69  * \code
70  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
71  * -------------------------------------------------------
72  * [supplied_section_name]
73  * ip_address = 192.168.0.50 ;a string wich is the SICK's ip adress (default is 192.168.0.1)
74  * TCP_port = 1234 ; an integer value : the tcp ip port on wich the sick is listening (default is 2111).
75  * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters)
76  * pose_y=0
77  * pose_z=0.34
78  * pose_yaw=0 ; Angles in degrees
79  * pose_pitch=0
80  * pose_roll=0
81  * \endcode
82  * This class doesn't configure the SICK LMS sensor, it is recomended to configure the sensor via the
83  * the SICK software : SOPAS.
84  * \note This class was contributed by Adrien Barral - Robopec (France)
85  * \ingroup mrpt_hwdrivers_grp
86  */
88  {
90  public:
91  /** Constructor.
92  * Note that there is default arguments, here you can customize IP Adress and TCP Port of your device.
93  */
94  CLMS100Eth(string _ip=string("192.168.0.1"), unsigned int _port=2111);
95  /** Destructor.
96  * Close communcation with the device, and free memory.
97  */
98  virtual ~CLMS100Eth();
99  /** This function acquire a laser scan from the device. If an error occured, hardwareError will be set to true.
100  * The new laser scan will be stored in the outObservation argument.
101  *
102  * \exception This method throw exception if the frame received from the LMS 100 contain the following bad parameters :
103  * * Status is not OK
104  * * Data in the scan aren't DIST1 (may be RSSIx or DIST2).
105  */
106  void doProcessSimple(bool &outThereIsObservation, CObservation2DRangeScan &outObservation, bool &hardwareError);
107 
108  /** This method must be called before trying to get a laser scan.
109  */
110  bool turnOn();
111  /** This method could be called manually to stop communication with the device. Method is also called by destructor.
112  */
113  bool turnOff();
114 
115  /** A method to set the sensor pose on the robot.
116  * Equivalent to setting the sensor pose via loading it from a config file.
117  */
118  void setSensorPose(const CPose3D& _pose);
119 
120  /** This method should be called periodically. Period depend on the process_rate in the configuration file.
121  */
122  void doProcess();
123 
124  /** Initialize the sensor according to the parameters previously read in the configuration file.
125  */
126  void initialize();
127  private :
128  string m_ip;
129  unsigned int m_port;
132  string m_cmd;
134  unsigned int m_scanFrequency; // en hertz
135  double m_angleResolution; // en degrés
136  double m_startAngle; // degrés
137  double m_stopAngle; // degrés
139  double m_maxRange;
141 
142  void generateCmd(const char *cmd);
143  bool checkIsConnected();
144  bool decodeLogIn(char *msg);
145  bool decodeScanCfg(istringstream& stream);
146  bool decodeScanDataCfg(istringstream& stream);
147  bool decodeScan(char *buf, CObservation2DRangeScan& outObservation);
148  void sendCommand(const char *cmd);
149  void roughPrint( char *msg );
150 
151 
152  protected:
153  /** Load sensor pose on the robot, or keep the default sensor pose.
154  */
155  void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource,
156  const std::string &iniSection );
157 
158  };
159  }
160 }
161 #endif // CLMS100ETH_H



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