roller: activate when ball is in front

do not take distance into account
pull/1/head
EmaMaker 2021-05-11 15:21:22 +02:00
parent f3eed47a67
commit f11127bb40
4 changed files with 18 additions and 20 deletions

View File

@ -15,6 +15,7 @@ class DataSourceBall : public DataSource{
void test() override;
bool isInMouth();
bool isInMouthMaxDistance();
bool isInFront();
int angle, distance, angleFix;
bool ballSeen;

View File

@ -29,17 +29,20 @@ void setup() {
testmenu = new TestMenu();
tone(BUZZER, 240, 250);
initStatusVector();
delay(100);
tone(BUZZER, 260, 250);
initSensors();
tone(BUZZER, 320, 250);
initGames();
delay(500);
drive->prepareDrive(0,0,0);
tone(BUZZER, 320, 250);
initGames();
delay(200);
//Startup sound
tone(BUZZER, 350.00, 250);
drive->prepareDrive(0,0,0);
}
void loop() {

View File

@ -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;
}

View File

@ -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);
// }
}