Main MRPT website > C++ reference
MRPT logo

CRoboticHeadInterface.h

Go to the documentation of this file.
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 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 HWDRIVERS_IMPEXP 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                         protected:
00079                                 /** Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file,
00080                                   *  loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes)
00081                                   *  See hwdrivers::CSonarSRF10 for the possible parameters
00082                                   */
00083                                 void  loadConfig_sensorSpecific(        const mrpt::utils::CConfigFileBase *configSource,
00084                                                                         const std::string         &iniSection );
00085 
00086                         public:
00087                                 /** Constructor
00088                                   */
00089                                 CRoboticHeadInterface();
00090 
00091                                 /** Destructor
00092                                   */
00093                                 ~CRoboticHeadInterface(){}
00094 
00095                                 /** Changes the serial number of the device to open
00096                                   */
00097                                 void  setDeviceSerialNumber(const std::string &deviceSerialNumber)
00098                                 {
00099                                         m_serialNumber = deviceSerialNumber;
00100                                 }
00101 
00102                                 /** Read the gain for the amplifier of the ear "channel", where channel is 0, 1 or 2.
00103                                   */
00104                                 void GetGain(int &_gain,int &channel);
00105 
00106                                 /** Set the gain for the amplifier each ear. The value range is [0x00(min) .. 0x7F(max)]. The value 0x80 set the resistor
00107                                   * in high impedance state, ¡¡¡DON'T USE IT!!!
00108                                   */
00109                                 bool SetGain(int &new_gain,int &channel);
00110 
00111                                 /** This function return the angle where last sound where detected. This angle is related to the robot pose, NOT head pose.
00112                                   * \code
00113                                   * angle > 0deg --> Sound detected in the left
00114                                   * angle = 0deg --> Sound detected in front of the head
00115                                   * angle < 0deg --> Sound detected in the right
00116                                   * \endcode
00117                                   */
00118                                 void GetSoundLocation(int &ang);
00119 
00120                                 /** Debug only!!! This function return the last 500 acquired samples for each sound channel.
00121                                   *
00122                                   */
00123                                 void Get3SoundBuffer(CMatrixTemplate<int>       &buf);
00124 
00125                                 /** Move the head in:
00126                                   * \code
00127                                   * elevation = 'yaw' degrees
00128                                   * orientation = 'pitch' degrees
00129                                   * \endcode
00130                                   */
00131                                 void SetHeadPose(int &yaw, int &pitch);
00132 
00133                                 //TO DO --> Funciones del acelerómetro
00134                                 //                      Movimientos faciales
00135 
00136                 };      // End of class
00137 
00138         } // End of namespace
00139 } // end of namespace
00140 
00141 #endif
00142 



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011