Skip to content

feat(adrc): Add Active Disturbance Rejection Control (ADRC) component#627

Open
finger563 wants to merge 1 commit into
mainfrom
feat/adrc
Open

feat(adrc): Add Active Disturbance Rejection Control (ADRC) component#627
finger563 wants to merge 1 commit into
mainfrom
feat/adrc

Conversation

@finger563
Copy link
Copy Markdown
Contributor

Description

Motivation and Context

How has this been tested?

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

Hardware

  • I have updated the design files (schematic, board, libraries).
  • I have attached the PDFs of the SCH / BRD to this PR
  • I have updated the design output (GERBER, BOM) files.

Copilot AI review requested due to automatic review settings May 30, 2026 20:42
@github-actions
Copy link
Copy Markdown

⚡ Static analysis result ⚡

🔴 cppcheck found 4 issues! Click here to see details.

State get_state() const { return state_; }
/// Get the active configuration.
/// @return Current configuration.
const Config &get_config() const { return config_; }

!Line: 303 - performance: Function 'get_state()' should return member 'state_' by const reference. [returnByReference]

State get_state() const { return state_; }
/// Get the active configuration.
/// @return Current configuration.
const Config &get_config() const { return config_; }

!Line: 450 - performance: Function 'get_state()' should return member 'state_' by const reference. [returnByReference]

State get_state() const { return state_; }
/// Get the active configuration.
/// @return Current configuration.
const Config &get_config() const { return config_; }

!Line: 591 - performance: Function 'get_state()' should return member 'state_' by const reference. [returnByReference]

State get_state() const { return state_; }
/// Get the active configuration.
/// @return Current configuration.
const Config &get_config() const { return config_; }

!Line: 771 - performance: Function 'get_state()' should return member 'state_' by const reference. [returnByReference]


Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new adrc component providing Active Disturbance Rejection Control utilities: a Han tracking differentiator and four ADRC controllers (linear and Han nonlinear, first- and second-order), together with an example application and the corresponding documentation and CI wiring.

Changes:

  • New components/adrc component (header-only logic in adrc.hpp plus stub .cpp, CMake, manifest, README, example).
  • Documentation added: doc/en/adrc.rst, doc/en/adrc_example.md, Doxyfile entries, and index entry.
  • CI wiring: build.yml matrix entry and upload_components.yml upload entry.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
components/adrc/include/adrc.hpp Core ADRC classes (TD + 4 controllers)
components/adrc/src/adrc.cpp Empty translation unit including the header
components/adrc/CMakeLists.txt Component registration requiring base_component
components/adrc/idf_component.yml IDF component manifest
components/adrc/README.md Component-level overview
components/adrc/example/CMakeLists.txt Example project cmake
components/adrc/example/README.md Example overview
components/adrc/example/main/CMakeLists.txt Example main component registration
components/adrc/example/main/adrc_example.cpp Simulated plants exercising all 4 controllers
doc/Doxyfile Adds adrc header and example to Doxygen INPUT/EXAMPLE_PATH
doc/en/index.rst Adds adrc entry to docs toctree
doc/en/adrc.rst Long-form ADRC documentation and tuning guide
doc/en/adrc_example.md Includes the example README
.github/workflows/build.yml Adds ADRC example to CI matrix (esp32)
.github/workflows/upload_components.yml Adds ADRC to component upload list

Comment on lines +101 to +108
* \section adrc_ex1 Linear First-Order ADRC Example
* \snippet adrc_example.cpp adrc linear first order example
* \section adrc_ex2 Linear Second-Order ADRC Example
* \snippet adrc_example.cpp adrc linear second order example
* \section adrc_ex3 Han First-Order ADRC Example
* \snippet adrc_example.cpp adrc han first order example
* \section adrc_ex4 Han Second-Order ADRC Example
* \snippet adrc_example.cpp adrc han second order example
Comment on lines +711 to +722
float update(float reference, float reference_rate, float measurement, float dt) {
std::lock_guard<std::recursive_mutex> lk(mutex_);
if (dt <= 0.0f) {
return state_.output;
}

auto td_state = config_.use_tracking_differentiator
? tracking_differentiator_.update(reference, dt)
: HanTrackingDifferentiator::State{
.position = reference,
.rate = reference_rate,
};

state_.measurement = measurement;
state_.reference = reference;
state_.z1 += dt * (state_.z2 - beta1 * error + config_.b0 * state_.output);
@finger563 finger563 self-assigned this May 30, 2026
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