Skip to content

Fix#4

Open
Rui-Xiaoyu wants to merge 1 commit into
QDU-Robomaster:devfrom
Rui-Xiaoyu:fix
Open

Fix#4
Rui-Xiaoyu wants to merge 1 commit into
QDU-Robomaster:devfrom
Rui-Xiaoyu:fix

Conversation

@Rui-Xiaoyu

@Rui-Xiaoyu Rui-Xiaoyu commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Update VT13 RC parsing to use fully-qualified LibXR error codes and adjust CI build configuration and sample code for the XRobot module template.

Bug Fixes:

  • Correct VT13 RC parsing return types and checks to use LibXR::ErrorCode consistently.
  • Fix VT13 gimbal yaw mapping by removing the inverted sign when translating RC input.

Build:

  • Bump the CI test project CMake C++ standard requirement from C++17 to C++20.

CI:

  • Update the CI workflow's embedded sample program to use the new LibXR::STDIO::Printf invocation syntax.

@sourcery-ai

sourcery-ai Bot commented May 1, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Qualifies VT13 error codes with the LibXR namespace, corrects VT13 gimbal yaw sign handling, and updates the CI build example to use C++20 and a new LibXR::STDIO::Printf signature.

Class diagram for VT13 ParseRC and related types

classDiagram
class VT13 {
  +LibXR_ErrorCode ParseRC(const uint8_t* raw_data, CMD_Data& output_data)
}

class CMD_Data {
}

class LibXR_ErrorCode {
  <<enum>>
  OK
  PTR_NULL
  CHECK_ERR
}

VT13 ..> CMD_Data : outputs
VT13 ..> LibXR_ErrorCode : returns
Loading

Flow diagram for VT13 RC frame parsing and yaw mapping

flowchart TD
  A["UART loop receives RX_BUFFER"] --> B{"LibXR::ErrorCode::OK from uart_->Read?"}
  B -- "No" --> A
  B -- "Yes" --> C["Iterate rx_buffer and detect frame"]
  C --> D{"Complete frame detected?"}
  D -- "No" --> A
  D -- "Yes" --> E["Call ParseRC(frame_buffer, rc_data)"]
  E --> F{"ParseRC returns LibXR::ErrorCode::OK?"}
  F -- "No" --> A
  F -- "Yes" --> G["Update last_time_ with Timebase::GetMilliseconds"]
  G --> H["Map rc_data to CMD::Data output_data"]
  H --> I{"Mouse control mode?"}
  I -- "No" --> J["Use other mapping branch"]
  I -- "Yes" --> K["Set output_data.gimbal.pit = curr_rc.y * MOUSE_SCALER"]
  K --> L["Set output_data.gimbal.yaw = curr_rc.x * MOUSE_SCALER (positive sign)"]
  L --> M["Set remaining fields and save last_data_"]
  M --> A
Loading

File-Level Changes

Change Details Files
Align VT13 error handling with LibXR::ErrorCode and adjust return values accordingly.
  • Replaced uses of bare ErrorCode::OK with LibXR::ErrorCode::OK in UART read handling and ParseRC call sites.
  • Updated ParseRC to return LibXR::ErrorCode instead of ErrorCode, including all early-return error paths.
  • Ensured all ParseRC error paths (null pointer, header check, CRC check, range check) return the appropriately namespaced LibXR error codes and that success returns LibXR::ErrorCode::OK.
VT13.hpp
Fix VT13 RC parsing behavior for gimbal yaw axis.
  • Removed the negation on gimbal yaw assignment so yaw now follows the same sign convention as the input RC x-axis.
  • Left pitch and roll mappings unchanged while keeping chassis outputs zeroed in mouse-mode mapping.
VT13.hpp
Update CI example program and CMake configuration for new LibXR STDIO API and C++20.
  • Changed the LibXR::STDIO::Printf call in the CI test main.cpp snippet to use the new templated-style invocation with the string passed as a template parameter rather than a function argument.
  • Bumped the CMake C++ standard in the GitHub Actions workflow example from C++17 to C++20 to match library requirements.
.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 change from LibXR::STDIO::Printf("...") to LibXR::STDIO::Printf<"..."]() in the CI test program is almost certainly invalid C++ and/or not the intended API usage; please verify the correct way to call Printf and adjust accordingly.
  • The sign change on gimbal.yaw will invert the yaw control direction relative to previous behavior; if this is intentional, consider adding a brief comment explaining the convention so future changes don’t accidentally flip it back.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The change from `LibXR::STDIO::Printf("...")` to `LibXR::STDIO::Printf<"..."]()` in the CI test program is almost certainly invalid C++ and/or not the intended API usage; please verify the correct way to call `Printf` and adjust accordingly.
- The sign change on `gimbal.yaw` will invert the yaw control direction relative to previous behavior; if this is intentional, consider adding a brief comment explaining the convention so future changes don’t accidentally flip it back.

## Individual Comments

### Comment 1
<location path=".github/workflows/build.yml" line_range="34" />
<code_context>
           int main() {
               LibXR::PlatformInit();
-              LibXR::STDIO::Printf("This is XRobot Module Template Test\n");
+              LibXR::STDIO::Printf<"This is XRobot Module Template Test\n">();
               LibXR::HardwareContainer hw;
               XRobotMain(hw);
</code_context>
<issue_to_address>
**issue (bug_risk):** The new Printf usage with template syntax is likely invalid C++ and should remain a normal function call.

Using `Printf<"...">()` makes the string a non-type template parameter, which is not valid in standard C++ and will not compile unless `Printf` is a very unusual custom template. This should remain a regular call, e.g. `LibXR::STDIO::Printf("This is XRobot Module Template Test\n");` or whatever the correct API overload is.
</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.

int main() {
LibXR::PlatformInit();
LibXR::STDIO::Printf("This is XRobot Module Template Test\n");
LibXR::STDIO::Printf<"This is XRobot Module Template Test\n">();

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): The new Printf usage with template syntax is likely invalid C++ and should remain a normal function call.

Using Printf<"...">() makes the string a non-type template parameter, which is not valid in standard C++ and will not compile unless Printf is a very unusual custom template. This should remain a regular call, e.g. LibXR::STDIO::Printf("This is XRobot Module Template Test\n"); or whatever the correct API overload is.

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.

1 participant