Conversation
Reviewer's GuideRefactors referee data packs to expose richer launcher, chassis, and sentry information (including sentry decision commands) and performs small cleanup of I/O and memory utilities. Sequence diagram for sending updated sentry decision packsequenceDiagram
actor SentryController
participant Referee
participant UART
SentryController->>Referee: SetNeedBullet(need_bullet)
Referee->>Referee: data_.sentry_dec_data.buy_bullet_num += need_bullet
SentryController->>Referee: SetConfirmRevival(revival)
Referee->>Referee: data_.sentry_dec_data.confirm_resurrection = revival
SentryController->>Referee: SetBulletRemote(bullet_number)
Referee->>Referee: data_.sentry_dec_data.remote_buy_bullet_times += 1
Referee->>Referee: data_.sentry_dec_data.buy_bullet_num += bullet_number
SentryController->>Referee: SetHPRemote()
Referee->>Referee: data_.sentry_dec_data.romote_buy_hp_times += 1
SentryController->>Referee: SetRevivalRemote(revival)
Referee->>Referee: data_.sentry_dec_data.buy_resurrection = revival
SentryController->>Referee: SetSwitchMode(state)
Referee->>Referee: data_.sentry_dec_data.current_state = (uint32_t)state
SentryController->>Referee: SendSentryPack()
Referee->>Referee: SendStudentCmd(REF_STDNT_CMD_ID_SENTRY_CMD, GetRobotID(), 0x8080, data_.sentry_dec_data)
Referee->>Referee: SendFrame(cmd_id, payload, PAYLOAD_LEN)
Referee->>UART: write(serial_frame)
UART-->>Referee: transmission complete
Updated class diagram for Referee launcher, chassis, and sentry packsclassDiagram
class Referee {
+LauncherPack lp_
+ChassisPack cp_
+SentryPack sp_
+RefereeData data_
+void SetNeedBullet(uint8_t need_bullet)
+void SetConfirmRevival(bool revival)
+void SetBulletRemote(uint8_t bullet_number)
+void SetHPRemote()
+void SetRevivalRemote(bool revival)
+void SetSwitchMode(State state)
+void SendSentryPack()
+LibXR__ErrorCode SendFrame(CommandID cmd_id, const void* payload, uint16_t PAYLOAD_LEN)
+LibXR__ErrorCode SendStudentCmd(CMDID data_cmd_id, uint16_t sender_id, uint16_t receiver_id, PayloadType payload)
}
class LauncherPack {
+RobotStatus rs
+RobotBuff rb
+LauncherData ld
+DartClient dc
}
class ChassisPack {
+RobotStatus rs
+uint16_t power_buffer
}
class SentryPack {
+RobotStatus rs
+GameStatus gs
}
class State {
<<enumeration>>
ATTACH = 0
DEFEND = 1
GUERRILLA = 2
}
class RefereeData {
+RobotStatus robot_status
+RobotBuff robot_buff
+LauncherData launcher_data
+DartClient dart_client
+PowerHeat power_heat
+GameStatus game_status
+SentryDecisionData sentry_dec_data
}
class SentryDecisionData {
+uint8_t buy_bullet_num
+bool confirm_resurrection
+uint8_t remote_buy_bullet_times
+uint8_t romote_buy_hp_times
+bool buy_resurrection
+uint32_t current_state
}
Referee *-- LauncherPack
Referee *-- ChassisPack
Referee *-- SentryPack
Referee *-- RefereeData
RefereeData *-- SentryDecisionData
RefereeData *-- RobotStatus
RefereeData *-- RobotBuff
RefereeData *-- LauncherData
RefereeData *-- DartClient
RefereeData *-- PowerHeat
RefereeData *-- GameStatus
LauncherPack *-- RobotStatus
LauncherPack *-- RobotBuff
LauncherPack *-- LauncherData
LauncherPack *-- DartClient
ChassisPack *-- RobotStatus
SentryPack *-- RobotStatus
SentryPack *-- GameStatus
Referee .. State : uses
Referee .. SentryDecisionData : modifies
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new Sentry decision helpers (
SetNeedBullet,SetBulletRemote,SetHPRemote, etc.) all use+=/++semantics; if these fields represent absolute commands rather than cumulative deltas you may want to assign instead or at least document that they are intentionally accumulating and consider guarding against overflow. - You replaced
LibXR::Memory::FastSetwithmemsetforrobot_ineraction_data.user_data; if the project prefers the LibXR memory utils for portability/performance, consider keepingFastSetfor consistency with surrounding code. - In the new Sentry API comments, one
@paramline (@param 是否整活) is missing the parameter name and some comments are slightly ambiguous; aligning parameter names and clarifying behavior (e.g., what each state inStatepractically means) would make the new API easier to use correctly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new Sentry decision helpers (`SetNeedBullet`, `SetBulletRemote`, `SetHPRemote`, etc.) all use `+=`/`++` semantics; if these fields represent absolute commands rather than cumulative deltas you may want to assign instead or at least document that they are intentionally accumulating and consider guarding against overflow.
- You replaced `LibXR::Memory::FastSet` with `memset` for `robot_ineraction_data.user_data`; if the project prefers the LibXR memory utils for portability/performance, consider keeping `FastSet` for consistency with surrounding code.
- In the new Sentry API comments, one `@param` line (`@param 是否整活`) is missing the parameter name and some comments are slightly ambiguous; aligning parameter names and clarifying behavior (e.g., what each state in `State` practically means) would make the new API easier to use correctly.
## Individual Comments
### Comment 1
<location path="Referee.hpp" line_range="1029-1030" />
<code_context>
- RobotStatus rs; /* 等级和功率上限 */
- uint16_t power_buffer; /* 底盘缓冲能量,单位 J */
- };
+ void SetNeedBullet(uint8_t need_bullet){
+ this->data_.sentry_dec_data.buy_bullet_num += need_bullet;
+ }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Using '+=' here may not match the documented 'set' semantics and risks unbounded accumulation.
The docstring says this API sets the bullet count ("设置…值"), but the implementation adds to `buy_bullet_num`. In periodic or looped calls this can cause unintended growth. Please either switch to assignment (`=`) to match the documented semantics, or clearly document that this method is additive and enforce bounds consistent with the protocol limits.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| void SetNeedBullet(uint8_t need_bullet){ | ||
| this->data_.sentry_dec_data.buy_bullet_num += need_bullet; |
There was a problem hiding this comment.
issue (bug_risk): Using '+=' here may not match the documented 'set' semantics and risks unbounded accumulation.
The docstring says this API sets the bullet count ("设置…值"), but the implementation adds to buy_bullet_num. In periodic or looped calls this can cause unintended growth. Please either switch to assignment (=) to match the documented semantics, or clearly document that this method is additive and enforce bounds consistent with the protocol limits.
加入哨兵相关发包,更新Launcher pack定义
Summary by Sourcery
Extend referee data packs and add sentry command helpers.
New Features:
Enhancements:
Build: