Skip to content

Dev#14

Merged
llLeo306 merged 4 commits into
QDU-Robomaster:devfrom
Rui-Xiaoyu:dev
Mar 26, 2026
Merged

Dev#14
llLeo306 merged 4 commits into
QDU-Robomaster:devfrom
Rui-Xiaoyu:dev

Conversation

@Rui-Xiaoyu

@Rui-Xiaoyu Rui-Xiaoyu commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Reformat RLS and power control code and adjust the power control public API to expose capacitor energy instead of percentage.

New Features:

  • Expose capacitor energy from PowerControl via a new getter, replacing the previous percentage-based accessor.

Enhancements:

  • Improve code formatting and include ordering in RLS and PowerControl to match style guidelines.

@sourcery-ai

sourcery-ai Bot commented Mar 25, 2026

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

Reviewer's Guide

This PR applies code style cleanups in the RLS update routine, normalizes include ordering, tidies loop body indentation for 3508 motor power calculations, and renames a power status accessor from percentage to capacitor energy to better reflect its semantics.

Class diagram for updated RLS and PowerControl interfaces

classDiagram
  class RLS {
    +Update(sample_vector : ParamVector, actual_output : float) const ParamVector&
    -gainvector_ : ParamVector
    -transmatrix_ : Matrix
    -paramsvector_ : ParamVector
    -lambda_ : float
  }

  class LibXR_Application {
  }

  class SuperPower {
    +GetCapEnergy() float
    +IsOnline() bool
  }

  class PowerControl {
    +GetMeasuredPower() float
    +GetCapEnergy() float
    +IsOnline() bool
    -superpower_ : SuperPower*
    -motor_count_3508_ : int
    -samples_3508_ : Matrix
    -output_current_3508_ : float[]
    -rotorspeed_rpm_3508_ : float[]
    -kt_3508_ : float
  }

  PowerControl --|> LibXR_Application
  PowerControl --> SuperPower
Loading

File-Level Changes

Change Details Files
Reformat the RLS::Update method for readability without changing its logic.
  • Reflow the computation of gainvector_ into a multi-line expression with clearer operator grouping.
  • Reindent the parameter update expression for paramsvector_.
  • Reformat the transmatrix_ update into a multi-line expression while preserving the original recursive least squares math.
  • Fix comment indentation and alignment in the Update method documentation block.
RLS.hpp
Normalize includes, loop indentation, and accessor naming in power control code.
  • Move Eigen/Core include above standard library headers to comply with preferred include ordering.
  • Adjust indentation in the 3508 motor loop when accumulating sample terms to match project style.
  • Change the public accessor from GetPercent() to GetCapEnergy() and update its implementation to call superpower_->GetCapEnergy() instead of GetPercentage().
PowerControl.hpp

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 left some high level feedback:

  • In RLS::Update, the nested expression for gainvector_ is now quite long; consider extracting the scalar denominator and intermediate (sample_vector.transpose() * transmatrix_ * sample_vector)(0, 0) into named variables to improve readability and make the update formula easier to verify.
  • Changing GetPercent() to GetCapEnergy() and switching from GetPercentage() to GetCapEnergy() in PowerControl alters the public API and semantics; if this class is used externally, consider keeping the old method as a wrapper or clearly separating the two accessors to avoid breaking existing callers and to make the intent of each clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `RLS::Update`, the nested expression for `gainvector_` is now quite long; consider extracting the scalar denominator and intermediate `(sample_vector.transpose() * transmatrix_ * sample_vector)(0, 0)` into named variables to improve readability and make the update formula easier to verify.
- Changing `GetPercent()` to `GetCapEnergy()` and switching from `GetPercentage()` to `GetCapEnergy()` in `PowerControl` alters the public API and semantics; if this class is used externally, consider keeping the old method as a wrapper or clearly separating the two accessors to avoid breaking existing callers and to make the intent of each clearer.

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.

@llLeo306 llLeo306 merged commit 9080a7d into QDU-Robomaster:dev Mar 26, 2026
1 of 2 checks 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