even better pass and shoot

pull/1/head
EmaMaker 2021-05-14 10:42:33 +02:00
parent fa005584d9
commit 297502ea70
2 changed files with 20 additions and 9 deletions

View File

@ -11,10 +11,10 @@
//Camera goal: those setpoints correspond to the position of the center of the goal on the field //Camera goal: those setpoints correspond to the position of the center of the goal on the field
#define CAMERA_GOAL_X 0 #define CAMERA_GOAL_X 0
#define CAMERA_GOAL_Y -14 #define CAMERA_GOAL_Y -12
#define CAMERA_GOAL_MIN_X -16 #define CAMERA_GOAL_MIN_X -8
#define CAMERA_GOAL_MAX_X 16 #define CAMERA_GOAL_MAX_X 8
#define CAMERA_CENTER_Y_ABS_SUM 60 #define CAMERA_CENTER_Y_ABS_SUM 60
//Actually it's ± MAX_VAL //Actually it's ± MAX_VAL

View File

@ -29,20 +29,31 @@ void PassAndShoot::init()
pass_counter = millis(); pass_counter = millis();
} }
unsigned long pass_timer = 0;
boolean flag = false;
void PassAndShoot::realPlay() void PassAndShoot::realPlay()
{ {
if (CURRENT_DATA_READ.ballSeen){ if (CURRENT_DATA_READ.ballSeen){
if(robot_indentifier == HIGH){ if(robot_indentifier == HIGH){
if(millis() - pass_counter <= 1500) { if(ball->isInFront() && CURRENT_DATA_READ.ballDistance <= 90){
striker(); if(!flag){
}else{ pass_timer = millis();
flag = true;
//Show on 32u4
Serial2.write(0b00000100);
}
}
if(!flag || (millis() - pass_timer <= 650)){
striker();
}else{
((PositionSysCamera*)ps)->setMoveSetpoints(CAMERA_GOAL_MIN_X, CAMERA_GOAL_Y); ((PositionSysCamera*)ps)->setMoveSetpoints(CAMERA_GOAL_MIN_X, CAMERA_GOAL_Y);
bt->tosend = 'C'; bt->tosend = 'C';
} roller->speed(0);
}
}else{ }else{
if(bt->received == 'C'){ if(bt->received == 'C'){
// //Show on 32u4
Serial2.write(0b00000100);
striker(); striker();
}else drive->prepareDrive(0,0,0); }else drive->prepareDrive(0,0,0);
} }