Skip to content

feat(referee): adapt to latest referee protocol and add sentry interaction#72

Closed
gqsdjhh wants to merge 4 commits into
mainfrom
dev/referee
Closed

feat(referee): adapt to latest referee protocol and add sentry interaction#72
gqsdjhh wants to merge 4 commits into
mainfrom
dev/referee

Conversation

@gqsdjhh
Copy link
Copy Markdown

@gqsdjhh gqsdjhh commented May 7, 2026

This PR updates RMCS referee communication to match the latest referee system protocol, and adds sentry-referee interaction support.

Changes

  • Update referee protocol field definitions and status parsing
  • Add support for event data, dart info, map command, and sentry info
  • Publish more complete ally/sentry related referee topics
  • Add SentryDecision interaction component for sentry decision commands
  • Register the new component in plugins.xml

Validation

  • Passed real-world test on doghole infantry
  • Passed real-world test on sentry

费更新 Referee 通信协议并添加哨兵交互支持

此 PR 将 RMCS 与最新 referee 协议对齐,扩展了 referee->本地 的状态解析与发布项,并新增哨兵(sentry)相关的交互组件与主题。

主要改动

协议字段与打包结构(field.hpp)

  • 新增并定义 GameRobotPosition(包含 hero/engineer/standard_3/standard_4 的 x,y 坐标及保留字段)。
  • 新增 SentryInfo(包含 sentry_info 与 sentry_info_2 两个打包字段)。
  • 在引入新结构后移除了原先对 MapCommand 大小的静态断言(static_assert 被删除)。

状态处理扩展(status.cpp)

  • 增加并发布更多 ally/robot 与 sentry 相关输出主题:队友位置(hero/engineer/infantry)、更细粒度的 HP 输出、robot_current_hp、sentry 能力/交换/模式指标、事件与飞镖(dart)数据、以及地图命令相关子字段(target、timestamp、sequence)等。
  • 扩展命令分发以支持新的命令 ID(如 0x0101 event data、0x0105 dart info、0x020B game-robot position、0x020D sentry info)。
  • update_game_status() 现在发布 game_stage、stage_remain_time 与 sync_timestamp,并根据阶段调整看门狗重置间隔。
  • 新增并实现 update_event_data() 与 update_dart_info():从位域解码事件激活与飞镖计数并发布相应输出。
  • update_game_robot_hp() 与相关函数现在填充 robots_hp_ 与更细化的盟友 HP 输出;update_robot_status() 解码当前 HP、射手冷却、功率限制(含无限值处理)及底盘输出位域等。
  • update_bullet_allowance() 扩展解码更多弹药/限额字段(包括堡垒 17mm)及剩余金币。
  • 引入 update_game_robot_position() 用于从 GameRobotPosition 解码并发布队友坐标;原先的 update_robot_position() 被替换为空存根。
  • update_map_command() 增加载荷长度校验、memcpy 复制 MapCommand、使用缓存 memcmp 抑制重复命令、更新 target/event 子字段、同步事件时间戳并递增事件序列计数。
  • 新增 update_sentry_info():校验载荷长度,解码两个打包的 sentry 字段为复活/交换能力标志、交换费用、可交换/远程弹药计数、模式与能量激活状态等。
  • 添加 update_map_robot_data(),将对手位置从厘米尺度缩放为米并填充对手坐标输出。

哨兵交互组件(sentry_decision.cpp)

  • 新增 rmcs_core::referee::command::interaction::SentryDecision 组件(继承 rmcs_executor::Component 与 rclcpp::Node),发布 /referee/command/interaction/sentry_decision 主题。
  • 注册多个 referee 输入以控制哨兵决策标志与参数;读取节点参数 resend_rate 与 repeat_count 以配置重传行为。
  • 实现 32 位打包决策命令的计算、变更检测与重传调度逻辑:在计算命令变化时重置重复/重传状态,按 resend_interval_ 安排重发并在 repeat_count 用尽后停止;在节点未启用、无就绪请求或非哨兵机器人等条件下重置挂起状态并清除待发字段。

