Conversation
|
⚡ Static analysis result ⚡ 🔴 cppcheck found 4 issues! Click here to see details.espp/components/adrc/include/adrc.hpp Lines 303 to 308 in bd97c2b !Line: 303 - performance: Function 'get_state()' should return member 'state_' by const reference. [returnByReference]
espp/components/adrc/include/adrc.hpp Lines 450 to 455 in bd97c2b !Line: 450 - performance: Function 'get_state()' should return member 'state_' by const reference. [returnByReference]
espp/components/adrc/include/adrc.hpp Lines 591 to 596 in bd97c2b !Line: 591 - performance: Function 'get_state()' should return member 'state_' by const reference. [returnByReference]
espp/components/adrc/include/adrc.hpp Lines 771 to 776 in bd97c2b !Line: 771 - performance: Function 'get_state()' should return member 'state_' by const reference. [returnByReference]
|
There was a problem hiding this comment.
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/adrccomponent (header-only logic inadrc.hppplus 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.ymlmatrix entry andupload_components.ymlupload 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 |
| * \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 |
| 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); |
Description
Motivation and Context
How has this been tested?
Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
Types of changes
Checklist:
Software
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.Hardware