Skip to content

Comments

refactor: consolidate duplicate PID controllers (pidmayuresh3 → wrapper) — fixes #378#435

Merged
pradeeban merged 3 commits intoControlCore-Project:devfrom
GaneshPatil7517:refactor/consolidate-pidmayuresh-378
Feb 20, 2026
Merged

refactor: consolidate duplicate PID controllers (pidmayuresh3 → wrapper) — fixes #378#435
pradeeban merged 3 commits intoControlCore-Project:devfrom
GaneshPatil7517:refactor/consolidate-pidmayuresh-378

Conversation

@GaneshPatil7517
Copy link

hey @pradeeban Sir
Resolves #378tools/pidmayuresh.py and tools/pidmayuresh3.py contained
identical PID controller implementations differing only in logging (logging
module vs print()).

Changes

  • tools/pidmayuresh3.py: Replaced the full duplicate implementation with
    a thin backward-compatibility wrapper that re-exports from pidmayuresh.py
    and emits a DeprecationWarning.
  • tools/pidmayuresh.py: No changes — remains the canonical implementation
    using the logging module.

What stays the same

  • PID algorithm and math — untouched
  • Function signature: pid_controller(state, ym, sp, Kp, Ki, Kd, sigout, cin, low, up)
  • All default tryparam values
  • Existing scripts importing either filename continue to work

Why this approach

Concern Resolution
Code duplication Single implementation in pidmayuresh.py
Inconsistent logging print() removed; all output uses logging
Backward compatibility pidmayuresh3.py wrapper re-exports everything
Maintenance overhead Future changes only need to touch one file

Testing

  • py_compile passes for both files
  • Full test suite: 83 passed, 0 new failures
  • 9 pre-existing errors in test_openjupyter_security.py (unrelated FLASK_SECRET_KEY issue)

Replace the duplicate PID implementation in tools/pidmayuresh3.py with a
thin backward-compatibility wrapper that re-exports from pidmayuresh.py.

- pidmayuresh.py remains the canonical implementation (uses logging)
- pidmayuresh3.py now imports from pidmayuresh.py with a DeprecationWarning
- No PID logic, API, or default parameters changed
- All existing imports of pidmayuresh3 continue to work

Closes ControlCore-Project#378
Copilot AI review requested due to automatic review settings February 20, 2026 06:18
Copy link

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

Consolidates the duplicate PID controller implementation by turning tools/pidmayuresh3.py into a backward-compatibility wrapper around the canonical tools/pidmayuresh.py, while also cleaning up minor whitespace in two bang-bang controller scripts.

Changes:

  • Replaced the duplicate implementation in tools/pidmayuresh3.py with a wrapper that emits a DeprecationWarning and re-exports the canonical module.
  • Removed stray whitespace in tools/bangbang.py and humanc/bangbang.py.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tools/pidmayuresh3.py Replaces duplicate PID implementation with a deprecation wrapper that re-exports the canonical controller.
tools/bangbang.py Whitespace cleanup in controller function.
humanc/bangbang.py Whitespace cleanup in controller function.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

GaneshPatil7517 and others added 2 commits February 20, 2026 11:53
Apply Copilot review suggestion — try relative import first
(from .pidmayuresh) for package-style usage, with fallback to
absolute import for direct script execution.
@pradeeban pradeeban merged commit 4926918 into ControlCore-Project:dev Feb 20, 2026
6 checks passed
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