00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 00029 #ifndef CLMS100ETH_H 00030 #define CLMS100ETH_H 00031 00032 #include <mrpt/utils.h> 00033 #include <mrpt/hwdrivers/C2DRangeFinderAbstract.h> 00034 00035 namespace mrpt 00036 { 00037 namespace hwdrivers 00038 { 00039 using namespace std; 00040 using namespace mrpt::hwdrivers; 00041 using namespace mrpt::utils; 00042 using namespace mrpt::slam; 00043 00044 /** This "software driver" implements the communication protocol for interfacing a SICK LMS100 laser scanners through an ethernet controller. 00045 * This class does not need to be bind, i.e. you do not need to call C2DRangeFinderAbstract::bindIO. 00046 * Connection is established when user call the turnOn() method. You can pass to the class's constructor the LMS100 's ip address and port. 00047 * Device will be configured with the following parameters : 00048 * - Start Angle : -45 deg (imposed by hardware) 00049 * - Stop Angle : +225 deg (imposed by hardware) 00050 * - Apperture : 270 deg (imposed by hardware) 00051 * - Angular resolution : 0.25 deg 00052 * - Scan frequency : 25 Hz 00053 * - Max Range : 20m (imposed by hardware). 00054 * 00055 * <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 00056 * <b>before using this class</b>, you must "pre-configure" your scanner with the SICK's software "SOAP" (this software ships with the device), 00057 * 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. 00058 * 00059 * To get a laser scan you must proceed like that : 00060 * \code 00061 * CLMS200Eth laser(string("192.168.0.10"), 1234); 00062 * laser.turnOn(); 00063 * bool isOutObs, hardwareError; 00064 * CObservation2DRangeScan outObs; 00065 * laser.doProcessSimple(isOutObs, outObs, hardwareError); 00066 * \endcode 00067 * 00068 * The sensor pose on the vehicle could be loaded from an ini configuration file with : 00069 * \code 00070 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00071 * ------------------------------------------------------- 00072 * [supplied_section_name] 00073 * ip_address = 192.168.0.50 ;a string wich is the SICK's ip adress (default is 192.168.0.1) 00074 * TCP_port = 1234 ; an integer value : the tcp ip port on wich the sick is listening (default is 2111). 00075 * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters) 00076 * pose_y=0 00077 * pose_z=0.34 00078 * pose_yaw=0 ; Angles in degrees 00079 * pose_pitch=0 00080 * pose_roll=0 00081 * \endcode 00082 * This class doesn't configure the SICK LMS sensor, it is recomended to configure the sensor via the 00083 * the SICK software : SOPAS. 00084 * \note This class was contributed by Adrien Barral - Robopec (France) 00085 * \ingroup mrpt_hwdrivers_grp 00086 */ 00087 class HWDRIVERS_IMPEXP CLMS100Eth : C2DRangeFinderAbstract 00088 { 00089 DEFINE_GENERIC_SENSOR(CLMS100Eth) 00090 public: 00091 /** Constructor. 00092 * Note that there is default arguments, here you can customize IP Adress and TCP Port of your device. 00093 */ 00094 CLMS100Eth(string _ip=string("192.168.0.1"), unsigned int _port=2111); 00095 /** Destructor. 00096 * Close communcation with the device, and free memory. 00097 */ 00098 virtual ~CLMS100Eth(); 00099 /** This function acquire a laser scan from the device. If an error occured, hardwareError will be set to true. 00100 * The new laser scan will be stored in the outObservation argument. 00101 * 00102 * \exception This method throw exception if the frame received from the LMS 100 contain the following bad parameters : 00103 * * Status is not OK 00104 * * Data in the scan aren't DIST1 (may be RSSIx or DIST2). 00105 */ 00106 void doProcessSimple(bool &outThereIsObservation, CObservation2DRangeScan &outObservation, bool &hardwareError); 00107 00108 /** This method must be called before trying to get a laser scan. 00109 */ 00110 bool turnOn(); 00111 /** This method could be called manually to stop communication with the device. Method is also called by destructor. 00112 */ 00113 bool turnOff(); 00114 /** A method to set the sensor pose on the robot. 00115 */ 00116 void setSensorPose(CPose3D& _pose); 00117 00118 /** This method should be called periodically. Period depend on the process_rate in the configuration file. 00119 */ 00120 void doProcess(); 00121 00122 /** Initialize the sensor according to the parameters previously read in the configuration file. 00123 */ 00124 void initialize(); 00125 private : 00126 string m_ip; 00127 unsigned int m_port; 00128 CClientTCPSocket m_client; 00129 bool m_turnedOn; 00130 string m_cmd; 00131 bool m_connected; 00132 unsigned int m_scanFrequency; // en hertz 00133 double m_angleResolution; // en degrés 00134 double m_startAngle; // degrés 00135 double m_stopAngle; // degrés 00136 CPose3D m_sensorPose; 00137 double m_maxRange; 00138 double m_beamApperture; 00139 00140 void generateCmd(const char *cmd); 00141 bool checkIsConnected(); 00142 bool decodeLogIn(char *msg); 00143 bool decodeScanCfg(istringstream& stream); 00144 bool decodeScanDataCfg(istringstream& stream); 00145 bool decodeScan(char *buf, CObservation2DRangeScan& outObservation); 00146 void sendCommand(const char *cmd); 00147 void roughPrint( char *msg ); 00148 00149 00150 protected: 00151 /** Load sensor pose on the robot, or keep the default sensor pose. 00152 */ 00153 void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, 00154 const std::string &iniSection ); 00155 00156 }; 00157 } 00158 } 00159 #endif // CLMS100ETH_H
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |