Main MRPT website > C++ reference for MRPT 1.5.7
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-2017, 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  /** This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scanners through an ethernet controller.
21  * This class does not need to be bind, i.e. you do not need to call C2DRangeFinderAbstract::bindIO.
22  * Connection is established when user call the turnOn() method. You can pass to the class's constructor the LMS100 's ip address and port.
23  * Device will be configured with the following parameters :
24  * - Start Angle : -45 deg (imposed by hardware)
25  * - Stop Angle : +225 deg (imposed by hardware)
26  * - Apperture : 270 deg (imposed by hardware)
27  * - Angular resolution : 0.25 deg
28  * - Scan frequency : 25 Hz
29  * - Max Range : 20m (imposed by hardware).
30  *
31  * <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
32  * <b>before using this class</b>, you must "pre-configure" your scanner with the SICK's software "SOAP" (this software ships with the device),
33  * 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.
34  *
35  * To get a laser scan you must proceed like that :
36  * \code
37  * CLMS200Eth laser(string("192.168.0.10"), 1234);
38  * laser.turnOn();
39  * bool isOutObs, hardwareError;
40  * CObservation2DRangeScan outObs;
41  * laser.doProcessSimple(isOutObs, outObs, hardwareError);
42  * \endcode
43  *
44  * The sensor pose on the vehicle could be loaded from an ini configuration file with :
45  * \code
46  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
47  * -------------------------------------------------------
48  * [supplied_section_name]
49  * ip_address = 192.168.0.50 ;a string wich is the SICK's ip adress (default is 192.168.0.1)
50  * TCP_port = 1234 ; an integer value : the tcp ip port on wich the sick is listening (default is 2111).
51  * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters)
52  * pose_y=0
53  * pose_z=0.34
54  * pose_yaw=0 ; Angles in degrees
55  * pose_pitch=0
56  * pose_roll=0
57  * \endcode
58  * This class doesn't configure the SICK LMS sensor, it is recomended to configure the sensor via the
59  * the SICK software : SOPAS.
60  * \note This class was contributed by Adrien Barral - Robopec (France)
61  * \ingroup mrpt_hwdrivers_grp
62  */
64  {
66  public:
67  /** Constructor.
68  * Note that there is default arguments, here you can customize IP Adress and TCP Port of your device.
69  */
70  CLMS100Eth(std::string _ip=std::string("192.168.0.1"), unsigned int _port=2111);
71  /** Destructor.
72  * Close communcation with the device, and free memory.
73  */
74  virtual ~CLMS100Eth();
75  /** This function acquire a laser scan from the device. If an error occured, hardwareError will be set to true.
76  * The new laser scan will be stored in the outObservation argument.
77  *
78  * \exception This method throw exception if the frame received from the LMS 100 contain the following bad parameters :
79  * * Status is not OK
80  * * Data in the scan aren't DIST1 (may be RSSIx or DIST2).
81  */
82  void doProcessSimple(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError);
83 
84  /** This method must be called before trying to get a laser scan.
85  */
86  bool turnOn();
87  /** This method could be called manually to stop communication with the device. Method is also called by destructor.
88  */
89  bool turnOff();
90 
91  /** A method to set the sensor pose on the robot.
92  * Equivalent to setting the sensor pose via loading it from a config file.
93  */
94  void setSensorPose(const mrpt::poses::CPose3D& _pose);
95 
96  /** This method should be called periodically. Period depend on the process_rate in the configuration file.
97  */
98  void doProcess();
99 
100  /** Initialize the sensor according to the parameters previously read in the configuration file.
101  */
102  void initialize();
103  private :
105  unsigned int m_port;
110  unsigned int m_scanFrequency; // hertz
111  double m_angleResolution; // degrees
112  double m_startAngle; // degrees
113  double m_stopAngle; // degrees
115  double m_maxRange;
117 
118  void generateCmd(const char *cmd);
119  bool checkIsConnected();
120  bool decodeLogIn(char *msg);
121  bool decodeScanCfg(std::istringstream& stream);
122  bool decodeScanDataCfg(std::istringstream& stream);
123  bool decodeScan(char *buf, mrpt::obs::CObservation2DRangeScan& outObservation);
124  void sendCommand(const char *cmd);
125  void roughPrint( char *msg );
126 
127 
128  protected:
129  /** Load sensor pose on the robot, or keep the default sensor pose.
130  */
131  void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource,const std::string &iniSection );
132 
133  };
134  }
135 }
136 #endif // CLMS100ETH_H
This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scan...
Definition: CLMS100eth.h:63
mrpt::utils::CClientTCPSocket m_client
Definition: CLMS100eth.h:106
This class allows loading and storing values and vectors of different types from a configuration text...
mrpt::poses::CPose3D m_sensorPose
Definition: CLMS100eth.h:114
GLsizei const GLchar ** string
Definition: glext.h:3919
#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 "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
A TCP socket that can be connected to a TCP server, implementing MRPT&#39;s CStream interface for passing...
unsigned int m_scanFrequency
Definition: CLMS100eth.h:110



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019