Advertisement

使用Python的tkinter和matplotlib模块在图形界面中绘制PID交互曲线分析各参数对PID控制的影响

阅读量:

PID参数影响可视化实现

近期在学习PID控制相关知识,为了更直观地了解各个参数对控制效果的具体影响,使用Python开发了一个可视化界面。整体实现过程相对简单,具体代码如下:

pid_GUI.py

复制代码
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # author:makang
    # Description: 绘制PID交互曲线,可以观察到Kp,Ki,Kd各参数对PID控制的影响
    
    import tkinter as tk
    import PID
    import matplotlib as plt
    from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
    from matplotlib.figure import Figure
    import numpy as np
    
    # 绘图函数
    def drawPic():
    global r, g, b
    
    # 清空图像,以使得前后两次绘制的图像不会重叠
    # drawPic.f.clf()
    drawPic.a = drawPic.f.add_subplot(111)

全部评论 (0)

还没有任何评论哟~