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