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-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
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::config::CConfigFileBase& configSource,
158  const std::string& iniSection);
159 };
160 }
161 }
162 #endif // CLMS100ETH_H
mrpt::hwdrivers::CLMS100Eth::m_scanFrequency
unsigned int m_scanFrequency
Definition: CLMS100eth.h:135
CClientTCPSocket.h
mrpt::hwdrivers::CLMS100Eth::doProcess
void doProcess()
This method should be called periodically.
Definition: CLMS100eth.cpp:354
mrpt::comms::CClientTCPSocket
A TCP socket that can be connected to a TCP server, implementing MRPT's CStream interface for passing...
Definition: CClientTCPSocket.h:34
mrpt::hwdrivers::CLMS100Eth::sendCommand
void sendCommand(const char *cmd)
Definition: CLMS100eth.cpp:213
mrpt::hwdrivers::CLMS100Eth::m_startAngle
double m_startAngle
Definition: CLMS100eth.h:137
mrpt::obs::CObservation2DRangeScan
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Definition: CObservation2DRangeScan.h:56
mrpt::hwdrivers::CLMS100Eth::decodeLogIn
bool decodeLogIn(char *msg)
mrpt::hwdrivers::CLMS100Eth::~CLMS100Eth
virtual ~CLMS100Eth()
Destructor.
Definition: CLMS100eth.cpp:44
mrpt::hwdrivers::CLMS100Eth::decodeScan
bool decodeScan(char *buf, mrpt::obs::CObservation2DRangeScan &outObservation)
Definition: CLMS100eth.cpp:232
mrpt::hwdrivers::CLMS100Eth::m_stopAngle
double m_stopAngle
Definition: CLMS100eth.h:138
mrpt::hwdrivers::CLMS100Eth::checkIsConnected
bool checkIsConnected()
Definition: CLMS100eth.cpp:87
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
DEFINE_GENERIC_SENSOR
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
Definition: CGenericSensor.h:314
mrpt::hwdrivers::CLMS100Eth::m_ip
std::string m_ip
Definition: CLMS100eth.h:129
mrpt::hwdrivers::CLMS100Eth::m_beamApperture
double m_beamApperture
Definition: CLMS100eth.h:141
mrpt::hwdrivers::CLMS100Eth::decodeScanCfg
bool decodeScanCfg(std::istringstream &stream)
mrpt::hwdrivers::C2DRangeFinderAbstract
This is the base, abstract class for "software drivers" interfaces to 2D scanners (laser range finder...
Definition: C2DRangeFinderAbstract.h:43
mrpt::hwdrivers::CLMS100Eth::m_maxRange
double m_maxRange
Definition: CLMS100eth.h:140
mrpt::hwdrivers::CLMS100Eth::loadConfig_sensorSpecific
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
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::hwdrivers::CLMS100Eth::m_client
mrpt::comms::CClientTCPSocket m_client
Definition: CLMS100eth.h:131
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::hwdrivers::CLMS100Eth::turnOn
bool turnOn()
This method must be called before trying to get a laser scan.
Definition: CLMS100eth.cpp:117
mrpt::hwdrivers::CLMS100Eth::decodeScanDataCfg
bool decodeScanDataCfg(std::istringstream &stream)
mrpt::hwdrivers::CLMS100Eth::initialize
void initialize()
Initialize the sensor according to the parameters previously read in the configuration file.
Definition: CLMS100eth.cpp:51
mrpt::hwdrivers::CLMS100Eth::doProcessSimple
void doProcessSimple(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError)
This function acquire a laser scan from the device.
Definition: CLMS100eth.cpp:312
mrpt::hwdrivers::CLMS100Eth
This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scan...
Definition: CLMS100eth.h:75
mrpt::hwdrivers::CLMS100Eth::m_angleResolution
double m_angleResolution
Definition: CLMS100eth.h:136
mrpt::hwdrivers::CLMS100Eth::m_turnedOn
bool m_turnedOn
Definition: CLMS100eth.h:132
mrpt::hwdrivers::CLMS100Eth::CLMS100Eth
CLMS100Eth(std::string _ip=std::string("192.168.0.1"), unsigned int _port=2111)
Constructor.
Definition: CLMS100eth.cpp:30
mrpt::hwdrivers::CLMS100Eth::m_sensorPose
mrpt::poses::CPose3D m_sensorPose
Definition: CLMS100eth.h:139
mrpt::hwdrivers::CLMS100Eth::m_connected
bool m_connected
Definition: CLMS100eth.h:134
mrpt::hwdrivers::CLMS100Eth::generateCmd
void generateCmd(const char *cmd)
Add the start and end character.
Definition: CLMS100eth.cpp:222
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::hwdrivers::CLMS100Eth::setSensorPose
void setSensorPose(const mrpt::poses::CPose3D &_pose)
A method to set the sensor pose on the robot.
Definition: CLMS100eth.cpp:381
mrpt::hwdrivers::CLMS100Eth::roughPrint
void roughPrint(char *msg)
mrpt::hwdrivers::CLMS100Eth::turnOff
bool turnOff()
This method could be called manually to stop communication with the device.
Definition: CLMS100eth.cpp:109
mrpt::hwdrivers::CLMS100Eth::m_cmd
std::string m_cmd
Definition: CLMS100eth.h:133
mrpt::hwdrivers::CLMS100Eth::m_port
unsigned int m_port
Definition: CLMS100eth.h:130
C2DRangeFinderAbstract.h



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST