Skip to content

Commit

Permalink
是否在禁区添加了三种模式[our,their,all]
Browse files Browse the repository at this point in the history
  • Loading branch information
Umbrella167 committed Apr 16, 2024
1 parent 4e2fe06 commit f2fb411
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Core/src/LuaModule/utils.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Utils{

// 小工具
CGeoPoint GetBallMaxPos(const CVisionModule *pVision);
bool InExclusionZone(CGeoPoint Point, double buffer = 0);
bool InExclusionZone(CGeoPoint Point, double buffer = 0,std::string dir = "all");
bool InField(CGeoPoint Point);
bool InOurField(CGeoPoint Point);

Expand Down
38 changes: 30 additions & 8 deletions Core/src/Utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ namespace Utils
// GDebugEngine::Instance() ->gui_debug_x(CGeoPoint(x,y));
// GDebugEngine::Instance() ->gui_debug_msg(CGeoPoint(x,y),to_string(grade),1,0,60);
}
GDebugEngine::Instance() ->gui_debug_arc(Tick[now].ball.first_dribbling_pos,1000,0,360,3);
GDebugEngine::Instance() ->gui_debug_arc(Tick[now].ball.first_dribbling_pos,1000,0,360,8);
GDebugEngine::Instance() ->gui_debug_x(max_grade_point,3);
return max_grade_point;

Expand Down Expand Up @@ -1391,22 +1391,44 @@ namespace Utils
* @param {double} y :
* @return {bool} :
*/
bool InExclusionZone(CGeoPoint Point, double buffer)
bool InExclusionZone(CGeoPoint Point, double buffer,string dir)
{
double x = Point.x();
double y = Point.y();
if (((x < (-1 * PARAM::Field::PITCH_LENGTH / 2) + PARAM::Field::PENALTY_AREA_DEPTH + buffer) ||
(x > (PARAM::Field::PITCH_LENGTH / 2) - PARAM::Field::PENALTY_AREA_DEPTH - buffer)) &&
(y > -1 * PARAM::Field::PENALTY_AREA_WIDTH / 2 - buffer && y < PARAM::Field::PENALTY_AREA_WIDTH / 2 + buffer))
if (dir == "our")
{
return true;

if ((x < (-1 * PARAM::Field::PITCH_LENGTH / 2) + PARAM::Field::PENALTY_AREA_DEPTH + buffer) &&
(y > -1 * PARAM::Field::PENALTY_AREA_WIDTH / 2 - buffer && y < PARAM::Field::PENALTY_AREA_WIDTH / 2 + buffer))
return true;
else
return false;





}
else if(dir == "their")
{
if ((x > (PARAM::Field::PITCH_LENGTH / 2) - PARAM::Field::PENALTY_AREA_DEPTH - buffer)&&
(y > -1 * PARAM::Field::PENALTY_AREA_WIDTH / 2 - buffer && y < PARAM::Field::PENALTY_AREA_WIDTH / 2 + buffer))
return true;
else
return false;

}
else
{
return false;
if (((x < (-1 * PARAM::Field::PITCH_LENGTH / 2) + PARAM::Field::PENALTY_AREA_DEPTH + buffer) ||
(x > (PARAM::Field::PITCH_LENGTH / 2) - PARAM::Field::PENALTY_AREA_DEPTH - buffer)) &&
(y > -1 * PARAM::Field::PENALTY_AREA_WIDTH / 2 - buffer && y < PARAM::Field::PENALTY_AREA_WIDTH / 2 + buffer))
return true;
else
return false;

}
}

/**
* 判断是否在场地内
* @brief InField
Expand Down
2 changes: 1 addition & 1 deletion Core/src/Utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Utils
extern std::string GlobalComputingPos(const CVisionModule *pVision); // 计算所有点位
extern double map(double value, double min_in, double max_in, double min_out, double max_out); // 映射
extern bool InField(CGeoPoint Point); // 判断点是否在场地内
extern bool InExclusionZone(CGeoPoint Point, double buffer = 0); // 判断点是否在禁区内
extern bool InExclusionZone(CGeoPoint Point, double buffer = 0,std::string dir = "all"); // 判断点是否在禁区内
extern bool InOurField(CGeoPoint Point);
extern double NumberNormalize(double data, double max_data, double min_data); // [0,1] 标准化
extern bool isValidPass(const CVisionModule *pVision, CGeoPoint start, CGeoPoint end, double buffer = 150);
Expand Down
2 changes: 1 addition & 1 deletion Core/tactics/play/newNormalPlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ local getBallRoleMatch = function(resState)
if NowAssisterNum ~= AssisterNumLast then
matchChangeCount = matchChangeCount + 1
end
if matchChangeCount > 3 and firstAssisterNum ~= NowAssisterNum then
if matchChangeCount > 2 and firstAssisterNum ~= NowAssisterNum then
matchChangeCount = 0
return resState
end
Expand Down
16 changes: 10 additions & 6 deletions Core/tactics/play/shootPoint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ local shootPosFun = function()
return param.shootPos
end
end
local debugMesg = function ()
-- debugEngine:gui_debug_msg(CGeoPoint(-1000,1000),shootPosFun():x() .. " " .. shootPosFun():y(),3)
debugEngine:gui_debug_line(player.pos("Assister"),player.pos("Assister") + Utils.Polar2Vector(9999,player.dir("Assister")),4)
-- debugEngine:gui_debug_line(player.pos("Assister"),player.pos("Assister") + Utils.Polar2Vector(9999,player.dir("Assister") - param.shootError / 57.3))
end


local shoot_kp = param.shootKp
local resShootPos = CGeoPoint(4500,0)
Expand All @@ -34,7 +30,15 @@ local shootKPFun = function()
return shoot_kp
end
end

local debugMesg = function ()

if(task.playerDirToPointDirSub("Assister",resShootPos) < param.shootError) then
debugEngine:gui_debug_line(player.pos("Assister"),player.pos("Assister") + Utils.Polar2Vector(9999,player.dir("Assister")),1)
else
debugEngine:gui_debug_line(player.pos("Assister"),player.pos("Assister") + Utils.Polar2Vector(9999,player.dir("Assister")),4)

end
end
return {

firstState = "ready1",
Expand Down
4 changes: 2 additions & 2 deletions ZBin/lua_scripts/worldmodel/task.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ function power(p, Kp) --根据目标点与球之间的距离求出合适的 击
if res > 6000 then
res = 6000
end
if res < 3500 then
res = 3500
if res < 4000 then
res = 4000
end
debugEngine:gui_debug_msg(CGeoPoint:new_local(0,3200),"Power" .. res .. " toTargetDist: " .. dist,3)
return res
Expand Down

0 comments on commit f2fb411

Please sign in to comment.