00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 University of Malaga | 00007 | | 00008 | This software was written by the Perception and Robotics | 00009 | research group, 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 CRoboticHeadInterface_H 00030 #define CRoboticHeadInterface_H 00031 00032 #include <mrpt/hwdrivers/CInterfaceFTDI.h> 00033 #include <mrpt/hwdrivers/CInterfaceFTDIMessages.h> 00034 #include <mrpt/utils/CMessage.h> 00035 #include <mrpt/synch.h> 00036 #include <mrpt/math/CMatrixTemplate.h> 00037 #include <mrpt/utils/CDebugOutputCapable.h> 00038 #include <mrpt/utils/CConfigFileBase.h> 00039 #include <mrpt/slam/CObservationRange.h> 00040 00041 00042 namespace mrpt 00043 { 00044 namespace hwdrivers 00045 { 00046 using namespace mrpt::math; 00047 00048 /** This "software driver" implements the communication protocol for interfacing a Robotic Head Board through a custom 00049 * USB RS-422 interface board. 00050 * In this class the "bind" is ignored since it is designed for USB connections only, thus it internally generate the required object for simplicity of use. 00051 * The default serial number is "OREJA001" 00052 * 00053 * Warning: Avoid defining an object of this class in a global scope if you want to catch all potential 00054 * exceptions during the constructors (like USB interface DLL not found, etc...) 00055 * 00056 * \code 00057 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: 00058 * ------------------------------------------------------- 00059 * [supplied_section_name] 00060 * HEAD_serialNumber=OREJA001 00061 * HEAD_gain=127,127,127 00062 * HEAD_yaw=0 //orientación inicial 00063 * HEAD_pitch=0 //elevación inicial 00064 * \endcode 00065 * 00066 */ 00067 class HWDLLIMPEXP CRoboticHeadInterface : public mrpt::utils::CDebugOutputCapable 00068 { 00069 private: 00070 CInterfaceFTDIMessages m_usbConnection; 00071 utils::CMessage msg; 00072 std::string m_serialNumber; 00073 std::vector<int32_t> gain; 00074 int head_yaw, head_pitch; 00075 00076 bool checkControllerIsConnected(); 00077 00078 public: 00079 /** Constructor 00080 */ 00081 CRoboticHeadInterface(); 00082 00083 /** Destructor 00084 */ 00085 ~CRoboticHeadInterface(){} 00086 00087 /** Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, 00088 * loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) 00089 * See hwdrivers::CSonarSRF10 for the possible parameters 00090 */ 00091 void loadConfig( const mrpt::utils::CConfigFileBase *configSource, 00092 const std::string &iniSection ); 00093 00094 /** Changes the serial number of the device to open 00095 */ 00096 void setDeviceSerialNumber(const std::string &deviceSerialNumber) 00097 { 00098 m_serialNumber = deviceSerialNumber; 00099 } 00100 00101 /** Read the gain for the amplifier of the ear "channel", where channel is 0, 1 or 2. 00102 */ 00103 void GetGain(int &_gain,int &channel); 00104 00105 /** Set the gain for the amplifier each ear. The value range is [0x00(min) .. 0x7F(max)]. The value 0x80 set the resistor 00106 * in high impedance state, ¡¡¡DON'T USE IT!!! 00107 */ 00108 bool SetGain(int &new_gain,int &channel); 00109 00110 /** This function return the angle where last sound where detected. This angle is related to the robot pose, NOT head pose. 00111 * \code 00112 * angle > 0deg --> Sound detected in the left 00113 * angle = 0deg --> Sound detected in front of the head 00114 * angle < 0deg --> Sound detected in the right 00115 * \endcode 00116 */ 00117 void GetSoundLocation(int &ang); 00118 00119 /** Debug only!!! This function return the last 500 acquired samples for each sound channel. 00120 * 00121 */ 00122 void Get3SoundBuffer(CMatrixTemplate<int> &buf); 00123 00124 /** Move the head in: 00125 * \code 00126 * elevation = 'yaw' degrees 00127 * orientation = 'pitch' degrees 00128 * \endcode 00129 */ 00130 void SetHeadPose(int &yaw, int &pitch); 00131 00132 //TO DO --> Funciones del acelerómetro 00133 // Movimientos faciales 00134 00135 }; // End of class 00136 00137 } // End of namespace 00138 } // end of namespace 00139 00140 #endif 00141
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 23:02:22 EDT 2009 |