new goalie c:

code_midgen
u-siri-ous 2020-01-22 18:51:30 +01:00
parent 13134cac99
commit 05399d8557
5 changed files with 27 additions and 22 deletions

View File

@ -10,5 +10,5 @@ class DataSourceBall : public DataSource{
int angle, distance;
bool ballSeen;
int plusang, dir, degrees2,b;
int dir, degrees2,b;
};

View File

@ -25,7 +25,7 @@ class Goalie : public Game{
private:
void realPlay() override;
void init() override;
void goalie();
void goalie(int);
void ballBack();
void storcimentoPorta();

View File

@ -15,7 +15,7 @@ void DataSourceCamera :: readSensor(){
end=true;
start=false;
data_received=false;
if(count==3 && start==true) {
if(count=4 && start==true) {
data_received=true;
true_xb = xb;
true_yb = yb;
@ -25,8 +25,8 @@ void DataSourceCamera :: readSensor(){
}else{
if(start==true){
if (count==0) xb=value;
else if (count==1) xy=value;
else if (count==2) yb=value;
else if (count==1) yb=value;
else if (count==2) xy=value;
else if (count==3) yy=value;
count++;
}

View File

@ -17,22 +17,25 @@ void Goalie::init(){
}
void Goalie::realPlay(){
if(ball->ballSeen) this->goalie();
if(ball->ballSeen) this->goalie(50);
else drive->prepareDrive(0,0,0);
}
void Goalie::goalie() {
if(ball->angle > 340 || ball->angle < 20) ball->plusang -= 20;
void Goalie::goalie(int plusang) {
if(ball->distance < 185) drive->prepareDrive(ball->angle, 350, 0);
else{
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
else 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 - plusang; //45 con 8 ruote
if(ball->dir < 0) ball->dir = ball->dir + 360;
else ball->dir = ball->dir;
ball->b = ball->dir;
drive->prepareDrive(ball->dir, 300, 0);
}
/* drive->speed = 300;
drive->dir = drive->dir; */
/* if(ball->angle >= 350 || ball->angle <= 10) {
@ -87,7 +90,7 @@ void Goalie::storcimentoPorta() {
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;
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
if(ball->dir < 0) ball->dir = ball->dir + 360;
else ball->dir = ball->dir;
atk_direction = ball->dir;
atk_direction = ball->dir; */
}

View File

@ -16,11 +16,13 @@ void setup() {
void loop() {
updateSensors();
camera->test();
/*
//camera->test();
goalie->play(role==1);
keeper->play(role==0); */
keeper->play(role==0);
ball->test();
// Last thing to do: movement
/* drive->drivePrepared(); */
drive->drivePrepared();
}