00001 /*!@file Devices/BeoMonkey.H Interface to robot monkey head, derived from 00002 BeoChip which is an to interface Brian Hudson's BeoChip .*/ 00003 00004 // //////////////////////////////////////////////////////////////////// // 00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00006 // University of Southern California (USC) and the iLab at USC. // 00007 // See http://iLab.usc.edu for information about this project. // 00008 // //////////////////////////////////////////////////////////////////// // 00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00011 // in Visual Environments, and Applications'' by Christof Koch and // 00012 // Laurent Itti, California Institute of Technology, 2001 (patent // 00013 // pending; application number 09/912,225 filed July 23, 2001; see // 00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00015 // //////////////////////////////////////////////////////////////////// // 00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00017 // // 00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00019 // redistribute it and/or modify it under the terms of the GNU General // 00020 // Public License as published by the Free Software Foundation; either // 00021 // version 2 of the License, or (at your option) any later version. // 00022 // // 00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00026 // PURPOSE. See the GNU General Public License for more details. // 00027 // // 00028 // You should have received a copy of the GNU General Public License // 00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00031 // Boston, MA 02111-1307 USA. // 00032 // //////////////////////////////////////////////////////////////////// // 00033 // 00034 // Primary maintainer for this file: Laurent Itti <itti@usc.edu> 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Devices/BeoMonkey.H $ 00036 // $Id: BeoMonkey.H 6795 2006-06-29 20:45:32Z rjpeters $ 00037 // 00038 00039 #ifndef BEOMONKEY_H_DEFINED 00040 #define BEOMONKEY_H_DEFINED 00041 00042 #include "Component/ModelComponent.H" 00043 #include "Component/ModelParam.H" 00044 #include "Devices/BeoChip.H" 00045 #include "Devices/BeoMonkeyTypes.H" 00046 #include "Util/Types.H" 00047 #include <deque> 00048 #include <pthread.h> 00049 #include <stdarg.h> 00050 00051 class BeoMonkey : public BeoChip 00052 { 00053 public: 00054 //Constructor 00055 BeoMonkey(OptionManager& mgr, 00056 const std::string& descrName = "BeoMonkey", 00057 const std::string& tagName = "BeoMonkey"); 00058 00059 // These are monkey specific functions to call servo by its name, i.e. mouth these should be split into a subclass and we should make a beoAnimation superclass 00060 //############################################################ 00061 void setHEyePos(const float position,const int velocity); 00062 00063 std::deque<Position> getPathHEyePos(const float position, 00064 const int velocity, 00065 const float starpos = -999); 00066 00067 void setHEyePosRel(const float offset,const int velocity); 00068 00069 void setVEyePos(const float position,const int velocity); 00070 00071 std::deque<Position> getPathVEyePos(const float position, 00072 const int velocity, 00073 const float starpos = -999); 00074 00075 void setVEyePosRel(const float offset,const int velocity); 00076 00077 void setEyeLidsPos(const float position,const int velocity); 00078 00079 std::deque<Position> getPathEyeLidsPos(const float position, 00080 const int velocity, 00081 const float starpos = -999); 00082 00083 void setEyeLidsRel(const float offset,const int velocity); 00084 00085 void setEyeBrowPos(const float position,const int velocity); 00086 00087 std::deque<Position> getPathEyeBrowPos(const float position, 00088 const int velocity, 00089 const float starpos = -999); 00090 00091 void setEyeBrowPosRel(const float offset,const int velocity); 00092 00093 void setMouthPos(const float position,const int velocity); 00094 00095 std::deque<Position> getPathMouthPos(const float position, 00096 const int velocity, 00097 const float starpos = -999); 00098 00099 void setMouthPosRel(const float offset,const int velocity); 00100 00101 void setMuzzlePos(const float position,const int velocity); 00102 00103 std::deque<Position> getPathMuzzlePos(const float position, 00104 const int velocity, 00105 const float starpos = -999); 00106 00107 void setMuzzlePosRel(const float offset,const int velocity); 00108 00109 void setHHeadPos(const float position,const int velocity); 00110 00111 std::deque<Position> getPathHHeadPos(const float position, 00112 const int velocity, 00113 const float starpos = -999); 00114 00115 void setHHeadPosRel(const float offset,const int velocity); 00116 00117 void setVHeadPos(const float position,const int velocity); 00118 00119 std::deque<Position> getPathVHeadPos(const float position, 00120 const int velocity, 00121 const float starpos = -999); 00122 00123 void setVHeadPosRel(const float offset,const int velocity); 00124 00125 //make a surprsing face 00126 void surpriseFace(float surprise); 00127 00128 //########################################################### 00129 void start2(); 00130 00131 //set everthing to zerp 00132 void initializeServos(); 00133 00134 //put a sequence in the que, with a servo name and a sequence of positions 00135 void addSequence(const byte servo, std::deque<float> sequence); 00136 00137 //put a sequence in the que from another deque of positions 00138 void addSequence(std::deque<Position> pos); 00139 00140 //put the sequence at the end of the movement que 00141 void addEndSequence(std::deque<Position> pos); 00142 00143 //put the sequence at the end of another sequence 00144 std::deque<Position> addEndSequence(std::deque<Position> sequence, 00145 std::deque<Position> pos); 00146 00147 //return a sequence given a servo and an array of positions 00148 std::deque<Position> getSequence(const byte servo, 00149 std::deque<float> sequence); 00150 00151 //blend an array of sequences togeather for smooth animation and add it to the que 00152 void blendSequence(std::deque< std::deque<Position> > elements); 00153 00154 //blend an array of sequences togeather for smooth animation and return it 00155 std::deque<Position> getBlendSequence(std::deque< 00156 std::deque<Position> > elements); 00157 00158 //blend one sequeunce with another 00159 std::deque<Position> blend(std::deque<Position> p1, 00160 std::deque<Position> p2); 00161 00162 //blend sequenc with current que to the que a sequence with the 00163 void setServo(const byte servo,const float pos, const int velocity); 00164 00165 //return a deque of positions for a given servo movement 00166 std::deque<Position> getPathServo(const byte servo, const float pos, 00167 const int velocity, 00168 const float startpos = -999); 00169 00170 //concatenate a deque of deque's into a single deque 00171 std::deque<Position> concatSequence(std::deque< std::deque<Position> >); 00172 00173 //return the current movement que 00174 std::deque<Position> getQue(); 00175 00176 //check if the que is empty 00177 bool isQueEmpty(); 00178 00179 //perform the next motor movement, return false if que is empty 00180 bool nextTimeStep(); 00181 00182 //clear the movement que 00183 void clearQue(); 00184 00185 //remove all movements from a servo 00186 void removeServo(const byte servo); 00187 00188 //diognostic: print the Positions in a curent que 00189 void printPath(std::deque<Position> p); 00190 00191 //check if a servo is in the movement que 00192 float isServoInQue(byte servo); 00193 00194 //check how many movements are in the que 00195 int queSize(); 00196 00197 00198 //servo numbers 00199 static const int H_EYE = 1; 00200 static const int V_EYE = 3; 00201 static const int EYELIDS = 2; 00202 static const int EYEBROW = 4; 00203 static const int MOUTH = 0; 00204 static const int MUZZLE = 6; 00205 static const int H_HEAD = 7; 00206 static const int V_HEAD = 5; 00207 00208 //min mechanical positions 00209 static const byte H_EYE_MIN= 56; 00210 static const byte V_EYE_MIN= 16; 00211 static const byte EYELIDS_MIN= 5; 00212 static const byte EYEBROW_MIN= 85; 00213 static const byte MOUTH_MIN= 85; 00214 static const byte MUZZLE_MIN= 255; 00215 static const byte H_HEAD_MIN= 10; 00216 static const byte V_HEAD_MIN= 10; 00217 00218 //center position 00219 static const byte H_EYE_MID= 115; 00220 static const byte V_EYE_MID= 55; 00221 static const byte EYELIDS_MID= 90; 00222 static const byte EYEBROW_MID= 100; 00223 static const byte MOUTH_MID= 180; 00224 static const byte MUZZLE_MID= 127; 00225 static const byte H_HEAD_MID= 90; 00226 static const byte V_HEAD_MID= 60; 00227 00228 //max mechanical position 00229 static const byte H_EYE_MAX= 190; 00230 static const byte V_EYE_MAX= 110; 00231 static const byte EYELIDS_MAX= 150; 00232 static const byte EYEBROW_MAX= 165; 00233 static const byte MOUTH_MAX= 215; 00234 static const byte MUZZLE_MAX= 0; 00235 static const byte H_HEAD_MAX= 235; 00236 static const byte V_HEAD_MAX= 190; 00237 00238 private: 00239 00240 //the movemement que 00241 std::deque<Position> moveQue; 00242 00243 }; 00244 00245 00246 #endif 00247 00248 // ###################################################################### 00249 /* So things look consistent in everyone's emacs... */ 00250 /* Local Variables: */ 00251 /* indent-tabs-mode: nil */ 00252 /* End: */