Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ProjectInterface.cc

Go to the documentation of this file.
00001 #include "ProjectInterface.h"
00002 #include "Wireless/Socket.h"
00003 #include "Vision/SegmentedColorGenerator.h"
00004 #include "debuget.h"
00005 #include <exception>
00006 
00007 namespace ProjectInterface {
00008 
00009   //! default implementation used for #sendCommand (just displays a warning and ignores the call)
00010   void noSendCommandErr(const std::string& cmd) {
00011     serr->printf("command '%s' ignored because no ProjectInterface::sendCommand() is installed\n",cmd.c_str());
00012   }
00013   void (*sendCommand)(const std::string& cmd)=noSendCommandErr;
00014   
00015   bool displayException(const char * file, int line, const char * message, const std::exception* ex) {
00016     if(file!=NULL) {
00017       serr->printf("Exception caught at %s:%d => ",debuget::extractFilename(file),line);
00018     } else {
00019       serr->printf("Exception => ");
00020     }
00021     if(ex!=NULL) {
00022       serr->printf("'%s'",ex->what());
00023     } else {
00024       serr->printf("'%s'","Unknown type");
00025     }
00026     if(message!=NULL) {
00027       serr->printf(" (%s)\n",message);
00028     } else {
00029       serr->printf("\n");
00030     }
00031 #ifndef PLATFORM_APERIOS
00032     serr->printf("\tWhen running in gdb, try 'catch throw' to break where exceptions are first thrown.\n");
00033 #endif
00034     return true;
00035   }
00036   bool (*uncaughtException)(const char * file, int line, const char * message, const std::exception* ex)=&displayException;
00037 
00038   //! default implementation assigned to lookupColorIndexByName(); checks that #defSegmentedColorGenerator is non-NULL and returns getColorIndex on it
00039   color_index defLookupColorIndexByName(const std::string& name) {
00040     if(defSegmentedColorGenerator==NULL)
00041       return -1U;
00042     return defSegmentedColorGenerator->getColorIndex(name);
00043   }
00044   color_index (*lookupColorIndexByName)(const std::string& name)=&defLookupColorIndexByName;
00045   
00046   //! default value initially assigned to lookupColorIndexByRgb(); checks that #defSegmentedColorGenerator is non-NULL and returns getColorIndex on it
00047   color_index defLookupColorIndexByRgb(const rgb rgbval) {
00048     if(defSegmentedColorGenerator==NULL)
00049       return -1U;
00050     return defSegmentedColorGenerator->getColorIndex(rgbval);
00051   }
00052   //! returns color index for color with specified "representitive" RGB color
00053   color_index (*lookupColorIndexByRgb)(const rgb rgbval)=&defLookupColorIndexByRgb;
00054   
00055   //! default implementation assigned to lookupColorRGB(); checks that #defSegmentedColorGenerator is non-NULL and returns getColorRGB on it
00056   rgb defLookupColorRGB(color_index cindex) {
00057     if(defSegmentedColorGenerator==NULL)
00058       return rgb();
00059     return defSegmentedColorGenerator->getColorRGB(cindex);
00060   }
00061   rgb (*lookupColorRGB)(color_index cindex)=&defLookupColorRGB;
00062 
00063         //! default implementation assigned to lookupColorName(); checks that #defSegmentedColorGenerator is non-NULL and returns getColorName on it
00064         const char* defLookupColorName(color_index cindex) {
00065     if(defSegmentedColorGenerator==NULL)
00066       return NULL;
00067     return defSegmentedColorGenerator->getColorName(cindex);
00068   }
00069         const char* (*lookupColorName)(color_index cindex)=&defLookupColorName;
00070 
00071   //! default value initially assigned to lookupNumColors(); checks that #defSegmentedColorGenerator is non-NULL and returns getNumColors on it
00072   unsigned int defLookupNumColors() {
00073     if ( defSegmentedColorGenerator == NULL ) 
00074       return -1U; 
00075     return defSegmentedColorGenerator->getNumColors();
00076   }
00077   //! returns the number of indexed colors which are currently defined
00078   unsigned int (*lookupNumColors)() = &defLookupNumColors;
00079 
00080 
00081   /*** Vision Setup ***/
00082   FilterBankGenerator * defRawCameraGenerator=NULL;
00083   FilterBankGenerator * defInterleavedYUVGenerator=NULL;
00084   JPEGGenerator * defColorJPEGGenerator=NULL;
00085   JPEGGenerator * defGrayscaleJPEGGenerator=NULL;
00086   PNGGenerator * defColorPNGGenerator=NULL;
00087   PNGGenerator * defGrayscalePNGGenerator=NULL;
00088   SegmentedColorGenerator * defSegmentedColorGenerator=NULL;
00089   RLEGenerator * defRLEGenerator=NULL;
00090   RegionGenerator * defRegionGenerator=NULL;
00091   
00092   
00093   /*** Vision SIDs ***/
00094   unsigned int visRawCameraSID=0;
00095 
00096   unsigned int visInterleaveSID=0;
00097 
00098   unsigned int visColorJPEGSID=0;
00099   unsigned int visGrayscaleJPEGSID=1;
00100 
00101   unsigned int visColorPNGSID=0;
00102   unsigned int visGrayscalePNGSID=1;
00103 
00104   unsigned int visSegmentSID=0;
00105 
00106   unsigned int visRLESID=0;
00107 
00108   unsigned int visRegionSID=0;
00109 
00110   unsigned int visPinkBallSID=0;
00111   unsigned int visBlueBallSID=1;
00112   unsigned int visGreenBallSID=2;
00113   unsigned int visYellowBallSID=3;
00114   unsigned int visOrangeSID=4;
00115   unsigned int visHandSID=visOrangeSID;
00116   
00117   
00118   /*** Layer Resolutions ***/
00119   unsigned int doubleLayer=5;
00120   unsigned int fullLayer=4;
00121   unsigned int halfLayer=3;
00122   unsigned int quarterLayer=2;
00123   unsigned int eighthLayer=1;
00124   unsigned int sixteenthLayer=0;
00125 
00126 }
00127 
00128 /*! @file
00129  * @brief Provides instantiation of the non-required members of ProjectInterface
00130  * @author ejt (Creator)
00131  *
00132  * $Author: ejt $
00133  * $Name: tekkotsu-4_0 $
00134  * $Revision: 1.22 $
00135  * $State: Exp $
00136  * $Date: 2007/11/11 06:18:35 $
00137  */
00138 

Tekkotsu v4.0
Generated Thu Nov 22 00:54:55 2007 by Doxygen 1.5.4