Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/TnT2'
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltApocalypse committed Apr 9, 2024
2 parents eb691f4 + e913d32 commit 3f78a0d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Core/src/LuaModule/utils.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Utils{


std::string GlobalStatus(const CVisionModule *pVision,int attack_flag);
CGeoPoint GetInterPos(const CVisionModule *pVision, CGeoPoint player_pos,double velocity);
//CGeoPoint GetInterPos(const CVisionModule *pVision, CGeoPoint player_pos,double velocity);
std::string GlobalComputingPos(const CVisionModule *pVision);
CGeoPoint GetAttackPos(const CVisionModule *pVision,int num);

Expand Down
5 changes: 3 additions & 2 deletions Core/src/Utils/LeastSquaresfit.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class LeastSquaresfit
double GetPreDist(double label, double time); // 输入标签和时间预测距离
double GetPreTime(double label, double d); // 输入标签和距离预测时间
double GetMaxDist(double label); // 输入标签,输出能到达的最远距离
// CGeoPoint GetBallPrePos(double ball_v, CGeoPoint ball_pos, double ball_dir,double time);

CGeoPoint GetMaxPos(double label, GlobalTick* Tick); // 输入标签,输出最远能到达的点
CGeoPoint BestGetBallPos(double label, CGeoPoint playerPos, GlobalTick* Tick); // 输入标签,玩家的位置和Tick返回最佳截球点
double GetLabel(GlobalTick* Tick); // 获取标签
private:
int Len;
double Em[6][4];
Expand Down
53 changes: 48 additions & 5 deletions Core/src/Utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,57 @@ namespace Utils
}
}

/**
* 获取球运动的最远距离
* @brief GetBallMaxDist
* @param pVision
* @return
*/
double GetBallMaxDist(const CVisionModule *pVision){
double a = PARAM::Field::V_DECAY_RATE;
double v = pVision ->ball().Vel().mod();
double maxT = v / a;
double maxDist = a * maxT * maxT;

GDebugEngine::Instance()->gui_debug_msg(CGeoPoint(1000, 1500), "v:"+to_string(v));
GDebugEngine::Instance()->gui_debug_msg(CGeoPoint(1000, 1000), "d:"+to_string(maxDist));
return maxDist;
}

/**
* 给球要经过的距离,返回到达此处的时间
* @brief GetBallToDistTime
* @param pVision
* @param dist
* @return
*/
double GetBallToDistTime(const CVisionModule *pVision, double dist){
double a = PARAM::Field::V_DECAY_RATE;
double v = pVision ->ball().Vel().mod();
double t = sqrt((2*a*dist + v*v) / a*a) - v/a;

// GDebugEngine::Instance()->gui_debug_msg(CGeoPoint(1000, 2000), "t:"+to_string(t));
return t;
}


/**
* 获取相对某坐标最佳截球点(动态:球在运动过程中)
* @param {CVisionModule*} pVision : pVision
* @param {CGeoPoint} player_pos : 坐标
* @param {double} velocity : 速度
* @return {CGeoPoint} : 最佳截球点
*/
CGeoPoint GetInterPos(const CVisionModule *pVision, CGeoPoint player_pos, double velocity)
CGeoPoint BestGetBallPos(const CVisionModule *pVision)
{

double maxDist = GetBallMaxDist(pVision);
GetBallToDistTime(pVision, maxDist);
for(int dist=0;dist<maxDist;dist+=100){
// GetBallToDistTime(pVision, dist);
GDebugEngine::Instance()->gui_debug_msg(pVision->ball().Pos()+Polar2Vector(dist, pVision->ball().Vel().dir()), to_string(GetBallToDistTime(pVision, dist)),1,10);
GDebugEngine::Instance()->gui_debug_x(pVision->ball().Pos()+Polar2Vector(dist, pVision->ball().Vel().dir()));
}
return pVision ->ball().Pos() + Polar2Vector(maxDist, pVision ->ball().Vel().dir());
}

/**
Expand All @@ -285,6 +326,8 @@ namespace Utils
CGeoSegment PredictBallLine(const CVisionModule *pVision)
{



}
double GlobalConfidence(const CVisionModule *pVision,int attack_flag)
{
Expand Down Expand Up @@ -429,13 +472,15 @@ namespace Utils
}

//Debug
GDebugEngine::Instance()->gui_debug_msg(CGeoPoint(0,0), "testmsg");
GDebugEngine::Instance()->gui_debug_x(BestGetBallPos(pVision));

for(int i = 0;i < PARAM::Field::MAX_PLAYER;i++)
{
if(pVision ->ourPlayer(i).Valid() &&
(attack_flag == 0 &&
(Tick[now].task[i].player_num != -1 && Tick[now].task[i].player_num != Tick[now].our.goalie_num)))
{

global_status = global_status + "[" + to_string(Tick[now].task[i].player_num) + "," + Tick[now].task[i].status + "]";
GDebugEngine::Instance()->gui_debug_msg(CGeoPoint(pVision ->ourPlayer(i).Pos().x(),pVision ->ourPlayer(i).Pos().y() - 160),"Number: " + to_string(Tick[now].task[i].player_num),4,0,80);
GDebugEngine::Instance()->gui_debug_msg(CGeoPoint(pVision ->ourPlayer(i).Pos().x(),pVision ->ourPlayer(i).Pos().y() - 250),"shoot: " + to_string(Tick[now].task[i].confidence_shoot),8,0,80);
Expand Down Expand Up @@ -659,8 +704,6 @@ namespace Utils
pass_grade = 0.2 * pass_dir_grade + 0.8 * pass_dist_grade;
grade = 0.4 * shoot_grade + 0.3 * pass_grade + 0.3 * pass_safty_grade;
return grade;


}


Expand Down
2 changes: 2 additions & 0 deletions Core/tactics/play/mytest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ local debugStatus = function()
" " ..
tostring(i.status),3)
end


end

local closures_point = function(point)
Expand Down
12 changes: 4 additions & 8 deletions share/staticparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,17 @@ namespace PARAM {
const double GOAL_WIDTH = 1000;
const double GOAL_DEPTH = 200;
const double RATIO = 1.5;
const double V_DECAY_RATE = 2000;
}
namespace Player {
const int playerFrontToCenter = 76; // 机器人圆心到嘴的距离
const int playerRadiusr = 90; // 机器人半径
const int playerBuffer = 120; // 检测敌人是否在某直线上的缓冲值
const double playerBallRightsBuffer = 230; // 球权判断缓冲值
const int playerTouchAngle = 60;
}
namespace Tick {
const int TickLength = 3; //保存的帧数
}
namespace Fit { // 擬合相關參數
const int FitLabel = 3; // 取第几帧的距离作为标签
const int DataTickLength = 100; // 采样时保存帧数
const std::string FitDataFileName = "fitfunctions/data.txt" ; //拟合时用的文件名
}
namespace Tick{
const int TickLength = 5; //保存的帧数
}
namespace Rule{
const int Version = 2019; // 规则的版本/年份
Expand Down

0 comments on commit 3f78a0d

Please sign in to comment.