Ejemplo n.º 1
0
void loop(){
  /*if(move){*/
    /*if(off_track_count > 700){
      analogWrite(ID_LED_BLUE, 0);
      analogWrite(ID_LED_GREEN, 0);
      analogWrite(ID_LED_RED, 255);
      adjustMotor(0,0);
      Serial.print("TOTAL DISTANCE: "); Serial.println(getTotalDistance());
      for(;;);
    }else{*/
      //detectLine();
      keepDistance();
      #ifdef ASSIGNMENT2
      if (motorDist_l < 0.1){
        startCrossingGap();
      }
      #else
      if (curstate == WAITTOSTART && motorDist_l < 0.1){
        curstate = STRAIGHTAHEAD;
      }
      #endif
      controlState();
#ifdef BOT_SERIAL
      //keepDistance();
#endif
      adjustMotor(motorLine_l*motorDist_l,motorLine_r*motorDist_r);
      //Serial.print("Motor line speed: ("); Serial.print(motorLine_l); Serial.print(", "); Serial.print(motorLine_r); Serial.println(")");
      //Serial.print("Motor dist speed: ("); Serial.print(motorDist_l); Serial.print(", "); Serial.print(motorDist_r); Serial.println(")");
    /*}*/
  /*}
  else
  {
      hearClap();
  }*/
}
Ejemplo n.º 2
0
void loop(){

 
  if(move){
    detectLine();
    keepDistance();
    adjustMotor(min(motorLine_l,motorDist_l),min(motorLine_r,motorDist_r));
  }
  else
  {
      hearClap();
  }
}
Ejemplo n.º 3
0
void loop(){

 
  if(move){
    detectLine();
    keepDistance();
    adjustMotor(min(motorLine_l,motorDist_l),min(motorLine_r,motorDist_r));
    measureDistance();
  }
  else
  {
      detectAlone();
  }
}
Ejemplo n.º 4
0
//The goal is update based on camera setting, doesn't quite work at the moment
//need to revise moveCam
void Camera::update(CameraSetting camSetting){
	switch(camSetting){
		case FREE: {
			if(trackBall) camTarg = minigolfBall->position;	
		}break;
		case TRACK_BALL:{
			keepDistance();
			camTarg = minigolfBall->position;	
		} break;
		case TOP_DOWN: {
			camPos = minigolfBall->position;
			camPos->setY(camPos->getY() + distToKeep);
		} break;
		default: cout << "Cam setting not recognized" << endl; break;
	}
	delete camPos;
	delete camTarg;
}
Ejemplo n.º 5
0
//The goal is update based on camera setting, doesn't quite work at the moment
//need to revise moveCam
void Camera::update(){
	//printf("\nentering update");
	//camPos->print();
	//camTarg->print();
	switch(camSetting){
		case FREE: {
			//test:
			if(counter>0){
				printf("\nbeginning of free:");
				camPos->print();
				camTarg->print();
				counter--;
			}
			if(camCount != 0){ 
				//camPos = minigolfBall->position;
				printf("\nfirst time FREE, pos & targ:");
				camPos->print();
				camTarg->print();	
				printf("\nolds:");
				oldCamPos->print();
				oldCamTarg->print();
				camPos->setPos(oldCamPos->getX(), oldCamPos->getY(), oldCamPos->getZ());
				//camTarg = oldCamTarg;
				printf("\nFREE, after:");
				camPos->print();
				camTarg->print();	
				printf("\nolds:");
				oldCamPos->print();
				oldCamTarg->print();
			}
			if(trackBall) camTarg = minigolfBall->position;	
			if(counter>0){
				printf("\nleaving update, case FREE:");
				camPos->print();
				camTarg->print();
				counter--;
			}
			camCount = 0;
		}break;
		case TRACK_BALL:{
			//testremove:
			keepDistance();
			camTarg = minigolfBall->position;	
			printf("\nleaving update, case track ball");
			camCount = 0;
		} break;
		case TOP_DOWN:{
			if(camCount != 2){ 
				printf("\nfirst time in topdown?");
				camPos->print();
				camTarg->print();	
				printf("\nolds:");
				oldCamPos->print();
				oldCamTarg->print();
				oldCamPos->setPos(camPos->getX(), camPos->getY(), camPos->getZ());
				//oldCamTarg = camTarg;
				//camPos = minigolfBall->position;	
				setCamPos(0, 0, 0);
				camPos->setZ((camPos->getZ()) + distToKeep); 
				printf("\ntopdown pos and trag after:");
				camPos->print();
				camTarg->print();	
				printf("\nolds:");
				oldCamPos->print();
				oldCamTarg->print();
				
			}
			//printf("\nleaving update, case top down");
			camCount = 2;
			counter = 4;
		} break;
		default: cout << "Cam setting not recognized" << endl; break;
	}
	//test:
	//delete camPos;
	//delete camTarg;
}