diff --git a/Core/src/LuaModule/utils.pkg b/Core/src/LuaModule/utils.pkg index ced37b6..174638a 100644 --- a/Core/src/LuaModule/utils.pkg +++ b/Core/src/LuaModule/utils.pkg @@ -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); diff --git a/Core/src/Utils/LeastSquaresfit.h b/Core/src/Utils/LeastSquaresfit.h index 8e9da67..bc88af0 100644 --- a/Core/src/Utils/LeastSquaresfit.h +++ b/Core/src/Utils/LeastSquaresfit.h @@ -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]; diff --git a/Core/src/Utils/utils.cpp b/Core/src/Utils/utils.cpp index 60fb39c..3858408 100644 --- a/Core/src/Utils/utils.cpp +++ b/Core/src/Utils/utils.cpp @@ -252,6 +252,40 @@ 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 @@ -259,9 +293,16 @@ namespace Utils * @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;distgui_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()); } /** @@ -285,6 +326,8 @@ namespace Utils CGeoSegment PredictBallLine(const CVisionModule *pVision) { + + } double GlobalConfidence(const CVisionModule *pVision,int attack_flag) { @@ -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); @@ -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; - - } diff --git a/Core/tactics/play/mytest.lua b/Core/tactics/play/mytest.lua index d20acaf..478857f 100644 --- a/Core/tactics/play/mytest.lua +++ b/Core/tactics/play/mytest.lua @@ -18,6 +18,8 @@ local debugStatus = function() " " .. tostring(i.status),3) end + + end local closures_point = function(point) diff --git a/share/staticparams.h b/share/staticparams.h index 4e96fd9..321d793 100644 --- a/share/staticparams.h +++ b/share/staticparams.h @@ -47,6 +47,7 @@ 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; // 机器人圆心到嘴的距离 @@ -54,14 +55,9 @@ namespace PARAM { 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; // 规则的版本/年份