-
Notifications
You must be signed in to change notification settings - Fork 32
refactor: consolidate duplicate PID controllers (pidmayuresh3 → wrapper) fixes #378 #435
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
Merged
pradeeban
merged 3 commits into
ControlCore-Project:dev
from
GaneshPatil7517:refactor/consolidate-pidmayuresh-378
Feb 20, 2026
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
52b0c3b
refactor: consolidate duplicate PID controller (pidmayuresh3 wrapper)
GaneshPatil7517 b27755a
fix: use try/except for relative+absolute import in pidmayuresh3 wrapper
GaneshPatil7517 22d0936
Merge branch 'dev' into refactor/consolidate-pidmayuresh-378
pradeeban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,26 @@ | ||
| import numpy as np | ||
| import math | ||
| import concore | ||
| dT = 0.1 | ||
|
|
||
| sp = concore.tryparam('sp', 67.5) | ||
| Kp = concore.tryparam('Kp', 0.075) | ||
| Ki = concore.tryparam('Ki', 0.02) | ||
| Kd = concore.tryparam('Kd', 0.005) | ||
| freq = concore.tryparam('freq',30) | ||
| sigout = concore.tryparam('sigout',True) | ||
| cin = concore.tryparam('cin', 'hr') | ||
|
|
||
| def pid_controller(state, ym, sp, Kp, Ki, Kd, sigout, cin, low, up): | ||
| Prev_Error = state[0] | ||
| I = state[1] | ||
| if cin == 'hr': | ||
| Error = sp - ym[1] | ||
| elif cin == 'map': | ||
| Error = sp - ym[0] | ||
| else: | ||
| print('invalid control input '+cin) | ||
| quit() | ||
| P = Error | ||
| I = I + Error*dT | ||
| D = (Error - Prev_Error )/dT | ||
| amp = Kp*P + Ki*I + Kd*D | ||
| Prev_Error = Error | ||
| if sigout: | ||
| amp = (up-low)/(1.0 + math.exp(amp)) + low | ||
| state = [Prev_Error, I] | ||
| return (state, amp) | ||
|
|
||
|
|
||
| concore.default_maxtime(150) | ||
| concore.delay = 0.02 | ||
| init_simtime_ym = "[0.0, 70.0,91]" | ||
| ym = np.array(concore.initval(init_simtime_ym)) | ||
| state = [0.0, 0.0] | ||
| print("Mayuresh's PID controller: sp is "+str(sp)) | ||
| print(concore.params) | ||
| while(concore.simtime<concore.maxtime): | ||
| while concore.unchanged(): | ||
| ym = concore.read(1,"ym",init_simtime_ym) | ||
| ym = np.array(ym) | ||
| (state,amp) = pid_controller(state,ym,sp,Kp,Ki,Kd,sigout,cin,0,3) | ||
| u = np.array([amp,freq]) | ||
| print(str(concore.simtime) + " u="+str(u) + "ym="+str(ym)) | ||
| concore.write(1,"u",list(u),delta=0) | ||
| """ | ||
| Backward-compatibility wrapper for pidmayuresh.py. | ||
|
|
||
| This file previously contained a duplicate PID controller implementation | ||
| that used print() instead of logging. The canonical implementation now | ||
| lives in pidmayuresh.py (which uses the logging module). | ||
|
|
||
| This wrapper re-exports everything so that any existing import of | ||
| pidmayuresh3 continues to work without modification. | ||
|
|
||
| See: https://github.com/ControlCore-Project/concore/issues/378 | ||
| """ | ||
|
|
||
| import warnings | ||
| warnings.warn( | ||
| "pidmayuresh3 is deprecated — use pidmayuresh instead.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| # Re-execute the canonical module so run-time behaviour is identical | ||
| # when this file is invoked directly (e.g., via a study graph). | ||
| from pidmayuresh import * # noqa: F401,F403 | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.