image.png

image.png

// 원본코드

void printResult(HUSKYLENSResult result){
    if (result.command == COMMAND_RETURN_BLOCK){
      Serial.println(String()+F("Block:xCenter=")+result.xCenter+F(",yCenter=")+result.yCenter+F(",width=")+result.width+F(",height=")+result.height+F(",ID=")+result.ID);
      
      if(result.xCenter > 180) {
        if(cmdM == 'x'){
          cmd = 'a';
          Serial.println(String() + cmd + F("  Backward right"));   
        } else {
          cmd = 'd';
          Serial.println(String() + cmd + F("  right"));   
        }  
      }
      if(result.xCenter < 140) {
        if(cmdM == 'x'){
          cmd = 'd';
          Serial.println(String() + cmd + F("  left"));   
        } else {
          cmd = 'a';
          Serial.println(String() + cmd + F("  Backward left"));   
        }
      }
       if(result.xCenter <= 180 && result.xCenter >=140) {
        cmd = 's';
        Serial.println(String() + cmd + F("  left"));   
      }
      if(result.width < 60 && result.height < 60) {
        cmd = 'w';
        cmdM = 'w';
        Serial.println(String() + cmd + F("  forward"));      
      } 
      if(result.width > 90 && result.height > 90) {
        cmd = 'x';
        cmdM = 'x';
        Serial.println(String() + cmd + F("  backward"));  
      }
    }
//vk 주석, 모니터링 코드 추가

void printResult(HUSKYLENSResult result){

    //vk 허스키렌즈 블록 정보
    if (result.command == COMMAND_RETURN_BLOCK){

      Serial.print(String()+F("\\n Block \\t xCenter: ")+result.xCenter+F("\\t yCenter: ")+result.yCenter+F("\\t width: ")+result.width+F("\\t height: ")+result.height+F("\\t ID: ")+result.ID);
   
      if(result.xCenter > 180) {//vk default:180 x축 중앙(160) 오른쪽. 실주행하며 수정필요.
        if(cmdM == 'x'){  //vk 이전cmd: 후진
          cmd = 'a';
          Serial.print(String() +"\\t\\t Set cmd: "+ cmd + F("\\t B_LeftTurn"));   //vk Backward Right -> B_LeftTurn. 후진 좌회전 (스티어링휠 반시계 회전)
        } else {
          cmd = 'd';
          Serial.print(String() +"\\t\\t Set cmd: "+ cmd + F("\\t RightTurn"));    //vk Right->RightTurn. 전진 우회전
        }  
      }

      if(result.xCenter < 140) { //vk default:140 x축 중앙(160) 왼쪽. 실주행하며 수정필요.
        if(cmdM == 'x'){ //vk cmdM: 후진
          cmd = 'd';
          Serial.print(String() +"\\t\\t Set cmd: "+ cmd + F("\\t B_RightTurn"));   //vk left->B_RightTurn. 후진 우회전
        } else {
          cmd = 'a';
          Serial.print(String() +"\\t\\t Set cmd: "+ cmd + F("\\t LeftTurn"));   //vk BL->leftTurn 전진 좌회전
        }
      }

       if(result.xCenter >= 140 && result.xCenter <=180) { //vk default(140,180) x축 중앙(160) 부근
        cmd = 'w'; // vk s->w. 정지에서 직진으로 수정
        Serial.print(String() +"\\t\\t Set cmd: "+ cmd + F("\\t Forward")); //vk left->stop->Forward 
      }

      if(result.width < 40) {   //vk default(W60, H60) 블록 크기가 설정값보다 작아졌을 때 전진 result.height값 삭제. 실주행하며 수정필요.
        cmd = 'w';
        cmdM = 'w';
        Serial.print(String() +"\\t\\t Set cmd: "+ cmd + F("\\t Forward"));      
      } 
      if(result.width > 80) {    //vk default(W90,H90) 블록 크기가 설정값보다 커졌을 때 후진. result.height값 삭제. 실주행하며 수정필요.
        cmd = 'x';
        cmdM = 'x';
        Serial.print(String() +"\\t\\t Set cmd: "+ cmd + F("\\t Backward"));  
      }
    }