插件注册(plugins.xml)

  • 在 rmcs_core 的插件注册中新增 SentryDecision 的导出注册(base_class_type="rmcs_executor::Component"),使该组件可被插件系统加载。

验证

  • 在真实环境中已通过验证:doghole 步兵测试通过,哨兵测试通过。

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

Walkthrough

新增 GameRobotPosition、OpponentMapRobotData 与 SentryInfo;扩展 Status 注册与解码以发布更多游戏/盟军/对手/哨兵字段与地图事件子字段;新增 SentryDecision ROS2 Component 实现命令打包与重传,并在 plugins.xml 注册该组件。

变更内容

Referee 系统协议与哨兵扩展

层级 / 文件 说明
数据结构定义
rmcs_ws/src/rmcs_core/src/referee/status/field.hpp
新增 GameRobotPositionOpponentMapRobotDataSentryInfo 打包结构;移除了紧随 MapCommandstatic_assert
Status 成员与输出注册
rmcs_ws/src/rmcs_core/src/referee/status.cpp
构造函数与成员声明扩展:注册阶段/同步时间、盟军与对手位置输出、细粒度 HP/弹药/哨兵指标及地图事件子字段。
Status 帧处理和解码
rmcs_ws/src/rmcs_core/src/referee/status.cpp
扩展 process_frame() 调度以处理新增命令 ID(含 0x0101、0x0105、0x020B、0x020D),实现/修改多个 update_* 解码函数(含重复抑制、时戳镜像、坐标单位缩放)。
SentryDecision 组件实现
rmcs_ws/src/rmcs_core/src/referee/command/interaction/sentry_decision.cpp
新增 ROS2 Component:注册多路输入/输出与参数(resend_raterepeat_count),在更新周期缓存就绪状态、构造 32-bit 打包命令并按间隔/重复发送,含命令变更检测与重传状态管理与序列化写入。
插件注册
rmcs_ws/src/rmcs_core/plugins.xml
新增 <class> 注册:rmcs_core::referee::command::interaction::SentryDecisionbase_class_type="rmcs_executor::Component"

🎯 4 (Complex) | ⏱️ ~60 分钟

🐰 我把哨兵命令打包好,
把位置与状态都记牢;
解码分层又仔细,
重传依序不慌张,
插件一加,全链路跑。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main changes: updating referee protocol and adding sentry interaction functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/referee

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
rmcs_ws/src/rmcs_core/src/referee/status.cpp (2)

171-199: ⚡ Quick win

process_frame 的分支结构存在两条独立 if 链,建议改成单一 dispatch。

第 173-174 行 if (command_id == 0x0001) 是独立 if,而第 175 行起的 if (command_id == 0x0003) ... else if ... 是另一条链。本 PR 在该链中又新增了 0x0101/0x0105/0x020D/0x0303 等多个分支,后续如果有人在第二条链中漏写 else 或者补充 0x0001 同源处理,会立刻引入分支被吞掉的隐藏 bug。建议统一成单一 else if 链或 switch (command_id)

