-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
added sweeping compatibility #179
Conversation
Reviewer's Guide by SourceryThis pull request introduces sweeping compatibility to the resonance tester, enabling a new vibration test mode that adds a slow sweep motion to the existing pulse test. This helps to reduce noise and isolate the primary resonance frequency, especially useful for less rigid machines. It also includes a static frequency vibration generator for maintaining a fixed vibration frequency over a specified duration. Sequence diagram for resonance testing with sweep modesequenceDiagram
participant User
participant Printer
participant ResonanceTester
participant Accelerometer
User->>ResonanceTester: Start resonance test
ResonanceTester->>Printer: Configure test parameters
ResonanceTester->>Accelerometer: Start recording
loop Sweep Test
ResonanceTester->>Printer: Apply vibration with sweep motion
Printer-->>Accelerometer: Measure vibrations
end
ResonanceTester->>Accelerometer: Stop recording
Accelerometer-->>ResonanceTester: Return measurements
ResonanceTester-->>User: Display results
State diagram for resonance testing modesstateDiagram-v2
[*] --> TestSelection
TestSelection --> PulseOnly: Choose pulse-only
TestSelection --> SweepMode: Choose sweep mode
state PulseOnly {
[*] --> FixedPosition
FixedPosition --> Vibrating
Vibrating --> DataCollection
DataCollection --> [*]
}
state SweepMode {
[*] --> SlowSweep
SlowSweep --> Vibrating
Vibrating --> NoiseReduction
NoiseReduction --> DataCollection
DataCollection --> [*]
}
note right of PulseOnly: Better for diagnostic
note right of SweepMode: Better for final tuning
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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 - here's some feedback:
Overall Comments:
- Consider consolidating the parameter handling logic between BaseVibrationGenerator and SweepingVibrationGenerator to reduce code duplication in the prepare_test methods.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟡 Testing: 5 issues found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
self.accel_per_hz = accel_per_hz | ||
self.hz_per_sec = hz_per_sec | ||
self.freq_start = min_freq | ||
self.freq_end = max_freq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (testing): Missing tests for the new classes and methods
The new BaseVibrationGenerator
, SweepingVibrationGenerator
, StaticFrequencyVibrationGenerator
, and ResonanceTestManager
classes, along with their methods, lack dedicated unit tests. It's crucial to add tests verifying their behavior, especially edge cases like zero frequency, zero acceleration, invalid axis directions, and interactions with the toolhead
and gcode
objects. Consider mocking these dependencies for isolated testing.
@@ -37,6 +37,12 @@ While you should usually try to focus on the toolhead/belts mechanical subsystem | |||
1. **Diagnosis phase**: Begin with the nozzle tip mount to identify and troubleshoot mechanical issues to ensure the printer components are healthy and the assembly is well done and optimized. | |||
1. **Filter selection phase**: If the graphs are mostly clean, you can transition to a mounting point near the toolhead's center of gravity for cleaner data on the main resonance, facilitating accurate Input Shaping filter settings. You can also consider the CANBus integrated accelerometer for its simplicity, especially if the toolhead is particularly rigid and minimally affected by wobble. | |||
|
|||
### Should I user the sweeping or pulse-only test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (typo): Typo: "user" should be "use".
### Should I user the sweeping or pulse-only test? | |
### Should I use the sweeping or pulse-only test? |
if test_seq: | ||
max_accel = max(abs(a) for _, a, _ in test_seq) | ||
else: | ||
max_accel = old_max_accel # no moves, just default | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): We've found these issues:
- Replace if statement with if expression (
assign-if-exp
) - Low code quality found in ResonanceTestManager._run_test_sequence - 12% (
low-code-quality
)
if test_seq: | |
max_accel = max(abs(a) for _, a, _ in test_seq) | |
else: | |
max_accel = old_max_accel # no moves, just default | |
max_accel = max(abs(a) for _, a, _ in test_seq) if test_seq else old_max_accel |
Explanation
The quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
* fixed compatibility with the new version of Klipper for pulse-only test * added sweeping compatibility (#179) * added documentation about sweeping mode
Summary by Sourcery
Add support for sweeping vibration tests during resonance measurements.
New Features:
Tests: