wallthrestategen.ic

void Wallthrestategenerico(){

  
  int pid1;
  
  // Espera precionar start antes de comecar
  sleep(0.5);
  printf ("\nSeguir Parede");
  while(!start_button());
  sleep(0.5);
  
  pid1 = start_process(WallFollow3());
  
  while(!stop_button());
  kill_process(pid1);
  ao();    

}

void WallFollow3(){

  
  int sensor;
  int estado = ESQ;
  
  
  LEFT_POWER = 30;
  RIGHT_POWER = 30;
  
  // Define o estado inicial
  VirarEsq();
  estado = ESQ;
  
  while (1){
      
      sensor = analog(SENSOR);
      
      if (sensor < perto){
          VirarDir();
      }
      else{
          if (sensor < longe){
              motor (LEFT_MOTOR, (int)((float)LEFT_POWER*(1.0-(float)(sensor-perto)/255.0)));
              motor (RIGHT_MOTOR, (int)((float)RIGHT_POWER*(1.0+(float)(sensor-perto)/255.0)));
          }
          else{
              VirarEsq();
          }
      }
      
      
  }

}

cursos/introrobotica/2007-2/grupo2/wallthrestategen.ic.txt · Última modificação: 2007/11/08 15:54 (edição externa)