first trial to follow the ball

code_midgen
u-siri-ous 2019-12-04 17:25:25 +01:00
parent db244dd35c
commit 75610d3dde
3 changed files with 14 additions and 6 deletions

View File

@ -13,6 +13,7 @@ class Game{
Game();
void keeper();
void goalie();
void ballBack();
bool role, attackGoal; //1->goalie 0->keeper, 1->yellow 0->blue
//~Game();
};

View File

@ -9,8 +9,11 @@ void Game::goalie(){
//drive->prepareDrive(0, 150, 0);
digitalWrite(LED_G, HIGH);
if(ball->ballSeen){
if(ball->angle >= 0) drive->drive(0, 100, 0);
else if(ball->angle <= 45) drive->drive(45, 100, 0);
if(ball->angle >= 0 && ball->angle <= 45) drive->drive(0, 75, 0);
//else if(ball->angle <= 45) drive->drive(45, 75, 0);
else if(ball->angle > 45 && ball->angle <= 90) drive->drive(90, 75, 0);
//else if(ball->angle <= 135) drive->drive(135, 75, 0);
else if(ball->angle > 90 && ball->angle <= 180) drive->drive(180, 75, 0);
} else {
drive->prepareDrive(0, 0, 0);
drive->drive(0, 0, 0);
@ -24,4 +27,8 @@ void Game::keeper(){
drive->drive(0, 0, 0);
}
void ballBack(){
}

View File

@ -15,12 +15,12 @@ void loop() {
//updateSensors();
/*if(millis() % 100 == 0)
DEBUG_PRINT.println(us->getValue());*/
/* if(game->role) game->goalie();
else game->keeper(); */
game->goalie();
game->role = digitalRead(SWITCH_DX);
game->attackGoal = digitalRead(SWITCH_SX);
if(game->role) game->goalie();
else game->keeper();
//game->goalie();
//drive->drivePrepared();
//compass->test();
//usCtrl->test();
delay(200);
}