Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ProjectInterface.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_ProjectInterface_h_
00003 #define INCLUDED_ProjectInterface_h_
00004 
00005 #include "Vision/colors.h"
00006 #include <string>
00007 
00008 class BehaviorBase;
00009 class FilterBankGenerator;
00010 class SegmentedColorGenerator;
00011 class RLEGenerator;
00012 class RegionGenerator;
00013 class JPEGGenerator;
00014 class PNGGenerator;
00015 namespace std {
00016   class exception;
00017 }
00018 
00019 //! A collection of the global variables which should be set by a project to use the Tekkotsu framework
00020 /*! This namespace hold a few variables needed for initialization of the
00021  *  framework, but mainly declares variables which are used by demo
00022  *  behaviors.  Although the variables are declared here, and
00023  *  some default values provided, it is up to your project to define
00024  *  the actual values used for your own project.  This provides a way
00025  *  to reassign conflicts between values provided by the framework vs.
00026  *  those you might wish to add to your project.
00027  *  
00028  *  Currently, all required members are references (so they can't be
00029  *  set to NULL and you'll get errors if you leave them out) and all
00030  *  optional settings are pointers so you can ignore them if you want.
00031  *  
00032  *  The "optional" variables are used by demo behaviors, and thus
00033  *  if you remove all of the demo behaviors, you won't need to define
00034  *  the corresponding interface values here.
00035  *
00036  *  If you want to add new ID values for your project, create a new
00037  *  'globals.h' or some such in your project -- you don't need to
00038  *  add them here since this file is shared by all projects which
00039  *  use the framework, you shouldn't need to modify it for each
00040  *  project.
00041  */
00042 namespace ProjectInterface {
00043   
00044   //! REQUIRED: you must define a behavior which will be started when the boot is complete
00045   /*! This is similar in idea to the Linux init process - it should do
00046    *  some basic initialization and then launch any other behavior you
00047    *  would like to run at boot.
00048    *  To avoid static initialization ordering issues, this is a function
00049    *  which will be called after environment setup is complete, which
00050    *  should then return a behavior to use as the startup behavior.
00051    *  This behavior should not be reference counted, and probably makes
00052    *  most sense to implement as a static local variable of the function.
00053    *  (Each call should return the same behavior) */
00054   BehaviorBase& startupBehavior();
00055   
00056   //! sends a command to the project, allows GUI elements of the framework to send commands to the hardware abstraction layer
00057   /*! Generally commands are assumed to be for the Tekkostu HAL command line,
00058    *  and otherwise this will be left NULL. */
00059   extern void (*sendCommand)(const std::string& cmd);
00060   
00061   //! The exception handler for exceptions which have fallen through to base Tekkotsu functions
00062   /*! You can override this to install your own handler by assigning a
00063    *  new function.  This defaults to displayException(), which
00064    *  <b>does not</b> call abort() (which would otherwise be the
00065    *  default if the exception fell through).
00066    *  @param file The file where the exception was caught (usually just pass __FILE__), or NULL
00067    *  @param line The line number where the exception was caught (usually just pass __LINE__), if @a file is NULL, @a line is ignored
00068    *  @param message An addition message, or NULL
00069    *  @param ex The exception which was caught, or NULL if it is was not a std::exception subclass
00070    *  @return true if the exception was handled, false if the exception should be rethrown */
00071   extern bool (*uncaughtException)(const char * file, int line, const char * message, const std::exception* ex);
00072 
00073   //! Displays information about an exception on #serr, provides a default value for #uncaughtException
00074   /*! You can call this directly from your own code any time you would like an exception error message.
00075    *  @param file The file where the exception was caught (usually just pass __FILE__), or NULL
00076    *  @param line The line number where the exception was caught (usually just pass __LINE__), if @a file is NULL, @a line is ignored
00077    *  @param message An addition message, or NULL
00078    *  @param ex The exception which was caught, or NULL if it is was not a std::exception subclass
00079    *  @return true, indicating the exception was handled adequately */
00080   bool displayException(const char * file, int line, const char * message, const std::exception* ex);
00081   
00082   //! allows you to override how colors are defined -- by default, this will be set to a function which passes the call to defSegmentedColorGenerator
00083   /*! As per SegmentedColorGenerator::getColorIndex(), if @a name is not valid, return -1U */
00084   extern color_index (*lookupColorIndexByName)(const std::string& name);
00085   //! allows you to override how colors are defined -- by default, this will be set to a function which passes the call to defSegmentedColorGenerator
00086   extern color_index (*lookupColorIndexByRgb)(const rgb rgbval);
00087   //! allows you to override how colors are defined -- by default, this will be set to a function which passes the call to defSegmentedColorGenerator
00088   /*! As per SegmentedColorGenerator::getColorRGB(), if @a index is not valid, return black (rgb()) */
00089   extern rgb (*lookupColorRGB)(color_index cindex);
00090   //! allows you to override how colors are defined -- by default, this will be set to a function which passes the call to defSegmentedColorGenerator
00091   /*! As per SegmentedColorGenerator::getColorRGB(), if @a index is not valid, return black (rgb()) */
00092   extern const char* (*lookupColorName)(color_index cindex);
00093   
00094   //! Returns the index corresponding to a color of specified name by calling lookupColorIndexByName()
00095   /*! As per SegmentedColorGenerator::getColorIndex(), if @a name is not valid, return -1U */
00096   inline color_index getColorIndex(const std::string& name) { if(lookupColorIndexByName==NULL) return -1U; return (*lookupColorIndexByName)(name); }
00097   //! Returns the index corresponding to an rgb value  by calling lookupColorIndexByRgb()
00098   inline color_index getColorIndex(const rgb rgbval) { if(lookupColorIndexByRgb==NULL) return -1U; return (*lookupColorIndexByRgb)(rgbval); }
00099   //! Returns rgb value corresponding to a color of specified name by calling lookupColorRGB(lookupColorIndexByName())
00100   /*! As per SegmentedColorGenerator::getColorRGB(), if @a name is not valid, return black (rgb()) */
00101   inline rgb getColorRGB(const std::string& name)  { if(lookupColorIndexByName==NULL || lookupColorRGB==NULL) return rgb(); return (*lookupColorRGB)((*lookupColorIndexByName)(name)); }
00102   //! Returns rgb value corresponding to a color of specified name by calling lookupColorRGB()
00103   /*! As per SegmentedColorGenerator::getColorRGB(), if @a index is not valid, return black (rgb()) */
00104   inline rgb getColorRGB(color_index cindex)  { if(lookupColorRGB==NULL) return rgb(); return (*lookupColorRGB)(cindex); }
00105 
00106   //! Returns color name corresponding to specified color index by calling lookupColorName()
00107   /*! As per SegmentedColorGenerator::getColorName(), if @a index is not valid, return NULL */
00108   inline const char* getColorName(color_index cindex) { if(lookupColorName==NULL) return NULL; return (*lookupColorName)(cindex); }
00109   
00110   extern unsigned int (*lookupNumColors)();
00111   //! Returns the number of colors, obtained from defSegmentedColorGenerator
00112   inline unsigned int getNumColors() { if (lookupNumColors == NULL) return -1U; return (*lookupNumColors)(); }
00113 
00114   //! A collection of the various stages of vision processing.  None of these are absolutely required, but are needed to run included demo behaviors and TekkotsuMon modules
00115   /*! @name Vision Setup */
00116   //! pointer to generator
00117   extern FilterBankGenerator * defRawCameraGenerator;
00118   extern FilterBankGenerator * defInterleavedYUVGenerator;
00119   extern JPEGGenerator * defColorJPEGGenerator;
00120   extern JPEGGenerator * defGrayscaleJPEGGenerator;
00121   extern PNGGenerator * defColorPNGGenerator;
00122   extern PNGGenerator * defGrayscalePNGGenerator;
00123   extern SegmentedColorGenerator * defSegmentedColorGenerator;
00124   extern RLEGenerator * defRLEGenerator;
00125   extern RegionGenerator * defRegionGenerator;
00126   //@}
00127 
00128   //! Default source IDs for the various generators; These are given default values, but you can reassign them if you like.
00129   /*! @name Vision SIDs */
00130   //! source id for vision events from the corresponding pipeline stage or object detector
00131   extern unsigned int visRawCameraSID;
00132   extern unsigned int visInterleaveSID;
00133   extern unsigned int visColorJPEGSID;
00134   extern unsigned int visGrayscaleJPEGSID;
00135   extern unsigned int visColorPNGSID;
00136   extern unsigned int visGrayscalePNGSID;
00137   extern unsigned int visSegmentSID;
00138   extern unsigned int visRLESID;
00139   extern unsigned int visRegionSID;
00140   extern unsigned int visPinkBallSID;
00141   extern unsigned int visBlueBallSID;
00142   extern unsigned int visGreenBallSID;
00143   extern unsigned int visYellowBallSID;
00144   extern unsigned int visOrangeSID;
00145   extern unsigned int visHandSID; //!< synonym for #visOrangeSID
00146   //@}
00147 
00148   //! Allows you to request a particular layer abstractly - this isn't used by the framework, just a suggestion for clarity
00149   /*! @name Layer Resolutions */
00150   extern unsigned int doubleLayer;   //!< ERS-2xx: 352*288; ERS-7 416*320 (requires non-trivial computation)
00151   extern unsigned int fullLayer;     //!< ERS-2xx: 176*144; ERS-7 208*160
00152   extern unsigned int halfLayer;     //!< ERS-2xx: 88*72; ERS-7 104*80
00153   extern unsigned int quarterLayer;  //!< ERS-2xx: 44*36; ERS-7 52*40
00154   extern unsigned int eighthLayer;   //!< ERS-2xx: 22*18; ERS-7 26*20 (simply a bigger interleave referencing quarterLayer)
00155   extern unsigned int sixteenthLayer;//!< ERS-2xx: 11*9; ERS-7 13*10 (simply a bigger interleave referencing quarterLayer)
00156   //@}
00157 }
00158 
00159 /*! @file
00160  * @brief Defines ProjectInterface namespace - a collection of the global variables which should be set by a project to use the Tekkotsu framework
00161  * @author ejt (Creator)
00162  *
00163  * $Author: ejt $
00164  * $Name: tekkotsu-4_0 $
00165  * $Revision: 1.19 $
00166  * $State: Exp $
00167  * $Date: 2007/06/13 18:14:14 $
00168  */
00169 
00170 #endif

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