first trial to follow the ball
parent
db244dd35c
commit
75610d3dde
|
@ -13,6 +13,7 @@ class Game{
|
||||||
Game();
|
Game();
|
||||||
void keeper();
|
void keeper();
|
||||||
void goalie();
|
void goalie();
|
||||||
|
void ballBack();
|
||||||
bool role, attackGoal; //1->goalie 0->keeper, 1->yellow 0->blue
|
bool role, attackGoal; //1->goalie 0->keeper, 1->yellow 0->blue
|
||||||
//~Game();
|
//~Game();
|
||||||
};
|
};
|
11
src/game.cpp
11
src/game.cpp
|
@ -9,8 +9,11 @@ void Game::goalie(){
|
||||||
//drive->prepareDrive(0, 150, 0);
|
//drive->prepareDrive(0, 150, 0);
|
||||||
digitalWrite(LED_G, HIGH);
|
digitalWrite(LED_G, HIGH);
|
||||||
if(ball->ballSeen){
|
if(ball->ballSeen){
|
||||||
if(ball->angle >= 0) drive->drive(0, 100, 0);
|
if(ball->angle >= 0 && ball->angle <= 45) drive->drive(0, 75, 0);
|
||||||
else if(ball->angle <= 45) drive->drive(45, 100, 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 {
|
} else {
|
||||||
drive->prepareDrive(0, 0, 0);
|
drive->prepareDrive(0, 0, 0);
|
||||||
drive->drive(0, 0, 0);
|
drive->drive(0, 0, 0);
|
||||||
|
@ -24,4 +27,8 @@ void Game::keeper(){
|
||||||
drive->drive(0, 0, 0);
|
drive->drive(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ballBack(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,12 @@ void loop() {
|
||||||
//updateSensors();
|
//updateSensors();
|
||||||
/*if(millis() % 100 == 0)
|
/*if(millis() % 100 == 0)
|
||||||
DEBUG_PRINT.println(us->getValue());*/
|
DEBUG_PRINT.println(us->getValue());*/
|
||||||
/* if(game->role) game->goalie();
|
|
||||||
else game->keeper(); */
|
|
||||||
game->goalie();
|
|
||||||
game->role = digitalRead(SWITCH_DX);
|
game->role = digitalRead(SWITCH_DX);
|
||||||
game->attackGoal = digitalRead(SWITCH_SX);
|
game->attackGoal = digitalRead(SWITCH_SX);
|
||||||
|
if(game->role) game->goalie();
|
||||||
|
else game->keeper();
|
||||||
|
//game->goalie();
|
||||||
|
//drive->drivePrepared();
|
||||||
//compass->test();
|
//compass->test();
|
||||||
//usCtrl->test();
|
//usCtrl->test();
|
||||||
delay(200);
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue