void playStun() { int8_t j = 0; int8_t i; while (j < 10) { for (i = 0; i < 24; i++) { if(i % 2) { colorRed(); } else { colorYellow(); } } delay_25ms_n_times(11); for (i = 0; i < 24; i++) { if(i % 2) { colorYellow(); } else { colorRed(); } } delay_25ms_n_times(11); j++; } }
void playArmed() { //Setting all 24 LED's to Red and blinking rapidly int8_t j = 0; int8_t i; while (j < 5) { for (i = 0; i < 24; i++) { if(i % 2) { colorRed(); } else { colorRedTwo(); } } delay_25ms_n_times(11); for (i = 0; i < 24; i++) { if(i % 2) { colorRedTwo(); } else { colorRed(); } } delay_25ms_n_times(11); j++; } }
void Test::RunLocalizationTest(RGBImage* image) { DLLExecution * executor = new DLLExecution(image); executor->executePreProcessingStep1(false); executor->executePreProcessingStep2(false); executor->executePreProcessingStep3(false); executor->executePreProcessingStep4(false); executor->prepareLocalization(); IntensityImage* img = executor->resultPreProcessingStep4; HistogramLocalization localizer = HistogramLocalization(); FeatureMap features = FeatureMap(); FeatureMap detectedItems = localizer.locateHead(img, features); RGB colorRed(244, 67, 54); RGBImage * debug = ImageFactory::newRGBImage(executor->resultPreProcessingStep1->getWidth(), executor->resultPreProcessingStep1->getHeight()); ImageIO::intensityToRGB(*executor->resultPreProcessingStep1, *debug); for (int i = 0; i < 3; ++i) HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, Point2D<double>(detectedItems.getFeature(i).getX(), detectedItems.getFeature(i).getY()), colorRed); ImageIO::saveRGBImage(*debug, ImageIO::getDebugFileName("localisation.png")); ImageIO::showImage(*debug); }
TEST(ColorToHex, Trivial) { CColor colorRed(1.0f, 0.0f, 0.0f); CColor colorGreen(0.0f, 1.0f, 0.0f); CColor colorBlue(0.0f, 0.0f, 1.0f); std::string redHex = utils::colorToHex(colorRed); std::string greenHex = utils::colorToHex(colorGreen); std::string blueHex = utils::colorToHex(colorBlue); ASSERT_EQ(redHex, "ff0000"); ASSERT_EQ(greenHex, "00ff00"); ASSERT_EQ(blueHex, "0000ff"); }
void playDamage() { //Setting all 24 LED's to Red and blinking 5 times for (uint8_t i = 0; i < 24; i++) { colorRed(); } delay_25ms_n_times(5); clearPattern(); delay_25ms_n_times(5); }
void playTestPassed() { int i; for ( i = 0; i < 6; i++) { colorRed(); } for (i = 0; i < 6; i++) { colorYellow(); } for (i = 0; i < 6; i++) { colorGreen(); } for (i = 0; i < 6; i++) { colorBlue(); } delay_25ms_n_times(200); }
void NeoPixelEffects::randomColor() { i++; switch ((i / 20) % 4) { case 0: colorBlue(); break; case 1: colorRed(); break; case 2: colorGreen(); break; case 3: colorYellow(); break; } }
void drawFeatureDebugImage(IntensityImage &image, FeatureMap &features) { RGB colorRed(244, 67, 54); RGBImage * debug = ImageFactory::newRGBImage(image.getWidth(), image.getHeight()); ImageIO::intensityToRGB(image, *debug); //Nose Point2D<double> noseLeft = features.getFeature(Feature::FEATURE_NOSE_END_LEFT)[0]; Point2D<double> noseRight = features.getFeature(Feature::FEATURE_NOSE_END_RIGHT)[0]; Point2D<double> nostrilLeft = features.getFeature(Feature::FEATURE_NOSTRIL_LEFT)[0]; Point2D<double> nostrilRight = features.getFeature(Feature::FEATURE_NOSTRIL_RIGHT)[0]; Point2D<double> noseBottom = features.getFeature(Feature::FEATURE_NOSE_BOTTOM)[0]; //These (weird) methods can be used to draw debug points HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, noseLeft, colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, noseRight, colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, nostrilLeft, colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, nostrilRight, colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, noseBottom, colorRed); //Chin std::vector<Point2D<double>> points = features.getFeature(Feature::FEATURE_CHIN_CONTOUR).getPoints(); for (size_t i = 0; i < points.size(); i++) { HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, points[i], colorRed); } //Eye Feature leftEye = features.getFeature(Feature::FEATURE_EYE_LEFT_RECT); Feature rightEye = features.getFeature(Feature::FEATURE_EYE_RIGHT_RECT); //These (weird) methods can be used to draw debug rects HereBeDragons::AsHisTriumphantPrizeProudOfThisPride(*debug, leftEye[0], leftEye[1], colorRed); HereBeDragons::AsHisTriumphantPrizeProudOfThisPride(*debug, rightEye[0], rightEye[1], colorRed); //Head Feature headTop = features.getFeature(Feature::FEATURE_HEAD_TOP); Feature headLeftNoseMiddle = features.getFeature(Feature::FEATURE_HEAD_LEFT_NOSE_MIDDLE); Feature headLeftNoseBottom = features.getFeature(Feature::FEATURE_HEAD_LEFT_NOSE_BOTTOM); Feature headRightNoseMiddle = features.getFeature(Feature::FEATURE_HEAD_RIGHT_NOSE_MIDDLE); Feature headRightNoseBottom = features.getFeature(Feature::FEATURE_HEAD_RIGHT_NOSE_BOTTOM); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, headTop[0], colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, headLeftNoseMiddle[0], colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, headLeftNoseBottom[0], colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, headRightNoseMiddle[0], colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, headRightNoseBottom[0], colorRed); //Mouth Point2D<double> mouthTop = features.getFeature(Feature::FEATURE_MOUTH_TOP)[0]; Point2D<double> mouthBottom = features.getFeature(Feature::FEATURE_MOUTH_BOTTOM)[0]; Point2D<double> mouthLeft = features.getFeature(Feature::FEATURE_MOUTH_CORNER_LEFT)[0]; Point2D<double> mouthRight = features.getFeature(Feature::FEATURE_MOUTH_CORNER_RIGHT)[0]; //This (weird) method can be used to draw a debug line HereBeDragons::ButRisingAtThyNameDothPointOutThee(*debug, mouthLeft, mouthRight, colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, mouthTop, colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, mouthBottom, colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, mouthLeft, colorRed); HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, mouthRight, colorRed); ImageIO::saveRGBImage(*debug, ImageIO::getDebugFileName("feature-points-debug.png")); delete debug; }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { IWeapon* pWeapon = GetWeapon(pActInfo); if (!pWeapon) return; switch (event) { case eFE_Initialize: { m_isFiring = false; m_numShots = GetPortInt( pActInfo, IN_NUMBEROFSHOTS ); m_actInfo = *pActInfo; m_numShotsDone = 0; pWeapon->StopFire(); if (pActInfo->pEntity->GetId() != m_weapId) RemoveListener(m_weapId, this); m_weapId = pActInfo->pEntity->GetId(); pWeapon->AddEventListener(this, __FUNCTION__); #ifdef DEBUG_NODEFIREWEAPON pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true ); #endif break; } case eFE_Activate: { m_actInfo = *pActInfo; if (IsPortActive(pActInfo, IN_NUMBEROFSHOTS)) m_numShots = GetPortBool( pActInfo, IN_NUMBEROFSHOTS ); if (IsPortActive(pActInfo, IN_STOPFIRE)) { StopFiring( pActInfo, pWeapon ); } if (IsPortActive(pActInfo, IN_STARTFIRE)) { m_numShotsDone = 0; ReplenishAmmo( pWeapon ); pWeapon->StopFire(); StartFiring( pActInfo, pWeapon ); } break; } case eFE_Update: { // this fixes the problem when the entity is being externally moved/rotated, in the interval of time between when the weapon is aimed an the actual shot happens if (m_isFiring && GetPortBool( pActInfo, IN_ALIGNTOTARGET )) if (pActInfo->pEntity->GetWorldPos()!=m_lastPos || pActInfo->pEntity->GetWorldRotation()!=m_lastRotation) CalcFiringPosition( pActInfo, pWeapon ); #ifdef DEBUG_NODEFIREWEAPON ColorB colorRed( 255,0,0 ); ColorB colorGreen( 0,255,0 ); gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine( posOrig, colorRed, posTarget, colorRed ); gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine( posTarget, colorGreen, posShot, colorGreen ); #endif break; } } }
void WorkPlaceWidget::drawEntitie(Entitie* e, bool focus, bool isAbstract){ this->calculateEntitie(e); int x = ((IntField*)e->fieldByID("X"))->getValue(); int y = ((IntField*)e->fieldByID("Y"))->getValue(); int w = ((IntField*)e->fieldByID("W"))->getValue(); int h = ((IntField*)e->fieldByID("H"))->getValue(); int t = ((IntField*)e->fieldByID("T"))->getValue(); bool mov = true; for(int i=0; i<this->core->getEntitieCount(); i++){ Entitie* e0 = this->core->getEntitieAt(i); int xe = ((IntField*)e0->fieldByID("X"))->getValue(); int ye = ((IntField*)e0->fieldByID("Y"))->getValue(); int we = ((IntField*)e0->fieldByID("W"))->getValue(); int he = ((IntField*)e0->fieldByID("H"))->getValue(); if((xe-w-15<x)&&(ye-h-15<y)&&(we+xe+15>x)&&(he+ye+15>y)&&(e0!=e)){ mov = false; } } int alpha = (((isAbstract)||(!mov)) ? 20 : 250); int alpha0 = (((isAbstract)||(!mov)) ? 0 : 25); int alpha1 = (((isAbstract)||(!mov)) ? 0 : 100); if(isAbstract){ ((IntField*)e->fieldByID("X"))->setValue(this->curX); ((IntField*)e->fieldByID("Y"))->setValue(this->curY); } QPainter painter(this); QColor color(255,200,125,alpha); QColor color1(255,170,100,alpha); QColor color2(215,215,255,alpha); QColor colorRed(252,139,130,alpha); QColor colorGreen(125,220,125,alpha); QColor colorGreenAlpha(55,155,55,alpha0); QColor colorBlackAlpha(0,0,0,alpha1); QPen pen1 = QPen(Qt::black, 1, Qt::SolidLine); QPen pen2 = QPen(colorBlackAlpha, 1, Qt::SolidLine); painter.setPen(pen1); if(this->core->getState()==10 && this->core->getWeightOfSolution()!=-1){ bool green = false; for(int i=0; i<this->core->getBestWay()->size(); i++){ if(e->getID()==this->core->getBestWay()->at(i)){ green = true; } } if(t!=1){ if(green){ painter.setBrush(QBrush(colorGreen)); }else{ painter.setBrush(QBrush(colorRed)); } }else{ painter.setBrush(QBrush(color2)); } }else{ if(t==0){ painter.setBrush(QBrush(color1)); }else if(t==1){ painter.setBrush(QBrush(color2)); }else{ painter.setBrush(QBrush(color)); } } if(x>max_width-w-5){ ((IntField*)e->fieldByID("X"))->setValue(max_width-w-5); x=max_width-w-5; } if(y>max_height-h-5){ ((IntField*)e->fieldByID("Y"))->setValue(max_height-h-5); y=max_height-h-5; } if(x<5){ ((IntField*)e->fieldByID("X"))->setValue(5); x=5; } if(y<5){ ((IntField*)e->fieldByID("Y"))->setValue(5); y=5; } string label = e->getID(); QRect r1(x,y,w,h); QRect r12(x+5,y+5,w-10,h-10); QRect r2(x,y,w,20); if(focus){ QRect rf(x-2,y-2,w+4,h+4); painter.drawRect(rf); } painter.drawRect(r1); painter.drawRect(r2); painter.drawText(r12,label.c_str()); for(int i=work_count; i<e->fieldCount(); i++){ string field = e->fieldAt(i)->getID(); QRect tr(x+5,y+5+(i+1-work_count)*24,w-10,h-10); painter.drawText(tr,field.c_str()); } if(t!=1){ double distance = this->core->getDistanceOf(e); painter.setBrush(QBrush(Qt::black)); painter.drawEllipse(QPoint(x-1,y-1), 2, 2); if(focus){ painter.setBrush(QBrush(colorGreenAlpha)); painter.setPen(pen2); painter.drawEllipse(QPoint(x-1,y-1), (int)qRound(distance), (int)qRound(distance)); } } }