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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020