Skip to content

Dev#15

Merged
llLeo306 merged 7 commits into
masterfrom
dev
May 8, 2026
Merged

Dev#15
llLeo306 merged 7 commits into
masterfrom
dev

Conversation

@Gcgc4514

@Gcgc4514 Gcgc4514 commented May 8, 2026

Copy link
Copy Markdown
Collaborator

加入哨兵相关发包,更新Launcher pack定义

Summary by Sourcery

Extend referee data packs and add sentry command helpers.

New Features:

  • Include robot buff, launcher data, and dart client info in the launcher data pack published to modules.
  • Provide a dedicated chassis data pack including chassis power buffer for downstream consumers.
  • Add sentry command helpers for bullet purchase, HP purchase, resurrection confirmation, and mode switching, and a sender for the sentry decision packet.

Enhancements:

  • Refine sentry data pack fields to use explicit Referee status and game status types.
  • Introduce a sentry state enum to represent different sentry modes.
  • Apply minor formatting and memory-handling cleanups in referee communication code.
  • Remove unused startup printf from the CI build test harness.

Build:

  • Update CI build workflow test program by removing an extraneous debug print.

@sourcery-ai

sourcery-ai Bot commented May 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors 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 pack

sequenceDiagram
    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
Loading

Updated class diagram for Referee launcher, chassis, and sentry packs

classDiagram
    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
Loading

File-Level Changes

Change Details Files
Extend LauncherPack and ChassisPack payloads to publish richer robot state data from referee frames.
  • Replace LauncherPack single heat field with RobotStatus, RobotBuff, LauncherData, and DartClient to expose more launcher-related data to subscribers.
  • Introduce ChassisPack struct dedicated to chassis consumers, carrying RobotStatus and chassis power buffer.
  • Update pack publication logic to fill the new LauncherPack and ChassisPack fields from internal referee data.
Referee.hpp
Add sentry posture enum, sentry decision setters, and a sender for the sentry decision command packet.
  • Define State enum for sentry posture/mode (ATTACH, DEFEND, GUERRILLA).
  • Update SentryPack to use fully qualified RobotStatus and GameStatus from Referee.
  • Add helper methods (SetNeedBullet, SetConfirmRevival, SetBulletRemote, SetHPRemote, SetRevivalRemote, SetSwitchMode) to manipulate sentry_dec_data fields for bullets, HP, resurrection, and posture.
  • Add SendSentryPack helper that wraps SendStudentCmd with the sentry decision data payload.
Referee.hpp
Minor refactors and cleanup of communication and utility code in Referee and build workflow.
  • Normalize formatting/indentation of SendFrame, SendStudentCmd, UI send helpers, and FindHeader for readability.
  • Replace LibXR::Memory::FastSet with memset for robot_interaction_data.user_data zeroing while keeping FastCopy for payload copy.
  • Remove a template test printf from the CI build harness main to avoid extra console output during builds.
  • Remove a stale TODO comment on operation timeout initialization.
Referee.hpp
.github/workflows/build.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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::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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread Referee.hpp
Comment on lines +1029 to +1030
void SetNeedBullet(uint8_t need_bullet){
this->data_.sentry_dec_data.buy_bullet_num += need_bullet;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@llLeo306 llLeo306 merged commit 2349e42 into master May 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants