00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2010 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 * To get a laser scan you must proceed like that : 00056 * \code 00057 * CLMS200Eth laser(string("192.168.0.10"), 1234); 00058 * laser.turnOn(); 00059 * bool isOutObs, hardwareError; 00060 * CObservation2DRangeScan outObs; 00061 * laser.doProcessSimple(isOutObs, outObs, hardwareError); 00062 * \endcode 00063 * 00064 * The sensor pose on the vehicle could be loaded from an ini configuration file with : 00065 * \code 00066 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00067 * ------------------------------------------------------- 00068 * [supplied_section_name] 00069 * pose_x=0.21 ; Laser range scaner 3D position in the robot (meters) 00070 * pose_y=0 00071 * pose_z=0.34 00072 * pose_yaw=0 ; Angles in degrees 00073 * pose_pitch=0 00074 * pose_roll=0 00075 * \endcode 00076 * 00077 * \note This class was contributed by Adrien Barral - Robopec (France) 00078 */ 00079 class HWDRIVERS_IMPEXP CLMS100Eth : C2DRangeFinderAbstract 00080 { 00081 DEFINE_GENERIC_SENSOR(CLMS100Eth) 00082 public: 00083 /** Constructor. 00084 * Note that there is default arguments, here you can customize IP Adress and TCP Port of your device. 00085 */ 00086 CLMS100Eth(string _ip=string("192.168.0.1"), unsigned int _port=2111); 00087 /** Destructor. 00088 * Close communcation with the device, and free memory. 00089 */ 00090 virtual ~CLMS100Eth(); 00091 /** This function acquire a laser scan from the device. If an error occured, hardwareError will be set to true. 00092 * The new laser scan will be stored in the outObservation argument. 00093 * 00094 * \exception This method throw exception if the frame received from the LMS 100 contain the following bad parameters : 00095 * * Status is not OK 00096 * * Data in the scan aren't DIST1 (may be RSSIx or DIST2). 00097 */ 00098 void doProcessSimple(bool &outThereIsObservation, CObservation2DRangeScan &outObservation, bool &hardwareError); 00099 00100 /** This method must be called before trying to get a laser scan. 00101 */ 00102 bool turnOn(); 00103 /** This method could be called manually to stop communication with the device. Method is also called by destructor. 00104 */ 00105 bool turnOff(); 00106 /** A method to set the sensor pose on the robot. 00107 */ 00108 void setSensorPose(CPose3D& _pose); 00109 00110 private : 00111 string m_ip; 00112 unsigned int m_port; 00113 CClientTCPSocket m_client; 00114 bool m_turnedOn; 00115 string m_cmd; 00116 bool m_connected; 00117 unsigned int m_scanFrequency; // en hertz 00118 double m_angleResolution; // en degrés 00119 double m_startAngle; // degrés 00120 double m_stopAngle; // degrés 00121 CPose3D m_sensorPose; 00122 double m_maxRange; 00123 double m_beamApperture; 00124 00125 void generateCmd(const char *cmd); 00126 bool checkIsConnected(); 00127 bool decodeLogIn(char *msg); 00128 bool decodeScanCfg(istringstream& stream); 00129 bool decodeScanDataCfg(istringstream& stream); 00130 bool decodeScan(char *buf, CObservation2DRangeScan& outObservation); 00131 void sendCommand(const char *cmd); 00132 void roughPrint( char *msg ); 00133 00134 00135 protected: 00136 /** Load sensor pose on the robot, or keep the default sensor pose. 00137 */ 00138 void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, 00139 const std::string &iniSection ); 00140 00141 }; 00142 } 00143 } 00144 #endif // CLMS100ETH_H
| Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010 |
