Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added maps/train_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions maps/train_map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
image: train_map.png
mode: trinary
resolution: 0.05
origin: [-1.2, -6.3, 0.0]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196
2 changes: 1 addition & 1 deletion src/lua/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local util = require("util.native")
--- @field fuck fun(message: string)
---
--- @field send_target fun(x: number, y: number)
--- @field update_gimbal_direction fun(angle: number)
--- @field update_gimbal_direction fun(angle: number)
--- @field update_gimbal_dominator fun(name: string)
--- @field update_chassis_mode fun(mode: string)
--- @field update_chassis_vel fun(x: number, y: number)
Expand Down
104 changes: 96 additions & 8 deletions src/lua/blackboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,82 @@ local function create_default_blackboard()
x = 0,
y = 0,
yaw = 0,

mode = "UNKNOWN",

},
game = {
stage = "UNKNOWN",

outpost_health = 0, -- 前哨站血量
base_health = 0, -- 基地血量

hero_health = 150,
infantry_1_health = 150,
infantry_2_health = 150,
engineer_health = 250,

remaining_time = 0, -- 比赛剩余时间
gold_coin = 0, -- 队伍剩余金币数
exchangeable_ammunition_quantity = 0, -- 队伍 17mm 允许发弹量的剩余可兑换数

our_dart_nmber_of_hits = 0, -- 己方飞镖击中次数
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

字段/谓词存在多处拼写错误,建议统一修正

下列拼写错误会随 blackboard 暴露给整个决策树/FSM,后续修正会成为破坏性变更,建议在合并前一并处理:

  • 第 37 行:our_dart_nmber_of_hitsour_dart_number_of_hits
  • 第 109 行:central_highland_gain_pountcentral_highland_gain_point
  • 第 150 行:oupost_survivaloutpost_survival
  • 第 155 行:result.game.our_dart_nmber_of_hits(同步修正字段引用)

注意第 150 行的 oupost_survival 是新增的 condition 谓词,已经被 FSM/任务侧依赖,越晚改影响面越大。

🔧 建议的修正 diff
-			our_dart_nmber_of_hits = 0, -- 己方飞镖击中次数
+			our_dart_number_of_hits = 0, -- 己方飞镖击中次数
-			central_highland_gain_pount = PointPair { { 0, 0 }, { 0, 0 } }, -- 中央高地增益点
+			central_highland_gain_point = PointPair { { 0, 0 }, { 0, 0 } }, -- 中央高地增益点
-		oupost_survival = function ()
-			return result.game.outpost_health > 0
-		end,
+		outpost_survival = function()
+			return result.game.outpost_health > 0
+		end,

-		dart_hit_first_time = function ()
-			return result.game.our_dart_nmber_of_hits == 1
-		end,
+		dart_hit_first_time = function()
+			return result.game.our_dart_number_of_hits == 1
+		end,

Also applies to: 109-109, 150-156

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lua/blackboard.lua` at line 37, Rename the misspelled blackboard fields
and all their references: change field our_dart_nmber_of_hits to
our_dart_number_of_hits and update any usages (e.g.
result.game.our_dart_nmber_of_hits) to result.game.our_dart_number_of_hits;
change central_highland_gain_pount to central_highland_gain_point; and change
oupost_survival to outpost_survival (note this predicate is used by FSM/tasks so
update all dependent condition checks). Ensure you update both the declarations
in blackboard.lua and every place that reads/writes these symbols to keep names
consistent across the decision tree/FSM.

double_damage_activated = false, -- 雷达双倍易伤是否开启
fortress_occupied = false, -- 己方堡垒是否被占领
big_energy_mechanism_activated = false, -- 大能量机关是否被激活
small_energy_mechanism_activated = false, -- 小能量机关是否被激活


},
play = {
rswitch = "UNKNOWN",
lswitch = "UNKNOWN",
},
meta = {
timestamp = 0, -- 秒
fsm_state = "unknown",
fsm_phase = "none",
},

-- Static Information
rule = {
decision = "auxiliary",

-- 状态类规则
-- 自身状态类规则

health_limit = 210,
health_ready = 400,
bullet_limit = 40,
bullet_ready = 300,
mode = "movement",

-- 其他状态类规则

-- 比赛相关
time_of_the_competition = 420, --比赛剩余时间

health_limit = 0,
health_ready = 0,
bullet_limit = 0,
bullet_ready = 0,
-- 队伍资源相关
exchangeable_ammunition_quantity = 1000, -- 队伍 17mm 允许发弹量的剩余可兑换数
gold_coin = 400, -- 队伍剩余金币数

-- 前哨站相关
outpost_health_ready = 1500,
outpost_health_red_line = 1500,

-- 基地相关
base_health_ready = 5000,
base_health_red_line = 2000,

-- 友方机器人相关
hero_health_ready = 150,
infantry_1_health_ready = 150,
infantry_2_health_ready = 150,
engineer_health_ready = 250,

hero_health_ready_red_line = 50,
infantry_1_health_ready_red_line = 50,
infantry_2_health_ready_red_line = 50,
engineer_health_ready_red_line = 50,

-- 坐标类规则
-- 定义顺序:ours = 0,them = 1
Expand All @@ -50,14 +104,20 @@ local function create_default_blackboard()
launch_ramp_final = PointPair { { 0, 0 }, { 0, 0 } },
outpost_resupply = PointPair { { 0, 0 }, { 0, 0 } }, -- 前哨站补给点
assembly_zone = PointPair { { 0, 0 }, { 0, 0 } },
central_highland_near_fluctuant_road = PointPair { { 0, 0 }, { 0, 0 } }, -- 中央高地靠近起伏路一侧
central_highland_near_doghole = PointPair { { 0, 0 }, { 0, 0 } }, -- 中央高地靠近狗洞一侧
central_highland_gain_pount = PointPair { { 0, 0 }, { 0, 0 } }, -- 中央高地增益点
central_highland_near_two_steps_and_outpost = PointPair { { 0, 0 }, { 0, 0 } }, -- 中央高地靠近二级台阶(二级台阶增益点和前哨站中间)

-- 特殊跨越地形坐标
road_tunnel_begin = PointPair { { 0, 0 }, { 0, 0 } }, -- 公路隧道
road_tunnel_final = PointPair { { 0, 0 }, { 0, 0 } },
one_step_begin = PointPair { { 0, 0 }, { 0, 0 } }, -- 一级台阶
one_step_final = PointPair { { 0, 0 }, { 0, 0 } },
two_step_begin = PointPair { { 0, 0 }, { 0, 0 } }, -- 二级台阶
one_step_begin = PointPair { { 0, 0 }, { 0, 0 } }, -- 一级台阶高点
one_step_final = PointPair { { 0, 0 }, { 0, 0 } }, -- 一级台阶低点
two_step_begin = PointPair { { 0, 0 }, { 0, 0 } }, -- 二级台阶高点
two_step_final = PointPair { { 0, 0 }, { 0, 0 } },
fluctuant_road_begin = PointPair { { 0, 0 }, { 0, 0 } }, -- 起伏路段
fluctuant_road_final = PointPair { { 0, 0 }, { 0, 0 } },
common_elevated_ground_begin = PointPair { { 0, 0 }, { 0, 0 } }, -- 普通高地(飞坡起点那个高地)
common_elevated_ground_final = PointPair { { 0, 0 }, { 0, 0 } },
},
Expand All @@ -83,6 +143,34 @@ local function create_default_blackboard()
return result.user.bullet >= result.rule.bullet_ready
end,

base_in_danger = function ()
return result.game.base_health <= result.rule.base_health_red_line
end,

oupost_survival = function ()
return result.game.outpost_health > 0
end,

dart_hit_first_time = function ()
return result.game.our_dart_nmber_of_hits == 1
end,

double_damage_activated = function ()
return result.game.double_damage_activated
end,

fortress_occupied = function ()
return result.game.fortress_occupied
end,

big_energy_mechanism_activated = function ()
return result.game.big_energy_mechanism_activated
end,

small_energy_mechanism_activated = function ()
return result.game.small_energy_mechanism_activated
end,

--- @param target {x: number, y: number}
--- @param tolerance? number|{x: number, y: number}
near = function(target, tolerance)
Expand Down
2 changes: 1 addition & 1 deletion src/lua/endpoint/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ end
--- 由 NAV2 发布的目标速度值,在此处理回调
on_control = function(x, y, _)
action:update_chassis_vel(x, y)
end
end
Loading