striker: robot tilt towards the goal when attacking
Although without a roller the robot just sky-rockets the ball away when they come in touchpull/1/head
parent
95a601f030
commit
3308c26ef4
|
@ -4,9 +4,9 @@
|
||||||
#include "sensors/sensors.h"
|
#include "sensors/sensors.h"
|
||||||
#include "strategy_roles/game.h"
|
#include "strategy_roles/game.h"
|
||||||
|
|
||||||
#define STRIKER_ATTACK_DISTANCE 300
|
#define STRIKER_ATTACK_DISTANCE 100
|
||||||
#define STRIKER_PLUSANG 55
|
#define STRIKER_PLUSANG 55
|
||||||
#define STRIKER_PLUSANG_VISIONCONE 20
|
#define STRIKER_PLUSANG_VISIONCONE 10
|
||||||
|
|
||||||
class Striker : public Game{
|
class Striker : public Game{
|
||||||
|
|
||||||
|
@ -18,11 +18,12 @@ class Striker : public Game{
|
||||||
void realPlay() override;
|
void realPlay() override;
|
||||||
void init() override;
|
void init() override;
|
||||||
void striker();
|
void striker();
|
||||||
void ballBack();
|
int tilt();
|
||||||
void storcimentoPorta();
|
|
||||||
|
|
||||||
int atk_speed, atk_direction;
|
int atk_speed, atk_direction, atk_tilt;
|
||||||
float cstorc;
|
float cstorc;
|
||||||
|
|
||||||
|
ComplementaryFilter* filter;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,10 @@ void Striker::init()
|
||||||
{
|
{
|
||||||
atk_speed = 0;
|
atk_speed = 0;
|
||||||
atk_direction = 0;
|
atk_direction = 0;
|
||||||
|
atk_tilt = 0;
|
||||||
cstorc = 0;
|
cstorc = 0;
|
||||||
|
|
||||||
|
filter = new ComplementaryFilter(0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Striker::realPlay()
|
void Striker::realPlay()
|
||||||
|
@ -37,11 +40,10 @@ void Striker::striker()
|
||||||
|
|
||||||
if (CURRENT_DATA_READ.ballDistance > STRIKER_ATTACK_DISTANCE)
|
if (CURRENT_DATA_READ.ballDistance > STRIKER_ATTACK_DISTANCE)
|
||||||
{
|
{
|
||||||
drive->prepareDrive(ball_deg > 180 ? CURRENT_DATA_READ.ballAngle - 10 : CURRENT_DATA_READ.ballAngle + 10, 100, 0);
|
drive->prepareDrive(ball_deg > 180 ? CURRENT_DATA_READ.ballAngle - 20 : CURRENT_DATA_READ.ballAngle + 20, MAX_VEL_EIGTH, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ball_deg > 340 || ball_deg < 20)
|
if (ball_deg > 340 || ball_deg < 20)
|
||||||
plusang -= STRIKER_PLUSANG_VISIONCONE; //se ho la palla in un range di +-20 davanti, diminuisco di 20 il plus
|
plusang -= STRIKER_PLUSANG_VISIONCONE; //se ho la palla in un range di +-20 davanti, diminuisco di 20 il plus
|
||||||
if (ball_deg > 180)
|
if (ball_deg > 180)
|
||||||
|
@ -58,9 +60,17 @@ void Striker::striker()
|
||||||
dir = dir + 360; //se sto nel quadrante negativo ricappotto
|
dir = dir + 360; //se sto nel quadrante negativo ricappotto
|
||||||
else
|
else
|
||||||
dir = dir;
|
dir = dir;
|
||||||
drive->prepareDrive(dir, MAX_VEL_EIGTH, 0);
|
|
||||||
|
drive->prepareDrive(dir, MAX_VEL_QUARTER, tilt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Striker::storcimentoPorta()
|
int Striker::tilt()
|
||||||
{
|
{
|
||||||
|
if (!CURRENT_DATA_READ.atkSeen) return 0;
|
||||||
|
if (CURRENT_DATA_READ.ballAngleFix >= 350 || CURRENT_DATA_READ.ballAngleFix <= 10)
|
||||||
|
atk_tilt = (constrain(CURRENT_DATA_READ.angleAtkFix, -45, 45) + 360) % 360;
|
||||||
|
else if((CURRENT_DATA_READ.ballAngleFix > 345 && CURRENT_DATA_READ.ballAngleFix < 350) || (CURRENT_DATA_READ.ballAngleFix > 10 && CURRENT_DATA_READ.ballAngleFix < 15))
|
||||||
|
atk_tilt = 0;
|
||||||
|
atk_tilt = filter->calculate(atk_tilt);
|
||||||
|
return atk_tilt;
|
||||||
}
|
}
|
Loading…
Reference in New Issue