new goalie c:
parent
13134cac99
commit
05399d8557
|
@ -10,5 +10,5 @@ class DataSourceBall : public DataSource{
|
||||||
|
|
||||||
int angle, distance;
|
int angle, distance;
|
||||||
bool ballSeen;
|
bool ballSeen;
|
||||||
int plusang, dir, degrees2,b;
|
int dir, degrees2,b;
|
||||||
};
|
};
|
|
@ -25,7 +25,7 @@ class Goalie : public Game{
|
||||||
private:
|
private:
|
||||||
void realPlay() override;
|
void realPlay() override;
|
||||||
void init() override;
|
void init() override;
|
||||||
void goalie();
|
void goalie(int);
|
||||||
void ballBack();
|
void ballBack();
|
||||||
void storcimentoPorta();
|
void storcimentoPorta();
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ void DataSourceCamera :: readSensor(){
|
||||||
end=true;
|
end=true;
|
||||||
start=false;
|
start=false;
|
||||||
data_received=false;
|
data_received=false;
|
||||||
if(count==3 && start==true) {
|
if(count=4 && start==true) {
|
||||||
data_received=true;
|
data_received=true;
|
||||||
true_xb = xb;
|
true_xb = xb;
|
||||||
true_yb = yb;
|
true_yb = yb;
|
||||||
|
@ -25,8 +25,8 @@ void DataSourceCamera :: readSensor(){
|
||||||
}else{
|
}else{
|
||||||
if(start==true){
|
if(start==true){
|
||||||
if (count==0) xb=value;
|
if (count==0) xb=value;
|
||||||
else if (count==1) xy=value;
|
else if (count==1) yb=value;
|
||||||
else if (count==2) yb=value;
|
else if (count==2) xy=value;
|
||||||
else if (count==3) yy=value;
|
else if (count==3) yy=value;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,22 +17,25 @@ void Goalie::init(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Goalie::realPlay(){
|
void Goalie::realPlay(){
|
||||||
if(ball->ballSeen) this->goalie();
|
if(ball->ballSeen) this->goalie(50);
|
||||||
else drive->prepareDrive(0,0,0);
|
else drive->prepareDrive(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Goalie::goalie() {
|
void Goalie::goalie(int plusang) {
|
||||||
if(ball->angle > 340 || ball->angle < 20) ball->plusang -= 20;
|
if(ball->distance < 185) drive->prepareDrive(ball->angle, 350, 0);
|
||||||
if(ball->angle > 180) ball->degrees2 = ball->angle - 360;
|
else{
|
||||||
else ball->degrees2 = ball->angle;
|
if(ball->angle > 340 || ball->angle < 20) plusang -= 20;
|
||||||
|
if(ball->angle > 180) ball->degrees2 = ball->angle - 360;
|
||||||
|
else ball->degrees2 = ball->angle;
|
||||||
|
|
||||||
if(ball->degrees2 > 0) ball->dir = ball->angle + ball->plusang; //45 con 8 ruote
|
if(ball->degrees2 > 0) ball->dir = ball->angle + plusang; //45 con 8 ruote
|
||||||
else ball->dir = ball->angle - ball->plusang; //45 con 8 ruote
|
else ball->dir = ball->angle - plusang; //45 con 8 ruote
|
||||||
|
|
||||||
if(ball->dir < 0) ball->dir = ball->dir + 360;
|
if(ball->dir < 0) ball->dir = ball->dir + 360;
|
||||||
else ball->dir = ball->dir;
|
else ball->dir = ball->dir;
|
||||||
ball->b = ball->dir;
|
ball->b = ball->dir;
|
||||||
drive->prepareDrive(ball->dir, 300, 0);
|
drive->prepareDrive(ball->dir, 300, 0);
|
||||||
|
}
|
||||||
/* drive->speed = 300;
|
/* drive->speed = 300;
|
||||||
drive->dir = drive->dir; */
|
drive->dir = drive->dir; */
|
||||||
/* if(ball->angle >= 350 || ball->angle <= 10) {
|
/* if(ball->angle >= 350 || ball->angle <= 10) {
|
||||||
|
@ -87,7 +90,7 @@ void Goalie::storcimentoPorta() {
|
||||||
|
|
||||||
void Goalie::ballBack() {
|
void Goalie::ballBack() {
|
||||||
|
|
||||||
if(ball->distance > 130) ball->plusang = GOALIE_ATKDIR_PLUSANGBAK;
|
/* if(ball->distance > 130) ball->plusang = GOALIE_ATKDIR_PLUSANGBAK;
|
||||||
else ball->plusang = 0;
|
else ball->plusang = 0;
|
||||||
|
|
||||||
if(ball->angle > 180) ball->degrees2 = ball->angle - 360;
|
if(ball->angle > 180) ball->degrees2 = ball->angle - 360;
|
||||||
|
@ -96,5 +99,5 @@ void Goalie::ballBack() {
|
||||||
else ball->dir = ball->angle - ball->plusang; //45 con 8 ruote
|
else ball->dir = ball->angle - ball->plusang; //45 con 8 ruote
|
||||||
if(ball->dir < 0) ball->dir = ball->dir + 360;
|
if(ball->dir < 0) ball->dir = ball->dir + 360;
|
||||||
else ball->dir = ball->dir;
|
else ball->dir = ball->dir;
|
||||||
atk_direction = ball->dir;
|
atk_direction = ball->dir; */
|
||||||
}
|
}
|
10
src/main.cpp
10
src/main.cpp
|
@ -16,11 +16,13 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
updateSensors();
|
updateSensors();
|
||||||
camera->test();
|
//camera->test();
|
||||||
/*
|
|
||||||
goalie->play(role==1);
|
goalie->play(role==1);
|
||||||
keeper->play(role==0); */
|
keeper->play(role==0);
|
||||||
|
|
||||||
|
ball->test();
|
||||||
|
|
||||||
|
|
||||||
// Last thing to do: movement
|
// Last thing to do: movement
|
||||||
/* drive->drivePrepared(); */
|
drive->drivePrepared();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue