00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 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 #ifndef CIbeoLuxETH_H 00029 #define CIbeoLuxETH_H 00030 00031 #include <mrpt/hwdrivers/CGenericSensor.h> 00032 #include <mrpt/poses/CPose3D.h> 00033 #include <mrpt/poses/CPoint3D.h> 00034 #include <mrpt/slam/CObservation3DRangeScan.h> 00035 #include <mrpt/utils/CClientTCPSocket.h> 00036 00037 namespace mrpt 00038 { 00039 namespace hwdrivers 00040 { 00041 using namespace std; 00042 using namespace mrpt::hwdrivers; 00043 using namespace mrpt::utils; 00044 using namespace mrpt::slam; 00045 00046 /** This "software driver" implements the communication protocol for interfacing a Ibeo Lux laser scanners through an ethernet controller. 00047 * This class does not need to be bind, i.e. you do not need to call C2DRangeFinderAbstract::bindIO. 00048 * Connection is established when user call the turnOn() method. You can pass to the class's constructor the Lux's ip address and port. 00049 * Device will NOT be configured. Configuration has to be done seperately. 00050 * 00051 * To get a laser scan you must proceed like that : 00052 * \code 00053 * CIbeoLuxETH laser(string("192.168.0.10"), 1234); 00054 * laser.turnOn(); 00055 * bool isOutObs, hardwareError; 00056 * CObservation2DRangeScan outObs; 00057 * laser.doProcessSimple(isOutObs, outObs, hardwareError); 00058 * \endcode 00059 * 00060 * \note This class was contributed by Adrien Barral - Robopec (France) 00061 * \note And modified by Jan Girlich - University of Hamburg 00062 * \ingroup mrpt_hwdrivers_grp 00063 */ 00064 class HWDRIVERS_IMPEXP CIbeoLuxETH : public mrpt::hwdrivers::CGenericSensor 00065 { 00066 DEFINE_GENERIC_SENSOR(CIbeoLuxETH) 00067 00068 public: 00069 /** Constructor. 00070 * Note that there is default arguments, here you can customize IP Adress and TCP Port of your device. 00071 */ 00072 CIbeoLuxETH(string _ip=string("10.152.36.93"), unsigned int _port=12002); 00073 /** Destructor. 00074 * Close communcation with the device, and free memory. 00075 */ 00076 virtual ~CIbeoLuxETH(); 00077 /** This function acquire a laser scan from the device. If an error occured, hardwareError will be set to true. 00078 * The new laser scan will be stored in the outObservation argument. 00079 * 00080 * \exception This method throw exception if the frame received from the LMS 100 contain the following bad parameters : 00081 * * Status is not OK 00082 * * Data in the scan aren't DIST1 (may be RSSIx or DIST2). 00083 */ 00084 void doProcess(); 00085 void initialize(); 00086 void start(); 00087 void makeCommandHeader(unsigned char* buffer); 00088 void makeStartCommand(unsigned char* buffer); 00089 void makeStopCommand(unsigned char* buffer); 00090 void makeTypeCommand(unsigned char* buffer); 00091 00092 private : 00093 string m_ip; 00094 unsigned int m_port; 00095 CClientTCPSocket m_client; 00096 unsigned int m_scanFrequency; // in hertz 00097 double m_angleResolution; // in degrees 00098 double m_startAngle; // degrees 00099 double m_stopAngle; // degrees 00100 CPose3D m_sensorPose; 00101 double m_maxRange; 00102 double m_beamApperture; 00103 bool m_run; 00104 void dataCollection(); 00105 mrpt::system::TThreadHandle dataCollectionThread; 00106 float convertLayerToRad(int scanlayer); 00107 float convertTicksToHRad(int hticks, int hticksPerRotation); 00108 CPoint3D convertToCartesian(float vrad, float hrad, float distance); 00109 float vwinkel; 00110 vector<CObservation3DRangeScan> m_observations; 00111 bool m_newObs; 00112 float m_vAngle; 00113 unsigned int lastScanNumber; 00114 unsigned int curScanNumber; 00115 00116 protected: 00117 /** Load sensor pose on the robot, or keep the default sensor pose. 00118 */ 00119 void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, 00120 const std::string &iniSection ); 00121 00122 }; 00123 } 00124 } 00125 00126 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |