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 CGyroKVHDSP3000_H 00030 #define CGyroKVHDSP3000_H 00031 00032 00033 #include <mrpt/hwdrivers/CGenericSensor.h> 00034 #include <mrpt/hwdrivers/CSerialPort.h> 00035 00036 #include <mrpt/poses/CPose3D.h> 00037 #include <mrpt/slam/CObservationIMU.h> 00038 00039 namespace mrpt 00040 { 00041 namespace hwdrivers 00042 { 00043 enum GYRO_MODE{RATE, INCREMENTAL_ANGLE, INTEGRATED_ANGLE}; 00044 /** A class for interfacing KVH DSP 3000 gyroscope with an assynchronous serial communication (product SN : 02-1222-01). 00045 * It uses a serial port connection to the device. The class implements the generic sensor class. 00046 * See also the application "rawlog-grabber" for a ready-to-use application to gather data from the scanner. 00047 * The generated observation is a CObservationIMU, but only the yaw angular velocity and the absolute yaw position are 00048 * are set in the vector CObservationIMU::rawMeasurements. 00049 * The sensor process rate is imposed by hardware at 100Hz. 00050 * For now, this sensor is only supported on posix system. 00051 * \code 00052 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00053 * ------------------------------------------------------- 00054 * [supplied_section_name] 00055 * process_rate = 100 ; MUST be 100 Hz. 00056 * pose_x=0 ; Sensor 3D position relative to the robot (meters) 00057 * pose_y=0 00058 * pose_z=0 00059 * pose_yaw=0 ; Angles in degrees 00060 * pose_pitch=0 00061 * pose_roll=0 00062 * sensorLabel = <label> ; Label of the sensor 00063 * COM_port_LIN = /dev/ttyUSB0 ; COM PORT in LINUX 00064 * operatingMode = <"rate"/"integrated", "incremental"> ; Default mode is Rate. 00065 * \endcode 00066 * In most of the communs applications, this class will be used as : 00067 * \code 00068 * CGyroKVHDSP3000 kvh; 00069 * /// ... 00070 * CConfigFile conf("conf.ini"); 00071 * /// ... 00072 * kvh.loadConfig_sensorSpecific(conf, "KVH"); 00073 * /// ... 00074 * while(1) { 00075 * kvh.doProcess(); 00076 * TListObservations rateObs; 00077 * kvh.getObservations(rateObs); 00078 * // .... 00079 * \endcode 00080 * \ingroup mrpt_hwdrivers_grp 00081 */ 00082 class HWDRIVERS_IMPEXP CGyroKVHDSP3000 : public hwdrivers::CGenericSensor 00083 { 00084 DEFINE_GENERIC_SENSOR(CGyroKVHDSP3000) 00085 protected: 00086 00087 /** This serial port will be attempted to be opened automatically when this class is first used to request data from the device. 00088 * \sa hwdrivers::CSerialPort 00089 */ 00090 int m_COMbauds; 00091 std::string m_com_port; 00092 00093 mrpt::poses::CPose3D m_sensorPose; 00094 00095 /** Search the port where the sensor is located and connect to it 00096 */ 00097 bool searchPortAndConnect(); 00098 00099 CSerialPort* m_serialPort; //!< The serial port connection 00100 GYRO_MODE m_mode; 00101 bool m_firstInteration; 00102 00103 mrpt::slam::CObservationIMUPtr m_observationGyro; 00104 00105 public: 00106 /** Constructor 00107 */ 00108 CGyroKVHDSP3000( ); 00109 00110 /** Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) 00111 * See hwdrivers::CGyroKVHDSP3000 for the possible parameters 00112 */ 00113 void loadConfig_sensorSpecific( 00114 const mrpt::utils::CConfigFileBase &configSource, 00115 const std::string &iniSection ); 00116 00117 /** Destructor 00118 */ 00119 virtual ~CGyroKVHDSP3000(); 00120 00121 00122 /** This method will be invoked at a minimum rate of "process_rate" (Hz) 00123 * \exception This method must throw an exception with a descriptive message if some critical error is found. 00124 */ 00125 void doProcess(); 00126 00127 /** Turns on the KVH DSP 3000 device and configure it for getting orientation data. you must have called loadConfig_sensorSpecific before 00128 * calling this function. 00129 */ 00130 void initialize(); 00131 /** Send to the sensor the command 'Z' wich reset the integrated angle. (in both rate mode and incremental, this function has no effect) */ 00132 void resetIncrementalAngle(void); 00133 void changeMode(GYRO_MODE _newMode); 00134 00135 00136 }; // end of class 00137 00138 } // end of namespace 00139 } // end of namespace 00140 00141 #endif 00142 00143
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |