-
Notifications
You must be signed in to change notification settings - Fork 9
/
goalie.hpp
68 lines (58 loc) · 2.02 KB
/
goalie.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef GOALIE_HPP
#define GOALIE_HPP
#include <list>
#include "beliefstate.h"
#include "geometry.h"
#include "pose.h"
#include "constants.h"
#include <algorithm>
#include <fstream>
class TGoalie
{
public:
TGoalie(){
} // TGoalie
~TGoalie()
{ } // ~TGoalKeeping
inline bool isActiveTactic(void) const
{
return false;
}
bool isGoalKeeperInPosition(const BeliefState* state, int botID)
{
if ((state->homeX[botID] > (-HALF_FIELD_MAXX + GOAL_DEPTH)) &&
(state->homeX[botID] <= (-HALF_FIELD_MAXX + GOAL_DEPTH + BOT_RADIUS*2)) &&
(state->homeY[botID] >= OUR_GOAL_MINY - DBOX_HEIGHT) &&
(state->homeY[botID] <= (OUR_GOAL_MAXY + DBOX_HEIGHT)))
return true;
else
return false;
}
Pose execute(BeliefState *state, int botID)
{
Vector2D<int> homePos(state->homeX[botID], state->homeY[botID]);
Vector2D<int> ballPos(state->ballX, state->ballY);
float dist = Vector2D<int>::dist(ballPos, homePos);
if (!isGoalKeeperInPosition(state, botID) && dist > 0.5 * BOT_BALL_THRESH)
{
return Pose(-HALF_FIELD_MAXX + GOAL_DEPTH + BOT_RADIUS*1.2, 0, -PI/2);
}
Vector2D<int> botDestination ;
float ang1;
if(abs(state->ballVx)<10)
ang1 = 0;
else
ang1 = atan(state->ballVy/state->ballVx);
//in case of ball traveling directly from the oponent's half
botDestination.y = state->ballY - ((state->ballX) - (-HALF_FIELD_MAXX + DBOX_WIDTH + BOT_RADIUS*1.5))*tan(ang1) ; //tan(ang1)
if(botDestination.y >= OUR_GOAL_MAXY)
botDestination.y = OUR_GOAL_MAXY - 0.2*BOT_RADIUS;
if(botDestination.y <= OUR_GOAL_MINY)
botDestination.y = OUR_GOAL_MINY + 0.2*BOT_RADIUS;
qDebug() << "bot dest y " << botDestination.y << endl;
botDestination.x = (-HALF_FIELD_MAXX + GOAL_DEPTH+ 1.5*BOT_RADIUS); //+ 100; //set your threshold ********
// botDestination.y + = oscillation()*BOT_RADIUS ;// set according to you decide to put oscillation at normal point********
return Pose(-HALF_FIELD_MAXX + GOAL_DEPTH + BOT_RADIUS*1.5, botDestination.y, -PI/2);
}
};// class TGoalKeepingOurside
#endif // GOALIE_H