camera fixing and new goalie(to test)
parent
3f6835ac94
commit
13134cac99
|
@ -10,4 +10,5 @@ class DataSourceBall : public DataSource{
|
|||
|
||||
int angle, distance;
|
||||
bool ballSeen;
|
||||
int plusang, dir, degrees2,b;
|
||||
};
|
|
@ -21,7 +21,7 @@ class DataSourceCamera : public DataSource{
|
|||
|
||||
int goalOrientation, pAtk, pDef, imuOff, portx, valX, valY, valB, oldGoalX, oldGoalY, oldGoalB;
|
||||
int cameraReady;
|
||||
char value;
|
||||
int value;
|
||||
int startpY = 0;
|
||||
int startpB = 0;
|
||||
int endpY = 0;
|
||||
|
|
|
@ -5,7 +5,8 @@ DataSourceCamera::DataSourceCamera(HardwareSerial* ser_, int baud) : DataSource(
|
|||
|
||||
void DataSourceCamera :: readSensor(){
|
||||
while(ser->available() > 0){
|
||||
value = (byte)ser->read();
|
||||
value = (int)ser->read();
|
||||
//Serial.println(value);
|
||||
if(value==startp){
|
||||
start=true;
|
||||
count=0;
|
||||
|
@ -14,14 +15,15 @@ void DataSourceCamera :: readSensor(){
|
|||
end=true;
|
||||
start=false;
|
||||
data_received=false;
|
||||
if(count==3) {
|
||||
if(count==3 && start==true) {
|
||||
data_received=true;
|
||||
xb=true_xb;
|
||||
yb=true_yb;
|
||||
xy=true_xy;
|
||||
yy=true_yy;
|
||||
true_xb = xb;
|
||||
true_yb = yb;
|
||||
true_xy = xy;
|
||||
true_yy = yy;
|
||||
}
|
||||
}else{
|
||||
if(start==true){
|
||||
if (count==0) xb=value;
|
||||
else if (count==1) xy=value;
|
||||
else if (count==2) yb=value;
|
||||
|
@ -30,6 +32,7 @@ void DataSourceCamera :: readSensor(){
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -173,7 +176,7 @@ int DataSourceCamera::getValueDef(bool fixed){
|
|||
|
||||
void DataSourceCamera::test(){
|
||||
goalOrientation = digitalRead(SWITCH_SX); //se HIGH attacco gialla, difendo blu
|
||||
|
||||
update();
|
||||
/* DEBUG.print(pAtk);
|
||||
DEBUG.print(" | ");
|
||||
DEBUG.print(fixCamIMU(pAtk));
|
||||
|
@ -182,28 +185,24 @@ void DataSourceCamera::test(){
|
|||
DEBUG.print(pDef);
|
||||
DEBUG.print(" | ");
|
||||
DEBUG.println(fixCamIMU(pDef)); */
|
||||
update();
|
||||
//update();
|
||||
DEBUG.print(xb);
|
||||
DEBUG.print("|");
|
||||
delay(100);
|
||||
DEBUG.print(yb);
|
||||
DEBUG.print("|");
|
||||
delay(100);
|
||||
DEBUG.print(xy);
|
||||
DEBUG.print("|");
|
||||
delay(100);
|
||||
DEBUG.print(yy);
|
||||
DEBUG.println("---------------");
|
||||
DEBUG.print(true_xb);
|
||||
DEBUG.print("|");
|
||||
delay(100);
|
||||
DEBUG.print(true_yb);
|
||||
DEBUG.print("|");
|
||||
delay(100);
|
||||
DEBUG.print(true_xy);
|
||||
DEBUG.print("|");
|
||||
delay(100);
|
||||
DEBUG.print(true_yy);
|
||||
DEBUG.println("---------------");
|
||||
delay(75);
|
||||
}
|
||||
|
||||
int DataSourceCamera::fixCamIMU(int d){
|
||||
|
|
|
@ -22,7 +22,20 @@ void Goalie::realPlay(){
|
|||
}
|
||||
|
||||
void Goalie::goalie() {
|
||||
if(ball->angle >= 350 || ball->angle <= 10) {
|
||||
if(ball->angle > 340 || ball->angle < 20) ball->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->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) {
|
||||
if(ball->distance > 190) atk_direction = 0;
|
||||
else atk_direction = ball->angle;
|
||||
atk_speed = GOALIE_ATKSPD_FRT;
|
||||
|
@ -62,7 +75,7 @@ void Goalie::goalie() {
|
|||
atk_speed = GOALIE_ATKSPD_STRK; //dove i gigahertz hanno fallito
|
||||
drive->prepareDrive(atk_direction, atk_speed, cstorc);
|
||||
}
|
||||
else drive->prepareDrive(atk_direction, atk_speed);
|
||||
else drive->prepareDrive(atk_direction, atk_speed); */
|
||||
}
|
||||
|
||||
void Goalie::storcimentoPorta() {
|
||||
|
@ -73,18 +86,15 @@ void Goalie::storcimentoPorta() {
|
|||
}
|
||||
|
||||
void Goalie::ballBack() {
|
||||
int degrees2;
|
||||
int dir;
|
||||
|
||||
int plusang;
|
||||
if(ball->distance > 130) plusang = GOALIE_ATKDIR_PLUSANGBAK;
|
||||
else plusang = 0;
|
||||
if(ball->distance > 130) ball->plusang = GOALIE_ATKDIR_PLUSANGBAK;
|
||||
else ball->plusang = 0;
|
||||
|
||||
if(ball->angle > 180) degrees2 = ball->angle - 360;
|
||||
else degrees2 = ball->angle;
|
||||
if(degrees2 > 0) dir = ball->angle + plusang; //45 con 8 ruote
|
||||
else dir = ball->angle - plusang; //45 con 8 ruote
|
||||
if(dir < 0) dir = dir + 360;
|
||||
else dir = dir;
|
||||
atk_direction = dir;
|
||||
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->dir < 0) ball->dir = ball->dir + 360;
|
||||
else ball->dir = ball->dir;
|
||||
atk_direction = ball->dir;
|
||||
}
|
Loading…
Reference in New Issue