-
Notifications
You must be signed in to change notification settings - Fork 0
/
DecisionMakingx.h
240 lines (163 loc) · 6.78 KB
/
DecisionMakingx.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// DecisionMakingx.h: interface for the CDecisionMakingx class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DECISIONMAKINGX_H__E1F060A5_484F_4338_B877_7B533844419F__INCLUDED_)
#define AFX_DECISIONMAKINGX_H__E1F060A5_484F_4338_B877_7B533844419F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "globe.h"
#include "defines.h"
#include "GeometryR.h"
#include "Logger.h"
#include "Formation.h"
#include "network.h"
#include "CounterTimer.h"
#include "Hundun.h"
#include "PerfTimer.h"
#define BALLNUMPARA 7
//long x,y;
class CDecisionMakingx : CCounterTimerListener
{
private:
// Basic Actions
int TurnToPointPDli(dbROBOTPOSTURE *pRobot,dbPOINT Point,int clock,dbLRWheelVelocity *pSpeed) ;
void TurnToAnglePD(int nRobot, double dAngle, int clock);
void TurnToPointPD(int nRobot, VecPosition posTarget, int clock);
int ToPositionPDli(dbROBOTPOSTURE* pROBOTPOSTURE,dbPOINT Target,double same_speed, double end_speed,dbLRWheelVelocity* pLRWheelVelocity);
int TurnToAnglePDli(dbROBOTPOSTURE *pRobot,double dbAngle,int clock,dbLRWheelVelocity *pSpeed);
void Turn(int nRobot, double dVelocity,int clock);
void MoveOnAngle(int nRobot,double Angle,double speed);
double TNparali(RobotInford myrobot,dbPOINT ball,dbPOINT goal,double dist,double angle);
void MoveToPt(int nRobot,VecPosition posTarget,double speed);
int Move2Ptli(dbROBOTPOSTURE* pROBOTPOSTURE,dbPOINT Target,double speed,dbLRWheelVelocity* pLRWheelVelocity);
void ToPositionPD(int nRobot, VecPosition posTarget, double speed);
void ToPositionN(int nRobot, VecPosition posTarget, double speed);
void ToPositionNew(int nRobot, VecPosition posTarget, VecPosition posBall, double speed, int IfEndprocess);
int ToPositionNewli(dbROBOTPOSTURE* robot, ballInformation ball,dbPOINT directionpt, double samespeed, int IfEndprocess,dbLRWheelVelocity* pSpeed);
double GetCrossPtWithGLLineli(double x) ;
//末端处理
void EndProcess(int i,int nRobot,VecPosition posTarget, VecPosition posBall);
int EndProcessli(dbROBOTPOSTURE *pRobot,dbPOINT shoot_target,dbPOINT ballPt,dbLRWheelVelocity *pSpeed);
void ToPositionPDGoal(int nRobot, VecPosition posTarget, double speed, double endspeed);
int ToPositionPDGoalli(dbROBOTPOSTURE* pROBOTPOSTURE,dbPOINT Target,double startspeed,double endspeed,dbLRWheelVelocity* pLRWheelVelocity);
void ToPositionAvoidObstacles(int nRobot, VecPosition pos[], int nObstacles);
MoveParameter m_MoveParameter;
private:
// Support
private:
// Complex Actions
void Vect_MidShoot(int nRobot);
void Vect_MidShoot1(int nRobot);
void Vect_MidShoot2(int nRobot);
int Vect_MidShootli(dbROBOTPOSTURE pRobotInford, BallInformation &ball,dbLRWheelVelocity *pSpeed);
void Wait(int nRobot, VecPosition posTarget, double angle, double speed);
void Wait(int nRobot, VecPosition posTarget, VecPosition posToward, double speed);
void ShootLine(int nRobot);
void KickBall(int nRobot);
void RobotReturn2Pt();
void RobotReturn2bound();
void Round(int nRoundRobot);
int GetBoundAreaNo(VecPosition posBall);
void BoundPushBall(int nRobot);
void PushBallofBound(int nRobot);
// Gaolie
void GoalieAction(int nRobot);
int GoalieAction3(dbROBOTPOSTURE *pRobotInford, int x, BallInformation ball, dbLRWheelVelocity *pSpeed,int nRobot);
int GoalieAction4(dbROBOTPOSTURE *pRobotInford, int x, BallInformation ball, dbLRWheelVelocity *pSpeed,int nRobot);
double AdjustTarget();
double GetCrossPtWithGLLine();
int Forcastball(dbPOINT *pPoint,FORCASTBALL *pBall);
public:
// Strategy Functions
void Initialize();
DecisionParamter m_decisionparamter;
void InitDEG(DEGame DEG);
void Startx(RobotInford dmRobot[]);
double m_Front;
AngleParameter m_AngleParameter;
private:
void PreProcess();
void MiroSot_DecisionMaking();
int GetAreaNo(VecPosition posBall);
void TaskDecompose(int areaNo);
void FormInterpret(int formNo);
void CharInterpret(int nRobot,int charNo, dbLRWheelVelocity* pSpeed);
void CharAllot();
double CharPerformance(int charNo, int nRobot);
int GetBestRobot(double Performance[], int charNo);
void RobotManager();
void ActProcess();
private:
// Support
void LogData();
void Test();
// Predict
int KalmanFilter();
VecPosition PredictBall(int nCycle, VecPosition* posVel=NULL);
private:
// Performance from predict
int GetToPositionNCycle(int nRobot, VecPosition posTarget);
int GetToPositionNewCycle(int nRole, int nRobot, VecPosition posBall, VecPosition posTarget);
int GetToPositionNewPerformance(int nRole, int nRobot,
VecPosition posTarget, VecPosition& posBall);
int GetKickBallPerformance(int nRole, int nRobot, VecPosition& posBall);
int GetShootLinePerformance(int nRobot);
void LimitSpeed(dbLRWheelVelocity* pSpeed, double dMaxSpeed, BOOL bMax = FALSE);
VecPosition m_posBall;
CFormation m_formation;
int m_nTimer, m_nTimerLastStart;
network nettpt, nettpn;
public:
CDecisionMakingx();
virtual ~CDecisionMakingx();
BOOL nReset; //是否归位,FALSE
BOOL together,round; ///< 赛前跑位
int m_nTestRobot;
RobotInford Robot[2*ROBOTNUMBER+1], oldRobot[2*ROBOTNUMBER+1];
dbLRWheelVelocity rbV[ROBOTNUMBER], oldrbV[ROBOTNUMBER];
private:
dbPOINT ball;
FORCASTBALL ballCharacter;
dbPOINT oldBallPt[BALLNUMPARA],FilterBallPt[BALLNUMPARA],FilterVel[BALLNUMPARA],FilterAccel[BALLNUMPARA];
int sym[3]; ///< 视觉丢球处理
DEGame dmDEG;
private:
int dmformNo; ///< 队形
///< 队形排列
int currentForm[ROBOTNUMBER],oldForm[ROBOTNUMBER];
///< 按照机器人顺序排列时对应的角色排列
int currentResult[ROBOTNUMBER], oldResult[ROBOTNUMBER];
///< 按照角色顺序排列时对应的机器人排列
int currentOrder[ROBOTNUMBER],oldOrder[ROBOTNUMBER];
int m_nPriorityForm[ROBOTNUMBER], m_nPriorityResult[ROBOTNUMBER];
double perfRecord[ROBOTNUMBER],oldperfRecord[ROBOTNUMBER];
int effecChar[100];
Logger log;
// CPerfTimer m_PerfTimer;
private:
BOOL bStartUnUsual;
BOOL m_bShootLine[ROBOTNUMBER];
BOOL m_bRobotShoot[ROBOTNUMBER];
VecPosition m_posPostBall;
BOOL m_bBallKick;
CCounterTimer m_timerStart, m_timerShootLine, m_timerBallKick;
virtual void Update(CCounterTimer* Timer);
private:
void Mark(int nRobot);
VecPosition GetMarkPosition();
void SendMsg(int nLevel, char* msg, ... );
// Hundun obstacle avoidance
private:
CHunDun m_hundun;
void HundunTest();
void Capture();
// SVM
private:
struct svm_model* m_svmModelTpt;
struct svm_node* m_svmAttrTpt;
private:
double Getpt2ptAngle(dbPOINT pt1,dbPOINT pt2);
// Kick m_kick[ROBOTNUMBER];
};
#endif // !defined(AFX_DECISIONMAKINGX_H__E1F060A5_484F_4338_B877_7B533844419F__INCLUDED_)