♻️ 建议改造
-        if (command_id == 0x0001)
-            update_game_status();
-        if (command_id == 0x0003)
-            update_game_robot_hp();
-        else if (command_id == 0x0101)
-            update_event_data();
-        else if (command_id == 0x0105)
-            update_dart_info();
-        else if (command_id == 0x0201)
-            update_robot_status();
-        else if (command_id == 0x0202)
-            update_power_heat_data();
-        else if (command_id == 0x0203)
-            update_robot_position();
-        else if (command_id == 0x0206)
-            update_hurt_data();
-        else if (command_id == 0x0207)
-            update_shoot_data();
-        else if (command_id == 0x0208)
-            update_bullet_allowance();
-        else if (command_id == 0x020B)
-            update_game_robot_position();
-        else if (command_id == 0x020D)
-            update_sentry_info();
-        else if (command_id == 0x0303)
-            update_map_command();
+        switch (command_id) {
+            case 0x0001: update_game_status(); break;
+            case 0x0003: update_game_robot_hp(); break;
+            case 0x0101: update_event_data(); break;
+            case 0x0105: update_dart_info(); break;
+            case 0x0201: update_robot_status(); break;
+            case 0x0202: update_power_heat_data(); break;
+            case 0x0203: update_robot_position(); break;
+            case 0x0206: update_hurt_data(); break;
+            case 0x0207: update_shoot_data(); break;
+            case 0x0208: update_bullet_allowance(); break;
+            case 0x020B: update_game_robot_position(); break;
+            case 0x020D: update_sentry_info(); break;
+            case 0x0303: update_map_command(); break;
+            default: break;
+        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rmcs_ws/src/rmcs_core/src/referee/status.cpp` around lines 171 - 199, The
current process_frame() has two separate if chains (a lone if for command_id ==
0x0001 and a separate if/else-if chain for other command_id values) which can
cause missed branches; refactor process_frame() to use a single dispatch (either
a unified else-if chain or a switch(command_id)) covering all handlers
(update_game_status, update_game_robot_hp, update_event_data, update_dart_info,
update_robot_status, update_power_heat_data, update_robot_position,
update_hurt_data, update_shoot_data, update_bullet_allowance,
update_game_robot_position, update_sentry_info, update_map_command) so each
command_id is handled exclusively and no branch can be inadvertently bypassed.

256-258: 💤 Low value

bool 赋值建议显式比较,避免隐式窄化。

*chassis_output_status_ = data.power_management_status & (1u << 1);unsigned 结果赋给 OutputInterface<bool>,虽然行为正确但部分编译器/静态扫描会警告隐式窄化,且其他位状态(底盘/枪口供电)未来若并列处理时容易写错。

♻️ 建议改造
-        *chassis_output_status_ = data.power_management_status & (1u << 1);
+        *chassis_output_status_ = (data.power_management_status & (1u << 1)) != 0;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rmcs_ws/src/rmcs_core/src/referee/status.cpp` around lines 256 - 258, The
assignment to OutputInterface<bool> chassis_output_status_ uses a raw unsigned
bitmask expression which can trigger implicit-narrowing warnings; change the
assignment in status.cpp so that *chassis_output_status_ is set to an explicit
boolean expression, e.g. evaluate (data.power_management_status & (1u << 1)) !=
0 (or use a named bit-test helper) instead of assigning the unsigned result
directly; update the nearby robot_chassis_power_limit_ usage only if needed but
ensure you reference chassis_output_status_, data.power_management_status, and
robot_chassis_power_limit_ when making the fix.
rmcs_ws/src/rmcs_core/src/referee/status/field.hpp (1)

7-104: ⚡ Quick win

建议为所有 packed 结构体补 static_assert(sizeof(...) == N)

MapCommand 已经有 static_assert(sizeof(MapCommand) == 12);(line 99),这种保护非常有效。建议把同样的 size 守卫加到 GameStatusGameRobotHpEventDataDartInfoRobotStatusPowerHeatDataBulletAllowanceGameRobotPositionSentryInfo 等所有用 reinterpret_cast<...&>(frame_.body.data) 解码的结构体上,后续协议升级时一旦字节数对不上能在编译期立即暴露,避免线上调试。

♻️ 示例
 struct __attribute__((packed)) SentryInfo {
     uint32_t sentry_info;
     uint16_t sentry_info_2;
 };
+static_assert(sizeof(SentryInfo) == 6);

对其他结构体按官方协议手册标定的字节数同步补充即可。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rmcs_ws/src/rmcs_core/src/referee/status/field.hpp` around lines 7 - 104, The
packed POD structs used for reinterpret_cast decoding (GameStatus, GameRobotHp,
EventData, DartInfo, RobotStatus, PowerHeatData, BulletAllowance,
GameRobotPosition, SentryInfo, etc.) lack compile-time size guards; add
static_assert(sizeof(StructName) == N) for each of those structs (using the
protocol-specified byte sizes) like the existing static_assert for MapCommand so
any size mismatch is caught at compile time; update each struct declaration to
include a corresponding static_assert with the correct expected size.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rmcs_ws/src/rmcs_core/src/referee/status.cpp`:
- Around line 214-227: The sentry-bit fields in update_sentry_info() are
misaligned with make_command(): adjust the bit shifts and masks in
update_sentry_info() so they exactly match make_command()'s layout
(bullet_exchange_value bits 2-12, remote_bullet_count bits 13-16,
remote_hp_count bits 17-20, mode bits 21-22, activate_energy_mechanism bit 23),
and add extraction for remote_hp_count, confirm_revive/exchange_instant_revive
at their proper bit positions instead of reading mode/activate from
sentry_info_2; update the variables sentry_exchanged_bullet,
sentry_remote_bullet_exchange_count, remote_hp_count, confirm_revive,
exchange_instant_revive, mode, and activate_energy_mechanism to use the
corrected shifts/masks and verify against the protocol doc.

---

Nitpick comments:
In `@rmcs_ws/src/rmcs_core/src/referee/status.cpp`:
- Around line 171-199: The current process_frame() has two separate if chains (a
lone if for command_id == 0x0001 and a separate if/else-if chain for other
command_id values) which can cause missed branches; refactor process_frame() to
use a single dispatch (either a unified else-if chain or a switch(command_id))
covering all handlers (update_game_status, update_game_robot_hp,
update_event_data, update_dart_info, update_robot_status,
update_power_heat_data, update_robot_position, update_hurt_data,
update_shoot_data, update_bullet_allowance, update_game_robot_position,
update_sentry_info, update_map_command) so each command_id is handled
exclusively and no branch can be inadvertently bypassed.
- Around line 256-258: The assignment to OutputInterface<bool>
chassis_output_status_ uses a raw unsigned bitmask expression which can trigger
implicit-narrowing warnings; change the assignment in status.cpp so that
*chassis_output_status_ is set to an explicit boolean expression, e.g. evaluate
(data.power_management_status & (1u << 1)) != 0 (or use a named bit-test helper)
instead of assigning the unsigned result directly; update the nearby
robot_chassis_power_limit_ usage only if needed but ensure you reference
chassis_output_status_, data.power_management_status, and
robot_chassis_power_limit_ when making the fix.

In `@rmcs_ws/src/rmcs_core/src/referee/status/field.hpp`:
- Around line 7-104: The packed POD structs used for reinterpret_cast decoding
(GameStatus, GameRobotHp, EventData, DartInfo, RobotStatus, PowerHeatData,
BulletAllowance, GameRobotPosition, SentryInfo, etc.) lack compile-time size
guards; add static_assert(sizeof(StructName) == N) for each of those structs
(using the protocol-specified byte sizes) like the existing static_assert for
MapCommand so any size mismatch is caught at compile time; update each struct
declaration to include a corresponding static_assert with the correct expected
size.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a364eb20-8452-435d-8c9d-6ddb3513aa90

📥 Commits

Reviewing files that changed from the base of the PR and between 5e83669 and b37d744.

📒 Files selected for processing (4)
  • rmcs_ws/src/rmcs_core/plugins.xml
  • rmcs_ws/src/rmcs_core/src/referee/command/interaction/sentry_decision.cpp
  • rmcs_ws/src/rmcs_core/src/referee/status.cpp
  • rmcs_ws/src/rmcs_core/src/referee/status/field.hpp

Comment thread rmcs_ws/src/rmcs_core/src/referee/status.cpp
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rmcs_ws/src/rmcs_core/src/referee/status.cpp (1)

360-378: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

删除 update_sentry_info() 后的孤立代码块。

第 360-378 行存在孤立代码,这些是 update_map_command() 的重复语句但不在任何函数体内,而是直接位于类定义作用域,会导致此文件成为无效的 C++。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rmcs_ws/src/rmcs_core/src/referee/status.cpp` around lines 360 - 378, There
is an orphaned block of code (appearing to be part of update_map_command()) left
outside any function after update_sentry_info(), causing invalid C++; remove
this stray block or reattach its logic into the proper function (e.g.
update_map_command()) so it is inside a method body, ensuring uses of
last_map_command_, has_last_map_command_, map_command_received_timestamp_,
map_command_event_* and related members remain valid and compiled; after moving
or deleting, run a build to confirm no unused/duplicate logic remains.
🧹 Nitpick comments (1)
rmcs_ws/src/rmcs_core/src/referee/status/field.hpp (1)

79-105: ⚡ Quick win

把重复的 MapCommand 断言改成新增协议结构体的尺寸断言。

Line 105 又断言了一次 MapCommand,但这次新增的 GameRobotPosition / SentryInfo 反而没有被尺寸锁定。status.cpp 里这两个 payload 都是按二进制结构体直接解析的,后续一旦有填充或字段调整,就会静默把协议解析搞偏。

可直接改成这样
 struct __attribute__((packed)) MapCommand {
     float target_position_x;
     float target_position_y;
     uint8_t cmd_keyboard;
     uint8_t target_robot_id;
     uint16_t cmd_source;
 };
 static_assert(sizeof(MapCommand) == 12);

 struct __attribute__((packed)) SentryInfo {
     uint32_t sentry_info;
     uint16_t sentry_info_2;
 };
-static_assert(sizeof(MapCommand) == 12);
+static_assert(sizeof(GameRobotPosition) == 40);
+static_assert(sizeof(SentryInfo) == 6);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rmcs_ws/src/rmcs_core/src/referee/status/field.hpp` around lines 79 - 105,
文件里重复写了 MapCommand 的静态断言,应该改为为新加的结构体也加上尺寸断言;在当前代码中保留
static_assert(sizeof(MapCommand) == 12) 并把第二个重复断言替换为
static_assert(sizeof(GameRobotPosition) == 40) 和
static_assert(sizeof(SentryInfo) == 6),以确保 GameRobotPosition、SentryInfo 和
MapCommand 在被按二进制解析时尺寸不发生静默变化(参考类型名 GameRobotPosition、SentryInfo、MapCommand 和现有
static_assert 使用位置)。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rmcs_ws/src/rmcs_core/src/referee/status.cpp`:
- Around line 344-358: The update_sentry_info function currently
reinterpret_casts frame_.body.data into SentryInfo and unpacks fields without
validating the received payload length; add a length check against
sizeof(SentryInfo) (e.g., verify frame_.body.size/length >= sizeof(SentryInfo))
before doing the reinterpret_cast and bit extraction, and if the check fails,
avoid writing the sentry outputs (or set them to safe defaults) so that
short/invalid 0x020D packets cannot write dirty bitfields into
*sentry_exchanged_bullet_, *sentry_remote_bullet_exchange_count_,
*sentry_can_confirm_free_revive_, *sentry_can_exchange_instant_revive_,
*sentry_instant_revive_cost_, *sentry_exchangeable_bullet_, *sentry_mode_, and
*sentry_energy_mechanism_activatable_; keep all decoding logic (shifts/masks)
only inside the guarded branch.
- Around line 293-304: update_game_robot_position() currently reinterpret_casts
frame_.body.data to GameRobotPosition without checking payload length for
message 0x020B; add the same payload-length guard used in update_map_command():
verify frame_.body.data_length >= sizeof(GameRobotPosition) (or >= 40) before
doing the reinterpret_cast and assigning to ally_hero_position_x_,
ally_hero_position_y_, ally_engineer_position_x_, ally_engineer_position_y_,
ally_infantry_1_position_x_, ally_infantry_1_position_y_,
ally_infantry_2_position_x_, and ally_infantry_2_position_y_; if the check
fails, skip updates (or set safe defaults) to avoid using leftover buffer data.

---

Outside diff comments:
In `@rmcs_ws/src/rmcs_core/src/referee/status.cpp`:
- Around line 360-378: There is an orphaned block of code (appearing to be part
of update_map_command()) left outside any function after update_sentry_info(),
causing invalid C++; remove this stray block or reattach its logic into the
proper function (e.g. update_map_command()) so it is inside a method body,
ensuring uses of last_map_command_, has_last_map_command_,
map_command_received_timestamp_, map_command_event_* and related members remain
valid and compiled; after moving or deleting, run a build to confirm no
unused/duplicate logic remains.

---

Nitpick comments:
In `@rmcs_ws/src/rmcs_core/src/referee/status/field.hpp`:
- Around line 79-105: 文件里重复写了 MapCommand 的静态断言,应该改为为新加的结构体也加上尺寸断言;在当前代码中保留
static_assert(sizeof(MapCommand) == 12) 并把第二个重复断言替换为
static_assert(sizeof(GameRobotPosition) == 40) 和
static_assert(sizeof(SentryInfo) == 6),以确保 GameRobotPosition、SentryInfo 和
MapCommand 在被按二进制解析时尺寸不发生静默变化(参考类型名 GameRobotPosition、SentryInfo、MapCommand 和现有
static_assert 使用位置)。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f7bec07-e224-43d3-933e-ebf8f50189ab

📥 Commits

Reviewing files that changed from the base of the PR and between b37d744 and 2a81eb2.

📒 Files selected for processing (3)
  • rmcs_ws/src/rmcs_core/plugins.xml
  • rmcs_ws/src/rmcs_core/src/referee/status.cpp
  • rmcs_ws/src/rmcs_core/src/referee/status/field.hpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • rmcs_ws/src/rmcs_core/plugins.xml

Comment thread rmcs_ws/src/rmcs_core/src/referee/status.cpp
Comment thread rmcs_ws/src/rmcs_core/src/referee/status.cpp
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rmcs_ws/src/rmcs_core/src/referee/command/interaction/sentry_decision.cpp`:
- Around line 120-123: The method is_sentry_robot() and similar accessors
currently dereference robot_id_ (and sentry_mode_) without checking readiness;
before dereferencing *robot_id_ or *sentry_mode_ call the input handle's ready()
(or equivalent) and return a safe default (false for is_sentry_robot(), and a
neutral/default enum value for sentry_mode_) when not ready; update
is_sentry_robot(), any accessor in the same block (lines around 137–153), and
any place that uses *robot_id_ or *sentry_mode_ to first check ready() and only
then dereference to avoid startup null/invalid access.

In `@rmcs_ws/src/rmcs_core/src/referee/status/field.hpp`:
- Around line 79-118: 为防止打包结构随编译器/ABI变化导致协议错位,在这些结构定义后加编译期尺寸校验:为
GameRobotPosition、MapCommand、OpponentMapRobotData 和 SentryInfo 分别添加
static_assert(sizeof(GameRobotPosition) == 40, "..."),
static_assert(sizeof(MapCommand) == 12, "..."),
static_assert(sizeof(OpponentMapRobotData) == 24, "...") 和
static_assert(sizeof(SentryInfo) == 6, "...")(将断言放在各 struct
定义之后或同一头文件合适位置,并提供简短错误信息以便诊断)。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c37f34a-987e-4160-9376-8caa1ef78249

📥 Commits

Reviewing files that changed from the base of the PR and between 2a81eb2 and 7deb136.

📒 Files selected for processing (4)
  • rmcs_ws/src/rmcs_core/plugins.xml
  • rmcs_ws/src/rmcs_core/src/referee/command/interaction/sentry_decision.cpp
  • rmcs_ws/src/rmcs_core/src/referee/status.cpp
  • rmcs_ws/src/rmcs_core/src/referee/status/field.hpp
✅ Files skipped from review due to trivial changes (1)
  • rmcs_ws/src/rmcs_core/plugins.xml
🚧 Files skipped from review as they are similar to previous changes (1)
  • rmcs_ws/src/rmcs_core/src/referee/status.cpp

Comment thread rmcs_ws/src/rmcs_core/src/referee/status/field.hpp
@gqsdjhh gqsdjhh closed this May 12, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in RMCS May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant