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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019