Add configure() overload to set the initial LPF state - #657
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #657 +/- ##
==========================================
+ Coverage 83.60% 83.78% +0.17%
==========================================
Files 31 32 +1
Lines 2202 2232 +30
Branches 126 128 +2
==========================================
+ Hits 1841 1870 +29
Misses 277 277
- Partials 84 85 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds an overload to control_toolbox::LowPassFilter::configure() that allows seeding the filter’s internal state from a known initial value, enabling deterministic startup behavior instead of implicitly seeding from the first update() input.
Changes:
- Add
configure(const T& initial_state)overload and internalinitialize_state()helper to seed the filter state. - Update
update()first-call initialization code to use the sharedinitialize_state()helper. - Add new unit tests covering the new behavior for
double,std::vector<double>, andgeometry_msgs::msg::WrenchStamped, and wire them into CMake.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| control_toolbox/test/low_pass_filter_tests.cpp | Adds direct unit tests validating seeded vs unseeded first-update behavior across supported types. |
| control_toolbox/include/control_toolbox/low_pass_filter.hpp | Introduces configure(initial_state) and a shared initialize_state() helper; updates first-update init to reuse it. |
| control_toolbox/CMakeLists.txt | Registers and links the new low_pass_filter_tests target in the test build. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
christophfroehlich
left a comment
There was a problem hiding this comment.
LGTM, but please update the docstring as suggested by copilot. btw as this is header-only, I think we also can backport this to other stable distros.
|
Docstring updated, thanks. |
Description
LowPassFilteralways initializes its state from the firstupdate()input, so there'sno way to start it from a known value.
This PR adds a
configure(const T & initial_state)overload that seeds the state: the firstupdate()returnsinitial_stateand the filter converges towards the input from there.Fixes #643
Is this user-facing behavior change?
Yes, additive only. Existing
configure()calls behave exactly as before.Did you use Generative AI?
Implementation written by hand. Claude Code (Opus 5) reviewed it and helped write the unit tests.
Additional Information
The new tests cover all three supported types (
double,std::vector<double>,WrenchStamped). These are the first direct unit tests ofcontrol_toolbox::LowPassFilter;the existing ones only reach it through the plugin.
TODOs
To send us a pull request, please:
colcon testandpre-commit run(requires you to install pre-commit bypip3 install pre-commit)