strange behaviour. started zenhub for this repo.
parent
5a0701f09e
commit
23794ebc2d
|
@ -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:
|
||||
Goalie();
|
||||
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();
|
||||
void goalie();
|
||||
void ballBack(); */
|
||||
//void rigore(); to be implemented
|
||||
|
||||
int atk_direction, atk_speed;
|
||||
};
|
||||
|
|
|
@ -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; */
|
||||
}
|
50
src/main.cpp
50
src/main.cpp
|
@ -1,9 +1,30 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
#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();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue