parent
f3eed47a67
commit
f11127bb40
|
@ -15,6 +15,7 @@ class DataSourceBall : public DataSource{
|
||||||
void test() override;
|
void test() override;
|
||||||
bool isInMouth();
|
bool isInMouth();
|
||||||
bool isInMouthMaxDistance();
|
bool isInMouthMaxDistance();
|
||||||
|
bool isInFront();
|
||||||
|
|
||||||
int angle, distance, angleFix;
|
int angle, distance, angleFix;
|
||||||
bool ballSeen;
|
bool ballSeen;
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -29,17 +29,20 @@ void setup() {
|
||||||
testmenu = new TestMenu();
|
testmenu = new TestMenu();
|
||||||
tone(BUZZER, 240, 250);
|
tone(BUZZER, 240, 250);
|
||||||
initStatusVector();
|
initStatusVector();
|
||||||
|
delay(100);
|
||||||
|
|
||||||
tone(BUZZER, 260, 250);
|
tone(BUZZER, 260, 250);
|
||||||
initSensors();
|
initSensors();
|
||||||
|
delay(500);
|
||||||
|
|
||||||
tone(BUZZER, 320, 250);
|
tone(BUZZER, 320, 250);
|
||||||
initGames();
|
initGames();
|
||||||
|
delay(200);
|
||||||
delay(500);
|
|
||||||
|
|
||||||
drive->prepareDrive(0,0,0);
|
|
||||||
|
|
||||||
//Startup sound
|
//Startup sound
|
||||||
tone(BUZZER, 350.00, 250);
|
tone(BUZZER, 350.00, 250);
|
||||||
|
|
||||||
|
drive->prepareDrive(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
|
@ -40,10 +40,14 @@ void DataSourceBall :: test(){
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DataSourceBall::isInFront(){
|
||||||
|
return (CURRENT_DATA_READ.ballAngle > MOUTH_MIN_ANGLE || CURRENT_DATA_READ.ballAngle < MOUTH_MAX_ANGLE );
|
||||||
|
}
|
||||||
|
|
||||||
bool DataSourceBall::isInMouth(){
|
bool DataSourceBall::isInMouth(){
|
||||||
return (CURRENT_DATA_READ.ballAngle > MOUTH_MIN_ANGLE || CURRENT_DATA_READ.ballAngle < MOUTH_MAX_ANGLE ) && CURRENT_DATA_READ.ballDistance<=MOUTH_DISTANCE;
|
return isInFront() && CURRENT_DATA_READ.ballDistance<=MOUTH_DISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataSourceBall::isInMouthMaxDistance(){
|
bool DataSourceBall::isInMouthMaxDistance(){
|
||||||
return (CURRENT_DATA_READ.ballAngle>MOUTH_MIN_ANGLE || CURRENT_DATA_READ.ballAngle<MOUTH_MAX_ANGLE) && CURRENT_DATA_READ.ballDistance <= MOUTH_MAX_DISTANCE;
|
return isInFront() && CURRENT_DATA_READ.ballDistance <= MOUTH_MAX_DISTANCE;
|
||||||
}
|
}
|
|
@ -56,24 +56,14 @@ int Striker::tilt() {
|
||||||
else gotta_tilt = false;
|
else gotta_tilt = false;
|
||||||
|
|
||||||
if(!gotta_tilt || !CURRENT_DATA_READ.atkSeen) {
|
if(!gotta_tilt || !CURRENT_DATA_READ.atkSeen) {
|
||||||
roller->speed(roller->MIN);
|
|
||||||
atk_tilt *= 0.8;
|
atk_tilt *= 0.8;
|
||||||
if(atk_tilt <= 10) atk_tilt = 0;
|
if(atk_tilt <= 10) atk_tilt = 0;
|
||||||
}else{
|
}else{
|
||||||
roller->speed(ROLLER_DEFAULT_SPEED);
|
atk_tilt = roller->roller_armed ? CURRENT_DATA_READ.angleAtkFix : constrain(CURRENT_DATA_READ.angleAtkFix, -45, 45);
|
||||||
atk_tilt = constrain(CURRENT_DATA_READ.angleAtkFix, -45, 45);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ball->isInFront()) roller->speed(ROLLER_DEFAULT_SPEED);
|
||||||
|
else roller->speed(roller->MIN);
|
||||||
|
|
||||||
return atk_tilt;
|
return atk_tilt;
|
||||||
|
|
||||||
// if (ball->isInMouth() || (ball->isInMouthMaxDistance() && gotta_tilt)) gotta_tilt = true;
|
|
||||||
// else gotta_tilt = false;
|
|
||||||
|
|
||||||
// if(!gotta_tilt || !CURRENT_DATA_READ.atkSeen) {
|
|
||||||
// roller->speed(roller->MIN);
|
|
||||||
// return 0;
|
|
||||||
// }else{
|
|
||||||
// roller->speed(ROLLER_DEFAULT_SPEED);
|
|
||||||
// return constrain(CURRENT_DATA_READ.angleAtkFix, -45, 45);
|
|
||||||
// }
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue