parent
f3eed47a67
commit
f11127bb40
|
@ -15,6 +15,7 @@ class DataSourceBall : public DataSource{
|
|||
void test() override;
|
||||
bool isInMouth();
|
||||
bool isInMouthMaxDistance();
|
||||
bool isInFront();
|
||||
|
||||
int angle, distance, angleFix;
|
||||
bool ballSeen;
|
||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -29,17 +29,20 @@ void setup() {
|
|||
testmenu = new TestMenu();
|
||||
tone(BUZZER, 240, 250);
|
||||
initStatusVector();
|
||||
delay(100);
|
||||
|
||||
tone(BUZZER, 260, 250);
|
||||
initSensors();
|
||||
delay(500);
|
||||
|
||||
tone(BUZZER, 320, 250);
|
||||
initGames();
|
||||
|
||||
delay(500);
|
||||
|
||||
drive->prepareDrive(0,0,0);
|
||||
delay(200);
|
||||
|
||||
//Startup sound
|
||||
tone(BUZZER, 350.00, 250);
|
||||
|
||||
drive->prepareDrive(0,0,0);
|
||||
}
|
||||
|
||||
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(){
|
||||
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(){
|
||||
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;
|
||||
|
||||
if(!gotta_tilt || !CURRENT_DATA_READ.atkSeen) {
|
||||
roller->speed(roller->MIN);
|
||||
atk_tilt *= 0.8;
|
||||
if(atk_tilt <= 10) atk_tilt = 0;
|
||||
}else{
|
||||
roller->speed(ROLLER_DEFAULT_SPEED);
|
||||
atk_tilt = constrain(CURRENT_DATA_READ.angleAtkFix, -45, 45);
|
||||
atk_tilt = roller->roller_armed ? CURRENT_DATA_READ.angleAtkFix : constrain(CURRENT_DATA_READ.angleAtkFix, -45, 45);
|
||||
}
|
||||
|
||||
if(ball->isInFront()) roller->speed(ROLLER_DEFAULT_SPEED);
|
||||
else roller->speed(roller->MIN);
|
||||
|
||||
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