From 23794ebc2d5c60744be5e7d635c7d6e75b28281e Mon Sep 17 00:00:00 2001 From: u-siri-ous Date: Thu, 5 Dec 2019 13:31:21 +0100 Subject: [PATCH] strange behaviour. started zenhub for this repo. --- include/goalie.h | 20 +++-------- src/goalie.cpp | 91 ++++++------------------------------------------ src/main.cpp | 50 +++++++++++++------------- 3 files changed, 39 insertions(+), 122 deletions(-) diff --git a/include/goalie.h b/include/goalie.h index a5044a5..fba8d97 100644 --- a/include/goalie.h +++ b/include/goalie.h @@ -2,7 +2,7 @@ #include "game.h" -#define GOALIE_ATKSPD_LAT 255 +/* #define GOALIE_ATKSPD_LAT 255 #define GOALIE_ATKSPD_BAK 350 #define GOALIE_ATKSPD_FRT 345 #define GOALIE_ATKSPD_STRK 355 @@ -12,24 +12,14 @@ #define GOALIE_ATKDIR_PLUSANGBAK 40 #define GOALIE_ATKDIR_PLUSANG1_COR 60 #define GOALIE_ATKDIR_PLUSANG2_COR 70 -#define GOALIE_ATKDIR_PLUSANG3_COR 70 +#define GOALIE_ATKDIR_PLUSANG3_COR 70 */ class Goalie{ public: - void goalie(); - void palla_dietro(); - void palla_dietroP(); - void storcimentoPorta(); - void storcimentoPorta2(); - void storcimentoZone(); - void storcimentoPortaIncr(); - void leaveMeAlone(); - void ballBack(); - int atk_direction, atk_speed; - /* Goalie(); + Goalie(); void goalie(); - void ballBack(); */ + void ballBack(); //void rigore(); to be implemented - + int atk_direction, atk_speed; }; diff --git a/src/goalie.cpp b/src/goalie.cpp index d86e499..81dee90 100644 --- a/src/goalie.cpp +++ b/src/goalie.cpp @@ -1,93 +1,22 @@ #include "goalie.h" -/* Goalie::Goalie(){ - digitalWrite(LED_Y, LOW); -} */ +Goalie::Goalie(){ } -/* void Goalie::goalie(){ - digitalWrite(LED_Y, LOW); - if(ball->angle >= 350 || ball->angle <= 10) { - if(ball->distance > 190) atk_direction = 0; - else atk_direction = ball->angle; - atk_speed = GOALIE_ATKSPD_FRT; - } - - if(ball->angle >= 90 && ball->angle <= 270) { - ballBack(); - atk_speed = GOALIE_ATKSPD_BAK; - } - if(digitalRead(SWITCH_DX) == 1) { - if(ball->angle > 10 && ball->angle < 30) { - atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG1; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle >= 30 && ball->angle < 45) { - atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG2; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle >= 45 && ball->angle < 90) { - atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG3; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle > 270 && ball->angle <= 315) { - atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG3_COR; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle > 315 && ball->angle <= 330) { - atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG2_COR; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle > 330 && ball->angle < 350) { - atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG1_COR; - atk_speed = GOALIE_ATKSPD_LAT; - } - } else { - if(ball->angle > 10 && ball->angle < 30) { - atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG1_COR; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle >= 30 && ball->angle < 45) { - atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG2_COR; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle >= 45 && ball->angle < 90) { - atk_direction = ball->angle + GOALIE_ATKDIR_PLUSANG3_COR; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle > 270 && ball->angle <= 315) { - atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG3; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle > 315 && ball->angle <= 330) { - atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG2; - atk_speed = GOALIE_ATKSPD_LAT; - } - if(ball->angle > 330 && ball->angle < 350) { - atk_direction = ball->angle - GOALIE_ATKDIR_PLUSANG1; - atk_speed = GOALIE_ATKSPD_LAT; - } - } - - if((ball->angle >= 330 || ball->angle <= 30) && ball->distance > 190) { //storcimento - atk_speed = GOALIE_ATKSPD_STRK; //dove i gigahertz hanno fallito - drive->prepareDrive(atk_direction, atk_speed, 0); - } - else drive->prepareDrive(atk_direction, atk_speed, 0); - - - /* siria digitalWrite(LED_G, HIGH); +void Goalie::goalie(){ + digitalWrite(LED_G, HIGH); if(ball->ballSeen){ - if(ball->angle >= 0 && ball->angle < 45) drive->drive(ball->angle, 75, 0); - else if(ball->angle >= 45 && ball->angle <= 60) drive->drive(ball->angle, 75, 0); + if(ball->angle >= 0 && ball->angle < 45) drive->drive(0, 75, 0); + /* else if(ball->angle >= 45 && ball->angle <= 60) drive->drive(ball->angle, 75, 0); else if(ball->angle > 60 && ball->angle < 90) drive->drive(ball->angle, 75, 0); - else if(ball->angle >= 90 && ball->angle < 135) drive->drive(ball->angle, 75, 0); + else if(ball->angle >= 90 && ball->angle < 135) drive->drive(ball->angle, 75, 0); */ } else { drive->prepareDrive(0, 0, 0); drive->drive(0, 0, 0); - } */ + } +} void Goalie::ballBack(){ - int ballangle2; +/* old int ballangle2; int dir; int plusang; @@ -100,5 +29,5 @@ void Goalie::ballBack(){ else dir = ball->angle - plusang; //45 con 8 ruote if(dir < 0) dir = dir + 360; else dir = dir; - atk_direction = dir; + atk_direction = dir; */ } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 6e13ba8..4e9e63f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,30 @@ #include #include "game.h" -#include "goalie.h" -class Trial{ +void setup() { + delay(500); + + DEBUG.begin(9600); + initSensors(); + delay(2000); +} + + +void loop() { + updateSensors(); + /* Trial trial; + trial.trial(); */ + //drive->prepareDrive(0,0,0); + linesCtrl->update(); + goalie->goalie(); + //drive->drivePrepared(); + +} + + +/*old function trial + class Trial{ public: void trial(){ digitalWrite(LED_Y, LOW); @@ -76,28 +97,5 @@ class Trial{ else drive->prepareDrive(goalie->atk_direction, goalie->atk_speed, 0); } -}; +}; */ - -void setup() { - delay(500); - - DEBUG.begin(9600); - initSensors(); - delay(2000); -} - - -void loop() { - updateSensors(); - Trial trial; - trial.trial(); - //drive->prepareDrive(0,0,0); - //linesCtrl->update(); - - - //drive->prepareDrive(0,0,0); - linesCtrl->update(); - drive->drivePrepared(); - -}