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 
16 namespace 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  */
94  void setSensorPose(const mrpt::poses::CPose3D& _pose);
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  */
102  void initialize();
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
115  double m_maxRange;
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
mrpt::hwdrivers::CLMS100Eth::m_scanFrequency
unsigned int m_scanFrequency
Definition: CLMS100eth.h:110
CClientTCPSocket.h
mrpt::hwdrivers::CLMS100Eth::CLMS100Eth
CLMS100Eth(std::string _ip=std::string("192.168.0.1"), unsigned int _port=2111)
Constructor.
mrpt::hwdrivers::CLMS100Eth::generateCmd
void generateCmd(const char *cmd)
mrpt::hwdrivers::CLMS100Eth::m_startAngle
double m_startAngle
Definition: CLMS100eth.h:112
mrpt::obs::CObservation2DRangeScan
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Definition: obs/CObservation2DRangeScan.h:41
mrpt::hwdrivers::CLMS100Eth::decodeLogIn
bool decodeLogIn(char *msg)
mrpt::hwdrivers::CLMS100Eth::m_stopAngle
double m_stopAngle
Definition: CLMS100eth.h:113
mrpt::utils::CClientTCPSocket
A TCP socket that can be connected to a TCP server, implementing MRPT's CStream interface for passing...
Definition: CClientTCPSocket.h:35
mrpt::hwdrivers::CLMS100Eth::checkIsConnected
bool checkIsConnected()
mrpt::hwdrivers::CLMS100Eth::initialize
void initialize()
Initialize the sensor according to the parameters previously read in the configuration file.
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:17
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:251
mrpt::hwdrivers::CLMS100Eth::m_ip
std::string m_ip
Definition: CLMS100eth.h:104
mrpt::hwdrivers::CLMS100Eth::m_client
mrpt::utils::CClientTCPSocket m_client
Definition: CLMS100eth.h:106
mrpt::hwdrivers::CLMS100Eth::m_beamApperture
double m_beamApperture
Definition: CLMS100eth.h:116
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:39
mrpt::hwdrivers::CLMS100Eth::m_maxRange
double m_maxRange
Definition: CLMS100eth.h:115
mrpt::hwdrivers::CLMS100Eth::~CLMS100Eth
virtual ~CLMS100Eth()
Destructor.
mrpt::hwdrivers::CLMS100Eth::turnOff
bool turnOff()
This method could be called manually to stop communication with the device.
mrpt::utils::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: CConfigFileBase.h:31
mrpt::hwdrivers::CLMS100Eth::setSensorPose
void setSensorPose(const mrpt::poses::CPose3D &_pose)
A method to set the sensor pose on the robot.
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
mrpt::hwdrivers::CLMS100Eth::decodeScanDataCfg
bool decodeScanDataCfg(std::istringstream &stream)
mrpt::hwdrivers::CLMS100Eth::decodeScan
bool decodeScan(char *buf, mrpt::obs::CObservation2DRangeScan &outObservation)
mrpt::hwdrivers::CLMS100Eth::turnOn
bool turnOn()
This method must be called before trying to get a laser scan.
mrpt::hwdrivers::CLMS100Eth::sendCommand
void sendCommand(const char *cmd)
mrpt::hwdrivers::CLMS100Eth
This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scan...
Definition: CLMS100eth.h:64
mrpt::hwdrivers::CLMS100Eth::m_angleResolution
double m_angleResolution
Definition: CLMS100eth.h:111
mrpt::hwdrivers::CLMS100Eth::doProcessSimple
void doProcessSimple(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError)
This function acquire a laser scan from the device.
mrpt::hwdrivers::CLMS100Eth::m_turnedOn
bool m_turnedOn
Definition: CLMS100eth.h:107
mrpt::hwdrivers::CLMS100Eth::m_sensorPose
mrpt::poses::CPose3D m_sensorPose
Definition: CLMS100eth.h:114
mrpt::hwdrivers::CLMS100Eth::m_connected
bool m_connected
Definition: CLMS100eth.h:109
mrpt::hwdrivers::CLMS100Eth::loadConfig_sensorSpecific
void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection)
Load sensor pose on the robot, or keep the default sensor pose.
mrpt::hwdrivers::CLMS100Eth::doProcess
void doProcess()
This method should be called periodically.
mrpt::hwdrivers::CLMS100Eth::roughPrint
void roughPrint(char *msg)
HWDRIVERS_IMPEXP
#define HWDRIVERS_IMPEXP
Definition: hwdrivers_impexp.h:82
mrpt::hwdrivers::CLMS100Eth::m_cmd
std::string m_cmd
Definition: CLMS100eth.h:108
mrpt::hwdrivers::CLMS100Eth::m_port
unsigned int m_port
Definition: CLMS100eth.h:105
C2DRangeFinderAbstract.h



Page generated by Doxygen 1.8.20 for MRPT 1.4.0 SVN: at Thu Aug 27 02:40:23 UTC 2020