Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and add sweeping compatibility #180

Merged
merged 4 commits into from
Dec 22, 2024
Merged

fix and add sweeping compatibility #180

merged 4 commits into from
Dec 22, 2024

Conversation

Frix-x
Copy link
Owner

@Frix-x Frix-x commented Dec 22, 2024

Summary by Sourcery

Update resonance testing to support Klipper's new sweeping method and maintain compatibility with the old pulse-only method.

New Features:

  • Introduce a sweeping vibration test method, which superimposes a slow motion sweep on top of the usual back-and-forth pulses, to filter out random motor and mechanical noise.

Tests:

  • Update the resonance test manager to handle both the old and new Klipper logic.

* added compatibility with sweeping test

* fix res_tester missing

* fixed compatibility with Klipper < v0.12.0-239

* added documentation about sweeping mode
Copy link

sourcery-ai bot commented Dec 22, 2024

Reviewer's Guide by Sourcery

This pull request introduces sweeping compatibility to ShakeTune by updating the resonance test methods to support both the old pulse-only method and the new sweeping method. It also refactors the resonance testing logic into a dedicated ResonanceTestManager class to handle both old and new Klipper versions.

Class diagram showing resonance testing compatibility changes

classDiagram
    class ResonanceTester {
        +test [old]
        +generator [new]
        +probe_points [new]
    }

    class Test {
        +min_freq
        +max_freq
        +accel_per_hz
        +get_start_test_points()
    }

    class VibrationGenerator {
        +min_freq
        +max_freq
        +accel_per_hz
    }

    ResonanceTester -- Test : has >  
    ResonanceTester -- VibrationGenerator : has >

    note for ResonanceTester "Supports both old and new Klipper versions"
    note for Test "Used in old Klipper (pre Dec 6, 2024)"
    note for VibrationGenerator "Used in new Klipper (post Dec 6, 2024)"
Loading

State diagram for resonance testing modes

stateDiagram-v2
    [*] --> CheckKlipperVersion
    CheckKlipperVersion --> OldVersion: has test attribute
    CheckKlipperVersion --> NewVersion: has generator attribute

    state OldVersion {
        [*] --> PulseOnlyTest
        PulseOnlyTest --> GetTestPoints
        GetTestPoints --> ExecuteTest
    }

    state NewVersion {
        [*] --> SweepingTest
        SweepingTest --> GetProbePoints
        GetProbePoints --> ExecuteTest
    }

    OldVersion --> [*]
    NewVersion --> [*]
Loading

File-Level Changes

Change Details Files
Refactored resonance testing logic into the ResonanceTestManager class.
  • Created the ResonanceTestManager class to encapsulate resonance testing logic.
  • Handles both old and new Klipper versions using the is_old_klipper property.
  • Implemented vibrate_axis and vibrate_axis_at_static_freq methods in the new class.
  • Moved the core vibration generation logic to separate generator classes: BaseVibrationGenerator, SweepingVibrationGenerator, and StaticFrequencyVibrationGenerator.
  • Updated the vibrate_axis and vibrate_axis_at_static_freq functions to use the new ResonanceTestManager class.
  • Added Sweeping test support
shaketune/helpers/resonance_test.py
Updated command implementations to use the new resonance testing logic.
  • Updated the commands to use the new vibrate_axis function which uses the ResonanceTestManager.
  • Added support for getting default parameter values from both old and new Klipper versions.
  • Updated the commands to pass the res_tester object to the vibrate_axis function.
  • Added documentation about the sweeping test
shaketune/commands/axes_shaper_calibration.py
shaketune/commands/compare_belts_responses.py
shaketune/commands/excitate_axis_at_freq.py
Added documentation for the sweeping test.
  • Added a new section explaining the sweeping test and its benefits.
  • Explained the difference between the sweeping and pulse-only tests.
  • Provided guidance on when to use each test type.
  • Added documentation about the sweeping test
docs/is_tuning_generalities.md

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Frix-x - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

shaketune/commands/axes_shaper_calibration.py Show resolved Hide resolved
shaketune/helpers/resonance_test.py Show resolved Hide resolved
docs/is_tuning_generalities.md Outdated Show resolved Hide resolved
shaketune/helpers/resonance_test.py Outdated Show resolved Hide resolved
Frix-x and others added 2 commits December 22, 2024 21:54
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@Frix-x Frix-x merged commit 822f147 into develop Dec 22, 2024
9 checks passed
@Frix-x Frix-x deleted the fix-sweeping-compat branch December 22, 2024 21:12
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