Skip to content

Dev#21

Merged
llLeo306 merged 2 commits into
QDU-Robomaster:devfrom
Rui-Xiaoyu:dev
May 11, 2026
Merged

Dev#21
llLeo306 merged 2 commits into
QDU-Robomaster:devfrom
Rui-Xiaoyu:dev

Conversation

@Rui-Xiaoyu

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

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Introduce configurable biased power allocation for 3508 motor groups, adding support for reserve-based distribution while keeping existing allocation as the default path.

New Features:

  • Add AllocationBias3508 configuration struct and setter to control reserve fractions and per-motor allocation bias for 3508 motors.

Enhancements:

  • Extend 3508 power allocation logic to optionally reserve a portion of available power and redistribute the remainder with biased weighting while preserving current behavior when bias is disabled.
  • Improve inline documentation and comments around 3508 power modeling, residual calculation, and RLS parameter identification for better maintainability.

@sourcery-ai

sourcery-ai Bot commented May 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds configurable biased power allocation for 3508 motor groups, introducing a two-stage reserve-then-distribute algorithm while preserving the existing mixed error/ratio scheme as the default, and documents parts of the RLS-based power model parameters.

File-Level Changes

Change Details Files
Introduce configurable allocation bias mechanism for 3508 motors, with a reserve power pool and weighted residual distribution on top of the existing allocation algorithm.
  • Add AllocationBias3508 struct to configure reserve fraction, per-motor reserve weights, and per-motor allocation weight scales with sensible defaults
  • Store allocation bias state inside PowerControl and protect updates with the existing mutex
  • Implement SetAllocationBias3508 to clamp reserve_fraction to [0,1], floor reserve_weight to non-negative, and default allocation_weight_scale to 1.0 when unset
  • Branch power distribution in CalculatePowerControlParam to use either the original mixed error/required-power weights or the new biased path when enabled
  • In the biased path, compute a reserve power pool shared among positive-power motors, allocate per-motor reserve quotas by reserve_weight, then redistribute remaining available power using error/requirement-based weights scaled by allocation_weight_scale
  • Ensure per-motor final power quota does not exceed its own requested motor power and fall back to previous current outputs for non-positive-power or no-demand motors
PowerControl.hpp
Refine power model documentation and comments related to RLS identification and motor power usage.
  • Clarify comment that measured chassis power is used to correct the 3508 power model parameters
  • Adjust comments to explain that negative power contributes to increasing available power
  • Add comments on RLS<2> and the samples_3508_/params_3508_ matrices to document their roles in identifying quadratic loss model parameters
  • Add member allocation_bias_3508_ to PowerControl with a descriptive comment
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:

  • The biased and unbiased allocation paths duplicate a lot of weight/quotas logic; consider extracting common computations (e.g., error/prop weight calculation and quota application) into helper functions to reduce complexity and chances of divergence between the two paths.
  • The temporary arrays reserve_power_3508, residual_power_3508, and weighted_residual_3508 are large stack allocations repeated every call; consider using std::array as members (or reusing existing buffers) to avoid per-call stack pressure and make bounds handling clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The biased and unbiased allocation paths duplicate a lot of weight/quotas logic; consider extracting common computations (e.g., error/prop weight calculation and quota application) into helper functions to reduce complexity and chances of divergence between the two paths.
- The temporary arrays `reserve_power_3508`, `residual_power_3508`, and `weighted_residual_3508` are large stack allocations repeated every call; consider using `std::array` as members (or reusing existing buffers) to avoid per-call stack pressure and make bounds handling 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 7b5b7fd into QDU-Robomaster:dev May 11, 2026
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