Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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
16namespace 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 */
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 */
103 private :
104 std::string m_ip;
105 unsigned int m_port;
108 std::string m_cmd;
110 unsigned int m_scanFrequency; // hertz
111 double m_angleResolution; // degrees
112 double m_startAngle; // degrees
113 double m_stopAngle; // degrees
117
118 void generateCmd(const char *cmd);
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
#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 "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scan...
Definition: CLMS100eth.h:64
void doProcessSimple(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError)
This function acquire a laser scan from the device.
bool turnOff()
This method could be called manually to stop communication with the device.
void generateCmd(const char *cmd)
mrpt::utils::CClientTCPSocket m_client
Definition: CLMS100eth.h:106
void sendCommand(const char *cmd)
void roughPrint(char *msg)
void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection)
Load sensor pose on the robot, or keep the default sensor pose.
CLMS100Eth(std::string _ip=std::string("192.168.0.1"), unsigned int _port=2111)
Constructor.
bool decodeScan(char *buf, mrpt::obs::CObservation2DRangeScan &outObservation)
bool decodeLogIn(char *msg)
mrpt::poses::CPose3D m_sensorPose
Definition: CLMS100eth.h:114
void doProcess()
This method should be called periodically.
bool decodeScanDataCfg(std::istringstream &stream)
bool decodeScanCfg(std::istringstream &stream)
virtual ~CLMS100Eth()
Destructor.
void initialize()
Initialize the sensor according to the parameters previously read in the configuration file.
void setSensorPose(const mrpt::poses::CPose3D &_pose)
A method to set the sensor pose on the robot.
bool turnOn()
This method must be called before trying to get a laser scan.
unsigned int m_scanFrequency
Definition: CLMS100eth.h:110
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:73
A TCP socket that can be connected to a TCP server, implementing MRPT's CStream interface for passing...
This class allows loading and storing values and vectors of different types from a configuration text...
#define HWDRIVERS_IMPEXP
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Sun Nov 27 02:56:26 UTC 2022