From f11127bb404be34db5af4d1ee0a03142da1b5b02 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Tue, 11 May 2021 15:21:22 +0200 Subject: [PATCH] roller: activate when ball is in front do not take distance into account --- include/sensors/data_source_ball.h | 1 + src/main.cpp | 11 +++++++---- src/sensors/data_source_ball.cpp | 8 ++++++-- src/strategy_roles/striker.cpp | 18 ++++-------------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/include/sensors/data_source_ball.h b/include/sensors/data_source_ball.h index 905294c..b028a99 100644 --- a/include/sensors/data_source_ball.h +++ b/include/sensors/data_source_ball.h @@ -15,6 +15,7 @@ class DataSourceBall : public DataSource{ void test() override; bool isInMouth(); bool isInMouthMaxDistance(); + bool isInFront(); int angle, distance, angleFix; bool ballSeen; diff --git a/src/main.cpp b/src/main.cpp index b4519ca..9d7453a 100755 --- a/src/main.cpp +++ b/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() { diff --git a/src/sensors/data_source_ball.cpp b/src/sensors/data_source_ball.cpp index 8d173e2..806075b 100644 --- a/src/sensors/data_source_ball.cpp +++ b/src/sensors/data_source_ball.cpp @@ -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.ballAnglespeed(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); - // } } \ No newline at end of file