forked from Mcpigeons04/Drone-Simulation-Gazebo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpid_lib.py
More file actions
66 lines (57 loc) · 1.65 KB
/
Copy pathpid_lib.py
File metadata and controls
66 lines (57 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
import tkinter as tk
from tkinter import Scale
import rospy
from pid_tune.msg import PidTune
class Pid_dim:
def __init__(self, title, topic_name, queue_size):
self.pub_pid = rospy.Publisher(topic_name, PidTune, queue_size=queue_size)
self.pid_params = PidTune()
self.root = tk.Tk()
self.root.title(title)
self.root.attributes("-topmost", True)
self.root.geometry("250x210")
self.scale = Scale(
self.root,
orient="horizontal",
from_=0,
to=5000,
command=self.set_value,
label="Kp",
width="20",
length="300",
troughcolor="red",
sliderlength="15",
)
self.scale1 = Scale(
self.root,
orient="horizontal",
from_=0,
to=1000,
command=self.set_value,
label="Ki",
width="20",
length="300",
troughcolor="green",
sliderlength="15",
)
self.scale2 = Scale(
self.root,
orient="horizontal",
from_=0,
to=5000,
command=self.set_value,
label="Kd",
width="20",
length="300",
troughcolor="blue",
sliderlength="15",
)
self.scale.pack()
self.scale1.pack()
self.scale2.pack()
def set_value(self, event):
self.pid_params.Kp = self.scale.get()
self.pid_params.Ki = self.scale1.get()
self.pid_params.Kd = self.scale2.get()
self.pub_pid.publish(self.pid_params)