MRPT  1.9.9
CLMS100eth.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
14 
15 namespace mrpt::hwdrivers
16 {
17 /** This "software driver" implements the communication protocol for interfacing
18  *a SICK LMS100 laser scanners through an ethernet controller.
19  * This class does not need to be bind, i.e. you do not need to call
20  *C2DRangeFinderAbstract::bindIO.
21  * Connection is established when user call the turnOn() method. You can
22  *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
32  *configuration. In its present implementation, this class only handles one of
33  *them, so
34  * <b>before using this class</b>, you must "pre-configure" your scanner
35  *with the SICK's software "SOAP" (this software ships with the device),
36  * and set the framerate with this software. Of course, you have to
37  *pre-configure the device just once, then save that configuration in its flash
38  *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
50  *file with :
51  * \code
52  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
53  * -------------------------------------------------------
54  * [supplied_section_name]
55  * ip_address = 192.168.0.50 ;a string wich is the SICK's ip adress
56  *(default is 192.168.0.1)
57  * TCP_port = 1234 ; an integer value : the tcp ip port on wich the
58  *sick is listening (default is 2111).
59  * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters)
60  * pose_y=0
61  * pose_z=0.34
62  * pose_yaw=0 ; Angles in degrees
63  * pose_pitch=0
64  * pose_roll=0
65  * \endcode
66  * This class doesn't configure the SICK LMS sensor, it is recomended to
67  *configure the sensor via the
68  * the SICK software : SOPAS.
69  * \note This class was contributed by Adrien Barral - Robopec (France)
70  * \ingroup mrpt_hwdrivers_grp
71  */
73 {
75  public:
76  /** Constructor.
77  * Note that there is default arguments, here you can customize IP Adress
78  * and TCP Port of your device.
79  */
80  CLMS100Eth(
81  std::string _ip = std::string("192.168.0.1"),
82  unsigned int _port = 2111);
83  /** Destructor.
84  * Close communcation with the device, and free memory.
85  */
86  ~CLMS100Eth() override;
87  /** This function acquire a laser scan from the device. If an error occured,
88  * hardwareError will be set to true.
89  * The new laser scan will be stored in the outObservation argument.
90  *
91  * \exception This method throw exception if the frame received from the
92  * LMS 100 contain the following bad parameters :
93  * * Status is not OK
94  * * Data in the scan aren't DIST1 (may be RSSIx or DIST2).
95  */
96  void doProcessSimple(
97  bool& outThereIsObservation,
98  mrpt::obs::CObservation2DRangeScan& outObservation,
99  bool& hardwareError) override;
100 
101  /** This method must be called before trying to get a laser scan.
102  */
103  bool turnOn() override;
104  /** This method could be called manually to stop communication with the
105  * device. Method is also called by destructor.
106  */
107  bool turnOff() override;
108 
109  /** A method to set the sensor pose on the robot.
110  * Equivalent to setting the sensor pose via loading it from a config
111  * file.
112  */
113  void setSensorPose(const mrpt::poses::CPose3D& _pose);
114 
115  /** This method should be called periodically. Period depend on the
116  * process_rate in the configuration file.
117  */
118  void doProcess() override;
119 
120  /** Initialize the sensor according to the parameters previously read in the
121  * configuration file.
122  */
123  void initialize() override;
124 
125  private:
126  std::string m_ip;
127  unsigned int m_port = 0;
129  bool m_turnedOn{false};
130  std::string m_cmd;
131  bool m_connected{false};
132  unsigned int m_scanFrequency = 0; // hertz
133  double m_angleResolution = 0; // degrees
134  double m_startAngle = 0; // degrees
135  double m_stopAngle = 0; // degrees
137  double m_maxRange{20.0};
138  double m_beamApperture = 0;
139 
140  void generateCmd(const char* cmd);
141  bool checkIsConnected();
142  bool decodeLogIn(char* msg);
143  bool decodeScanCfg(std::istringstream& stream);
144  bool decodeScanDataCfg(std::istringstream& stream);
145  bool decodeScan(
146  char* buf, mrpt::obs::CObservation2DRangeScan& outObservation);
147  void sendCommand(const char* cmd);
148  void roughPrint(char* msg);
149 
150  protected:
151  /** Load sensor pose on the robot, or keep the default sensor pose.
152  */
154  const mrpt::config::CConfigFileBase& configSource,
155  const std::string& iniSection) override;
156 };
157 } // namespace mrpt::hwdrivers
This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scan...
Definition: CLMS100eth.h:72
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection) override
Load sensor pose on the robot, or keep the default sensor pose.
Definition: CLMS100eth.cpp:57
bool decodeScanDataCfg(std::istringstream &stream)
Contains classes for various device interfaces.
void roughPrint(char *msg)
bool decodeScan(char *buf, mrpt::obs::CObservation2DRangeScan &outObservation)
Definition: CLMS100eth.cpp:227
This class allows loading and storing values and vectors of different types from a configuration text...
mrpt::poses::CPose3D m_sensorPose
Definition: CLMS100eth.h:136
bool decodeScanCfg(std::istringstream &stream)
void doProcessSimple(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError) override
This function acquire a laser scan from the device.
Definition: CLMS100eth.cpp:308
bool turnOn() override
This method must be called before trying to get a laser scan.
Definition: CLMS100eth.cpp:112
#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...
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:85
mrpt::comms::CClientTCPSocket m_client
Definition: CLMS100eth.h:128
A TCP socket that can be connected to a TCP server, implementing MRPT&#39;s CStream interface for passing...
void initialize() override
Initialize the sensor according to the parameters previously read in the configuration file...
Definition: CLMS100eth.cpp:46
void doProcess() override
This method should be called periodically.
Definition: CLMS100eth.cpp:350
void sendCommand(const char *cmd)
Definition: CLMS100eth.cpp:208
unsigned int m_scanFrequency
Definition: CLMS100eth.h:132
CLMS100Eth(std::string _ip=std::string("192.168.0.1"), unsigned int _port=2111)
Constructor.
Definition: CLMS100eth.cpp:30
bool turnOff() override
This method could be called manually to stop communication with the device.
Definition: CLMS100eth.cpp:104
void setSensorPose(const mrpt::poses::CPose3D &_pose)
A method to set the sensor pose on the robot.
Definition: CLMS100eth.cpp:377
~CLMS100Eth() override
Destructor.
Definition: CLMS100eth.cpp:41
void generateCmd(const char *cmd)
Add the start and end character.
Definition: CLMS100eth.cpp:217



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020