Skip to content

Add Interactive Root Locus GUI with High-Resolution Catmull-Rom Interpolation #1175

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AndrewTrepagnier
Copy link

The python-control library currently lacks interactive plotting capabilities that are essential for modern control system analysis and education. While the library provides excellent static root locus plots, users often need to:

  • Explore system behavior interactively - Hover over curves to see gain, damping, and frequency values
  • Understand parameter relationships - See how changes in gain affect pole locations in real-time
  • Enhance learning experience - Provide visual feedback that helps students understand control theory concepts
  • Match commercial software capabilities - Bring python-control closer to MATLAB's interactive features

** The problem **
Real-time GUI's can be tricky for high-order polynomials such as a complex root locus plot. I have experience building precomputed lookup tables and implementing more advanced interpolation techniques for smoothing out resolution issues with real-time followers like the one I proposed.

What This Contribution Adds

  • Interactive hover functionality with real-time gain, damping ratio, and frequency display
  • High-resolution cursor marker (10,000 resolution points) that follows root locus curves
  • Catmull-Rom spline interpolation for ultra-smooth movement along curves
  • Information box showing current system parameters
  • Maintains original plot style - no visual changes to existing functionality

Why it is efficient and novel?
This improvement uses:

  • Precomputed gain tables with log-spaced resolution for optimal performance
  • Curve-following interpolation that treats each locus as a separate smooth curve
  • Spatial indexing for efficient search and interpolation
  • 50 interpolation samples per curve segment for maximum smoothness
  • User Experience
  • Intuitive interaction - hover vs click-based methods
  • Ultra-smooth movement - cursor slides like butter along curves
  • Real-time feedback - continuous parameter updates
  • Educational value - makes control theory more accessible

You can test it through my fork by running:

git clone https://github.com/AndrewTrepagnier/python-control.git
cd python-control
pip install -e .

Then run:

python examples/high_resolution_demo.py

Now you can hover over the curve to see real-time gain changes.

I find this real-time tool very helpful, I hope this helps and is considered for the control package!

The readme is AI generated so I can delete that if needed. Thanks!

- Add RootLocusGUI class for interactive matplotlib-based root locus plots
- Implement hover detection to show gain, damping, and frequency information
- Use original root locus plotting style with small info box overlay
- Add comprehensive tests and documentation
- Include simple example demonstrating usage
- Integrate with main control namespace via interactive module

This provides a more intuitive hover-based interaction compared to the
existing click-based functionality, while maintaining the familiar
matplotlib plot appearance.
- Implement RootLocusGUI class with matplotlib-based interactive plotting
- Add green dot cursor marker with linear interpolation for smooth movement
- Use wide default limits (-5,2)x(-3,3) and large distance threshold (10.0)
- Include real-time gain, damping, and frequency display
- Add comprehensive test suite (17 tests passing)
- Add complex system example demonstrating multiple asymptotes
@ilayn
Copy link

ilayn commented Jul 26, 2025

It seems like the whole thing is written with AI and it gets wackier towards the end dummy functions returning classes, 10k resolution points etc. User's profile is also not instilling trust if I have to be honest. I guess this is the new world as promised.

@AndrewTrepagnier
Copy link
Author

Ilayn, I am sorry you feel that way about my additions, I am relatively new to GitHub and still trying to learn through open sourcing and collaborating. The 10k resolution can absolutely be changed, however I found this gave extremely smooth lookup tables for the root locus gains. What can I change to make this a better addition to the package?

@ilayn
Copy link

ilayn commented Jul 27, 2025

Don't mind me. I have been dealing with tons of AI submissions lately, I just don't know what to make of them yet.

@murrayrm
Copy link
Member

Quick comments on the failing unit tests:

  • Ruff checks are self explanatory (see the error log) and should be quick to fix
  • For the keyword check (kwargs_test.py), you need to make sure that if a bad keyword is passed, this generates an error message. Once you have a unit test that covers that, you can specify it in the unit test file.

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.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy