goalie: use status vector's CURRENT_DATA_READ to get sensors data
So this is in sync with the rest of the data being used in the cycle. This runs a loop cycle behind reality, but we don't care on such a fast machine Also use atk_speed instead of hardcoding it to 100pull/1/head
parent
304610e2e2
commit
bc040bd084
|
@ -22,53 +22,53 @@ void Goalie::init(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Goalie::realPlay(){
|
void Goalie::realPlay(){
|
||||||
if(ball->ballSeen) this->goalie();
|
if(CURRENT_DATA_READ.ballSeen) this->goalie();
|
||||||
else ((PositionSysCamera*)ps)->goCenter();
|
else ((PositionSysCamera*)ps)->goCenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Goalie::goalie() {
|
void Goalie::goalie() {
|
||||||
if(ball->angle>= 350 || ball->angle<= 20) {
|
if(CURRENT_DATA_READ.ballAngle>= 350 || CURRENT_DATA_READ.ballAngle<= 20) {
|
||||||
if(ball->distance > 190) atk_direction = 0;
|
if(CURRENT_DATA_READ.ballDistance > 190) atk_direction = 0;
|
||||||
else atk_direction = ball->angle;
|
else atk_direction = CURRENT_DATA_READ.ballAngle;
|
||||||
atk_speed = GOALIE_ATKSPD_FRT;
|
atk_speed = GOALIE_ATKSPD_FRT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ball->angle>= 90 && ball->angle<= 270) {
|
if(CURRENT_DATA_READ.ballAngle>= 90 && CURRENT_DATA_READ.ballAngle<= 270) {
|
||||||
ballBack();
|
ballBack();
|
||||||
atk_speed = GOALIE_ATKSPD_BAK;
|
atk_speed = GOALIE_ATKSPD_BAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ball->angle> 10 && ball->angle< 30) {
|
if(CURRENT_DATA_READ.ballAngle> 10 && CURRENT_DATA_READ.ballAngle< 30) {
|
||||||
atk_direction = ball->angle+ GOALIE_ATKDIR_PLUSANG1;
|
atk_direction = CURRENT_DATA_READ.ballAngle+ GOALIE_ATKDIR_PLUSANG1;
|
||||||
atk_speed = GOALIE_ATKSPD_LAT;
|
atk_speed = GOALIE_ATKSPD_LAT;
|
||||||
}
|
}
|
||||||
if(ball->angle>= 30 && ball->angle< 45) {
|
if(CURRENT_DATA_READ.ballAngle>= 30 && CURRENT_DATA_READ.ballAngle< 45) {
|
||||||
atk_direction = ball->angle+ GOALIE_ATKDIR_PLUSANG2;
|
atk_direction = CURRENT_DATA_READ.ballAngle+ GOALIE_ATKDIR_PLUSANG2;
|
||||||
atk_speed = GOALIE_ATKSPD_LAT;
|
atk_speed = GOALIE_ATKSPD_LAT;
|
||||||
}
|
}
|
||||||
if(ball->angle>= 45 && ball->angle< 90) {
|
if(CURRENT_DATA_READ.ballAngle>= 45 && CURRENT_DATA_READ.ballAngle< 90) {
|
||||||
atk_direction = ball->angle+ GOALIE_ATKDIR_PLUSANG3;
|
atk_direction = CURRENT_DATA_READ.ballAngle+ GOALIE_ATKDIR_PLUSANG3;
|
||||||
atk_speed = GOALIE_ATKSPD_LAT;
|
atk_speed = GOALIE_ATKSPD_LAT;
|
||||||
}
|
}
|
||||||
if(ball->angle> 270 && ball->angle<= 315) {
|
if(CURRENT_DATA_READ.ballAngle> 270 && CURRENT_DATA_READ.ballAngle<= 315) {
|
||||||
atk_direction = ball->angle- GOALIE_ATKDIR_PLUSANG3_COR;
|
atk_direction = CURRENT_DATA_READ.ballAngle- GOALIE_ATKDIR_PLUSANG3_COR;
|
||||||
atk_speed = GOALIE_ATKSPD_LAT;
|
atk_speed = GOALIE_ATKSPD_LAT;
|
||||||
}
|
}
|
||||||
if(ball->angle> 315 && ball->angle<= 330) {
|
if(CURRENT_DATA_READ.ballAngle> 315 && CURRENT_DATA_READ.ballAngle<= 330) {
|
||||||
atk_direction = ball->angle- GOALIE_ATKDIR_PLUSANG2_COR;
|
atk_direction = CURRENT_DATA_READ.ballAngle- GOALIE_ATKDIR_PLUSANG2_COR;
|
||||||
atk_speed = GOALIE_ATKSPD_LAT;
|
atk_speed = GOALIE_ATKSPD_LAT;
|
||||||
}
|
}
|
||||||
if(ball->angle> 330 && ball->angle< 350) {
|
if(CURRENT_DATA_READ.ballAngle> 330 && CURRENT_DATA_READ.ballAngle< 350) {
|
||||||
atk_direction = ball->angle- GOALIE_ATKDIR_PLUSANG1_COR;
|
atk_direction = CURRENT_DATA_READ.ballAngle- GOALIE_ATKDIR_PLUSANG1_COR;
|
||||||
atk_speed = GOALIE_ATKSPD_LAT;
|
atk_speed = GOALIE_ATKSPD_LAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if((ball->angle>= 330 || ball->angle<= 30) && ball->distance > 190) { //storcimento
|
// if((CURRENT_DATA_READ.ballAngle>= 330 || CURRENT_DATA_READ.ballAngle<= 30) && CURRENT_DATA_READ.ballDistance > 190) { //storcimento
|
||||||
// atk_speed = GOALIE_ATKSPD_STRK; //dove i gigahertz hanno fallito
|
// atk_speed = GOALIE_ATKSPD_STRK; //dove i gigahertz hanno fallito
|
||||||
// drive->prepareDrive(atk_direction, atk_speed, cstorc);
|
// drive->prepareDrive(atk_direction, atk_speed, cstorc);
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
drive->prepareDrive(atk_direction, 100);
|
drive->prepareDrive(atk_direction, atk_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,13 +78,13 @@ void Goalie::ballBack() {
|
||||||
int dir;
|
int dir;
|
||||||
|
|
||||||
int plusang;
|
int plusang;
|
||||||
if(ball->distance > 130) plusang = GOALIE_ATKDIR_PLUSANGBAK;
|
if(CURRENT_DATA_READ.ballDistance > 130) plusang = GOALIE_ATKDIR_PLUSANGBAK;
|
||||||
else plusang = 0;
|
else plusang = 0;
|
||||||
|
|
||||||
if(ball->angle> 180) ball_degrees2 = ball->angle- 360;
|
if(CURRENT_DATA_READ.ballAngle> 180) ball_degrees2 = CURRENT_DATA_READ.ballAngle- 360;
|
||||||
else ball_degrees2 = ball->angle;
|
else ball_degrees2 = CURRENT_DATA_READ.ballAngle;
|
||||||
if(ball_degrees2 > 0) dir = ball->angle+ plusang; //45 con 8 ruote
|
if(ball_degrees2 > 0) dir = CURRENT_DATA_READ.ballAngle+ plusang; //45 con 8 ruote
|
||||||
else dir = ball->angle- plusang; //45 con 8 ruote
|
else dir = CURRENT_DATA_READ.ballAngle- plusang; //45 con 8 ruote
|
||||||
if(dir < 0) dir = dir + 360;
|
if(dir < 0) dir = dir + 360;
|
||||||
else dir = dir;
|
else dir = dir;
|
||||||
atk_direction = dir;
|
atk_direction = dir;
|
||||||
|
|
Loading…
Reference in New Issue