00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 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 */ 00081 class HWDRIVERS_IMPEXP CGyroKVHDSP3000 : public hwdrivers::CGenericSensor 00082 { 00083 DEFINE_GENERIC_SENSOR(CGyroKVHDSP3000) 00084 protected: 00085 00086 /** This serial port will be attempted to be opened automatically when this class is first used to request data from the device. 00087 * \sa hwdrivers::CSerialPort 00088 */ 00089 int m_COMbauds; 00090 std::string m_com_port; 00091 00092 mrpt::poses::CPose3D m_sensorPose; 00093 00094 /** Search the port where the sensor is located and connect to it 00095 */ 00096 bool searchPortAndConnect(); 00097 00098 CSerialPort* m_serialPort; //!< The serial port connection 00099 GYRO_MODE m_mode; 00100 bool m_firstInteration; 00101 00102 mrpt::slam::CObservationIMUPtr m_observationGyro; 00103 00104 public: 00105 /** Constructor 00106 */ 00107 CGyroKVHDSP3000( ); 00108 00109 /** 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) 00110 * See hwdrivers::CGyroKVHDSP3000 for the possible parameters 00111 */ 00112 void loadConfig_sensorSpecific( 00113 const mrpt::utils::CConfigFileBase &configSource, 00114 const std::string &iniSection ); 00115 00116 /** Destructor 00117 */ 00118 virtual ~CGyroKVHDSP3000(); 00119 00120 00121 /** This method will be invoked at a minimum rate of "process_rate" (Hz) 00122 * \exception This method must throw an exception with a descriptive message if some critical error is found. 00123 */ 00124 void doProcess(); 00125 00126 /** Turns on the KVH DSP 3000 device and configure it for getting orientation data. you must have called loadConfig_sensorSpecific before 00127 * calling this function. 00128 */ 00129 void initialize(); 00130 /** Send to the sensor the command 'Z' wich reset the integrated angle. (in both rate mode and incremental, this function has no effect) */ 00131 void resetIncrementalAngle(void); 00132 void changeMode(GYRO_MODE _newMode); 00133 00134 00135 }; // end of class 00136 00137 } // end of namespace 00138 } // end of namespace 00139 00140 #endif 00141 00142
Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:46:17 UTC 2011 |