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