Main MRPT website > C++ reference
MRPT logo
CRoboticHeadInterface.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef CRoboticHeadInterface_H
30 #define CRoboticHeadInterface_H
31 
34 #include <mrpt/utils/CMessage.h>
35 #include <mrpt/synch.h>
40 
41 
42 namespace mrpt
43 {
44  namespace hwdrivers
45  {
46  using namespace mrpt::math;
47 
48  /** This "software driver" implements the communication protocol for interfacing a Robotic Head Board through a custom
49  * USB RS-422 interface board.
50  * 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.
51  * The default serial number is "OREJA001"
52  *
53  * Warning: Avoid defining an object of this class in a global scope if you want to catch all potential
54  * exceptions during the constructors (like USB interface DLL not found, etc...)
55  *
56  * \code
57  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
58  * -------------------------------------------------------
59  * [supplied_section_name]
60  * HEAD_serialNumber=OREJA001
61  * HEAD_gain=127,127,127
62  * HEAD_yaw=0 //orientación inicial
63  * HEAD_pitch=0 //elevación inicial
64  * \endcode
65  * \ingroup mrpt_hwdrivers_grp
66  */
68  {
69  private:
72  std::string m_serialNumber;
73  std::vector<int32_t> gain;
74  int head_yaw, head_pitch;
75 
76  bool checkControllerIsConnected();
77 
78  protected:
79  /** Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file,
80  * loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes)
81  * See hwdrivers::CSonarSRF10 for the possible parameters
82  */
83  void loadConfig_sensorSpecific( const mrpt::utils::CConfigFileBase *configSource,
84  const std::string &iniSection );
85 
86  public:
87  /** Constructor
88  */
90 
91  /** Destructor
92  */
94 
95  /** Changes the serial number of the device to open
96  */
97  void setDeviceSerialNumber(const std::string &deviceSerialNumber)
98  {
99  m_serialNumber = deviceSerialNumber;
100  }
101 
102  /** Read the gain for the amplifier of the ear "channel", where channel is 0, 1 or 2.
103  */
104  void GetGain(int &_gain,int &channel);
105 
106  /** Set the gain for the amplifier each ear. The value range is [0x00(min) .. 0x7F(max)]. The value 0x80 set the resistor
107  * in high impedance state, ¡¡¡DON'T USE IT!!!
108  */
109  bool SetGain(int &new_gain,int &channel);
110 
111  /** This function return the angle where last sound where detected. This angle is related to the robot pose, NOT head pose.
112  * \code
113  * angle > 0deg --> Sound detected in the left
114  * angle = 0deg --> Sound detected in front of the head
115  * angle < 0deg --> Sound detected in the right
116  * \endcode
117  */
118  void GetSoundLocation(int &ang);
119 
120  /** Debug only!!! This function return the last 500 acquired samples for each sound channel.
121  *
122  */
123  void Get3SoundBuffer(CMatrixTemplate<int> &buf);
124 
125  /** Move the head in:
126  * \code
127  * elevation = 'yaw' degrees
128  * orientation = 'pitch' degrees
129  * \endcode
130  */
131  void SetHeadPose(int &yaw, int &pitch);
132 
133  //TO DO --> Funciones del acelerómetro
134  // Movimientos faciales
135 
136  }; // End of class
137 
138  } // End of namespace
139 } // end of namespace
140 
141 #endif
142 



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013