Main MRPT website > C++ reference
MRPT logo
CLMS100eth.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef CLMS100ETH_H
11 #define CLMS100ETH_H
12 
15 
16 namespace mrpt
17 {
18  namespace hwdrivers
19  {
20  using namespace std;
21  using namespace mrpt::hwdrivers;
22  using namespace mrpt::utils;
23  using namespace mrpt::slam;
24 
25  /** This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scanners through an ethernet controller.
26  * This class does not need to be bind, i.e. you do not need to call C2DRangeFinderAbstract::bindIO.
27  * Connection is established when user call the turnOn() method. You can pass to the class's constructor the LMS100 's ip address and port.
28  * Device will be configured with the following parameters :
29  * - Start Angle : -45 deg (imposed by hardware)
30  * - Stop Angle : +225 deg (imposed by hardware)
31  * - Apperture : 270 deg (imposed by hardware)
32  * - Angular resolution : 0.25 deg
33  * - Scan frequency : 25 Hz
34  * - Max Range : 20m (imposed by hardware).
35  *
36  * <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
37  * <b>before using this class</b>, you must "pre-configure" your scanner with the SICK's software "SOAP" (this software ships with the device),
38  * 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.
39  *
40  * To get a laser scan you must proceed like that :
41  * \code
42  * CLMS200Eth laser(string("192.168.0.10"), 1234);
43  * laser.turnOn();
44  * bool isOutObs, hardwareError;
45  * CObservation2DRangeScan outObs;
46  * laser.doProcessSimple(isOutObs, outObs, hardwareError);
47  * \endcode
48  *
49  * The sensor pose on the vehicle could be loaded from an ini configuration file with :
50  * \code
51  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
52  * -------------------------------------------------------
53  * [supplied_section_name]
54  * ip_address = 192.168.0.50 ;a string wich is the SICK's ip adress (default is 192.168.0.1)
55  * TCP_port = 1234 ; an integer value : the tcp ip port on wich the sick is listening (default is 2111).
56  * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters)
57  * pose_y=0
58  * pose_z=0.34
59  * pose_yaw=0 ; Angles in degrees
60  * pose_pitch=0
61  * pose_roll=0
62  * \endcode
63  * This class doesn't configure the SICK LMS sensor, it is recomended to configure the sensor via the
64  * the SICK software : SOPAS.
65  * \note This class was contributed by Adrien Barral - Robopec (France)
66  * \ingroup mrpt_hwdrivers_grp
67  */
69  {
71  public:
72  /** Constructor.
73  * Note that there is default arguments, here you can customize IP Adress and TCP Port of your device.
74  */
75  CLMS100Eth(string _ip=string("192.168.0.1"), unsigned int _port=2111);
76  /** Destructor.
77  * Close communcation with the device, and free memory.
78  */
79  virtual ~CLMS100Eth();
80  /** This function acquire a laser scan from the device. If an error occured, hardwareError will be set to true.
81  * The new laser scan will be stored in the outObservation argument.
82  *
83  * \exception This method throw exception if the frame received from the LMS 100 contain the following bad parameters :
84  * * Status is not OK
85  * * Data in the scan aren't DIST1 (may be RSSIx or DIST2).
86  */
87  void doProcessSimple(bool &outThereIsObservation, CObservation2DRangeScan &outObservation, bool &hardwareError);
88 
89  /** This method must be called before trying to get a laser scan.
90  */
91  bool turnOn();
92  /** This method could be called manually to stop communication with the device. Method is also called by destructor.
93  */
94  bool turnOff();
95 
96  /** A method to set the sensor pose on the robot.
97  * Equivalent to setting the sensor pose via loading it from a config file.
98  */
99  void setSensorPose(const CPose3D& _pose);
100 
101  /** This method should be called periodically. Period depend on the process_rate in the configuration file.
102  */
103  void doProcess();
104 
105  /** Initialize the sensor according to the parameters previously read in the configuration file.
106  */
107  void initialize();
108  private :
109  string m_ip;
110  unsigned int m_port;
113  string m_cmd;
115  unsigned int m_scanFrequency; // en hertz
116  double m_angleResolution; // en degrés
117  double m_startAngle; // degrés
118  double m_stopAngle; // degrés
120  double m_maxRange;
122 
123  void generateCmd(const char *cmd);
124  bool checkIsConnected();
125  bool decodeLogIn(char *msg);
126  bool decodeScanCfg(istringstream& stream);
127  bool decodeScanDataCfg(istringstream& stream);
128  bool decodeScan(char *buf, CObservation2DRangeScan& outObservation);
129  void sendCommand(const char *cmd);
130  void roughPrint( char *msg );
131 
132 
133  protected:
134  /** Load sensor pose on the robot, or keep the default sensor pose.
135  */
136  void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource,
137  const std::string &iniSection );
138 
139  };
140  }
141 }
142 #endif // CLMS100ETH_H
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scan...
Definition: CLMS100eth.h:68
CClientTCPSocket m_client
Definition: CLMS100eth.h:111
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
Contains classes for various device interfaces.
STL namespace.
This namespace contains algorithms for SLAM, localization, map building, representation of robot's ac...
This class allows loading and storing values and vectors of different types from a configuration text...
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
This is the base, abstract class for "software drivers" interfaces to 2D scanners (laser range finder...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:69
#define HWDRIVERS_IMPEXP
A TCP socket that can be connected to a TCP server, implementing MRPT's CStream interface for passing...
unsigned int m_scanFrequency
Definition: CLMS100eth.h:115



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014