docs: remove Tkinter GUI example from host communication guide
This commit is contained in:
@@ -180,60 +180,6 @@ def send_debug_tune(ser,
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Tkinter 界面建议
|
|
||||||
|
|
||||||
```python
|
|
||||||
import tkinter as tk
|
|
||||||
import tkinter.ttk as ttk
|
|
||||||
import serial
|
|
||||||
import struct
|
|
||||||
import threading
|
|
||||||
|
|
||||||
class TunerApp:
|
|
||||||
def __init__(self, root):
|
|
||||||
self.ser = serial.Serial('COM3', 115200, timeout=0.01)
|
|
||||||
|
|
||||||
# 视觉环 PID
|
|
||||||
self.vision_frame = ttk.LabelFrame(root, text="视觉环 PID")
|
|
||||||
self.v_yaw = self._make_pid_row(self.vision_frame, "Yaw", 0, (1.5, 3.0, 0.07))
|
|
||||||
self.v_pitch = self._make_pid_row(self.vision_frame, "Pitch", 1, (1.0, 2.0, 0.05))
|
|
||||||
|
|
||||||
# 电机角度环 PID
|
|
||||||
self.motor_frame = ttk.LabelFrame(root, text="电机角度环 PID")
|
|
||||||
self.m_yaw = self._make_pid_row(self.motor_frame, "Yaw", 2, (30, 80, 0.2))
|
|
||||||
self.m_pitch = self._make_pid_row(self.motor_frame, "Pitch", 3, (20, 50, 0.1))
|
|
||||||
|
|
||||||
ttk.Button(root, text="发送调参", command=self.send_tune).pack()
|
|
||||||
|
|
||||||
def _make_pid_row(self, parent, label, row, default):
|
|
||||||
frame = ttk.Frame(parent)
|
|
||||||
ttk.Label(frame, text=label).grid(row=0, column=0)
|
|
||||||
kp = tk.DoubleVar(value=default[0])
|
|
||||||
ki = tk.DoubleVar(value=default[1])
|
|
||||||
kd = tk.DoubleVar(value=default[2])
|
|
||||||
ttk.Entry(frame, textvariable=kp, width=8).grid(row=0, column=1)
|
|
||||||
ttk.Entry(frame, textvariable=ki, width=8).grid(row=0, column=2)
|
|
||||||
ttk.Entry(frame, textvariable=kd, width=8).grid(row=0, column=3)
|
|
||||||
frame.pack()
|
|
||||||
return (kp, ki, kd)
|
|
||||||
|
|
||||||
def send_tune(self):
|
|
||||||
def get(v): return v[0].get(), v[1].get(), v[2].get()
|
|
||||||
vy_kp, vy_ki, vy_kd = get(self.v_yaw)
|
|
||||||
vp_kp, vp_ki, vp_kd = get(self.v_pitch)
|
|
||||||
my_kp, my_ki, my_kd = get(self.m_yaw)
|
|
||||||
mp_kp, mp_ki, mp_kd = get(self.m_pitch)
|
|
||||||
send_debug_tune(self.ser,
|
|
||||||
vy_kp, vy_ki, vy_kd,
|
|
||||||
vp_kp, vp_ki, vp_kd,
|
|
||||||
my_kp, my_ki, my_kd,
|
|
||||||
mp_kp, mp_ki, mp_kd)
|
|
||||||
|
|
||||||
root = tk.Tk()
|
|
||||||
app = TunerApp(root)
|
|
||||||
root.mainloop()
|
|
||||||
```
|
|
||||||
|
|
||||||
## 校验和计算
|
## 校验和计算
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|||||||
Reference in New Issue
Block a user