BeoHead.H

Go to the documentation of this file.
00001 /*!@file Devices/BeoHead.H Interface to robot head */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00005 // University of Southern California (USC) and the iLab at USC.         //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Lior Elazary <elazary@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Devices/BeoHead.H $
00035 // $Id: BeoHead.H 8732 2007-08-30 19:33:05Z beobot $
00036 //
00037 
00038 #ifndef BeoHead_H_DEFINED
00039 #define BeoHead_H_DEFINED
00040 
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "Devices/Pololu.H"
00044 #include "Controllers/PID.H"
00045 #include "Util/Types.H"
00046 #include <deque>
00047 #include <pthread.h>
00048 #include <stdarg.h>
00049 
00050 class BeoHead : public ModelComponent
00051 {
00052 public:
00053   //Constructor
00054   BeoHead(OptionManager& mgr,
00055           const std::string& descrName = "BeoHead",
00056           const std::string& tagName = "BeoHead");
00057 
00058   bool setLeftEyePan(float pos);
00059   bool setLeftEyeTilt(float pos);
00060   bool setRightEyePan(float pos);
00061   bool setRightEyeTilt(float pos);
00062 
00063   bool setHeadPan(float pos);
00064   bool setHeadTilt(float pos);
00065   bool setHeadYaw(float pos);
00066 
00067 
00068   float getLeftEyePanPos(){ return  itsLeftEyePanPos;  }
00069   float getRightEyeTiltPos(){ return  itsRightEyeTiltPos;}
00070   float getRightEyePanPos(){ return  itsRightEyePanPos; }
00071   float getLeftEyeTiltPos(){ return  itsLeftEyeTiltPos; }
00072   float getHeadPanPos(){ return  itsHeadPanPos;     }
00073   float getHeadTiltPos(){ return  itsHeadTiltPos;    }
00074   float getHeadYawPos(){ return  itsHeadYawPos;     }
00075 
00076 
00077   bool relaxNeck(); //shut off neck servos
00078   bool relaxHead(); //shut off all servos
00079   bool moveRestPos(); //move the head to a relaxed position (all servos on)
00080 
00081   //move the head to the desired position based on the current visual pos
00082   float trackTarget(float desiredVisualPosX, float desiredVisualPosY,
00083     float currentVisualPosX, float currentVisualPosY);
00084 
00085   //###########################################################
00086   void start2();
00087 
00088   void initHead();
00089 
00090   //servo definition
00091   static const byte LEFT_EYE_PAN     = 2;
00092   static const byte LEFT_EYE_TILT    = 1;
00093   static const byte RIGHT_EYE_PAN    = 0;
00094   static const byte RIGHT_EYE_TILT   = 3;
00095 
00096   static const byte HEAD_PAN         = 6;
00097   static const byte HEAD_LEFT        = 7;
00098   static const byte HEAD_RIGHT       = 5;
00099 
00100 private:
00101 
00102   nub::soft_ref<Pololu> itsPololu; //our servo controller
00103 
00104   float itsLeftEyePanPos;
00105   float itsRightEyeTiltPos;
00106   float itsRightEyePanPos;
00107   float itsLeftEyeTiltPos;
00108   float itsHeadPanPos;
00109   float itsHeadTiltPos;
00110   float itsHeadYawPos;
00111 
00112   PID<float>  pidLeftPan;
00113   PID<float>  pidLeftTilt;
00114   PID<float>  pidHeadPan;
00115 
00116 
00117   bool isNeckRelaxed;
00118 };
00119 
00120 
00121 #endif
00122 
00123 // ######################################################################
00124 /* So things look consistent in everyone's emacs... */
00125 /* Local Variables: */
00126 /* indent-tabs-mode: nil */
00127 /* End: */
Generated on Sun May 8 08:04:44 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3