Merge branch 'urdf' of https://git.svs-tech.pro/ksenia_mikhailova/modbus_test into urdf
This commit is contained in:
commit
96fe6de6ba
26
client.py
26
client.py
|
@ -8,23 +8,25 @@ import tkinter as tk
|
||||||
from func import *
|
from func import *
|
||||||
|
|
||||||
window = tk.Tk()
|
window = tk.Tk()
|
||||||
window.geometry('520x300')
|
window.geometry("520x300")
|
||||||
label = tk.Label(window, text="Hello, world!")
|
label = tk.Label(window, text="Hello, world!")
|
||||||
label.pack()
|
label.pack()
|
||||||
|
|
||||||
|
|
||||||
all_files = glob.glob("data/data.txt")
|
all_files = glob.glob("data/*.nc")
|
||||||
file = all_files[0]
|
file = all_files[0]
|
||||||
data = []
|
data = [
|
||||||
with open(file, "r") as fp:
|
("line", 0, 0, 277.8, 0, 5, 0),
|
||||||
lines = fp.readlines()
|
]
|
||||||
for l in lines:
|
# with open(file, "r") as fp:
|
||||||
r = l.strip().split(",")
|
# lines = fp.readlines()
|
||||||
r[1] = float(r[1])
|
# for l in lines:
|
||||||
r[2] = float(r[2])
|
# r = l.strip().split(",")
|
||||||
r[3] = float(r[3])
|
# r[1] = float(r[1])
|
||||||
|
# r[2] = float(r[2])
|
||||||
|
# r[3] = float(r[3])
|
||||||
|
|
||||||
data.append(r)
|
# data.append(r)
|
||||||
|
|
||||||
client = ModbusTcpClient(
|
client = ModbusTcpClient(
|
||||||
host=MODBUS_SERVER_HOST,
|
host=MODBUS_SERVER_HOST,
|
||||||
|
@ -113,5 +115,5 @@ except Exception as e:
|
||||||
finally:
|
finally:
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__ == "__main__":
|
||||||
window.mainloop()
|
window.mainloop()
|
|
@ -19,8 +19,8 @@ class SocketRobotArm:
|
||||||
line_smooth = 9
|
line_smooth = 9
|
||||||
line_tool = 1
|
line_tool = 1
|
||||||
|
|
||||||
global_speed = 100
|
global_speed = 10
|
||||||
physical_speed = 50
|
physical_speed = 10
|
||||||
# laser_id = 15
|
# laser_id = 15
|
||||||
laser_id = 14
|
laser_id = 14
|
||||||
# filename = 'half-sphere-no-angle'
|
# filename = 'half-sphere-no-angle'
|
||||||
|
@ -55,6 +55,7 @@ class SocketRobotArm:
|
||||||
|
|
||||||
threading.Thread(target=self.run_pybullet, daemon=True).start()
|
threading.Thread(target=self.run_pybullet, daemon=True).start()
|
||||||
|
|
||||||
|
print((self.port, self.host))
|
||||||
self.socket.connect((self.host, self.port))
|
self.socket.connect((self.host, self.port))
|
||||||
self.cycle_base()
|
self.cycle_base()
|
||||||
|
|
||||||
|
@ -126,7 +127,8 @@ class SocketRobotArm:
|
||||||
self.tkinter_info_label.pack()
|
self.tkinter_info_label.pack()
|
||||||
self.tkinter_root.update()
|
self.tkinter_root.update()
|
||||||
|
|
||||||
step = 2
|
step = 4
|
||||||
|
empty = 1
|
||||||
for i in range(0, len(self.add_rcc_list), step):
|
for i in range(0, len(self.add_rcc_list), step):
|
||||||
if not self.tkinter_info_label:
|
if not self.tkinter_info_label:
|
||||||
return
|
return
|
||||||
|
@ -137,11 +139,14 @@ class SocketRobotArm:
|
||||||
# self.update_text(m, text=f"Отправка данных {i}...{i+step-1}")
|
# self.update_text(m, text=f"Отправка данных {i}...{i+step-1}")
|
||||||
self.tkinter_info_label.config(text=f"Отправка данных {i}...{i+step-1}")
|
self.tkinter_info_label.config(text=f"Отправка данных {i}...{i+step-1}")
|
||||||
self.tkinter_root.update()
|
self.tkinter_root.update()
|
||||||
|
# print(empty)
|
||||||
self.send_data(
|
self.send_data(
|
||||||
make_addrcc_data(self.add_rcc_list[i : i + step], int(not i))
|
make_addrcc_data(
|
||||||
|
self.add_rcc_list[i : i + step], empty
|
||||||
|
)
|
||||||
)
|
)
|
||||||
time.sleep(0.5)
|
empty = 0
|
||||||
|
time.sleep(0.05)
|
||||||
|
|
||||||
def imitate(self):
|
def imitate(self):
|
||||||
points = self.steps_from_file()
|
points = self.steps_from_file()
|
||||||
|
@ -240,7 +245,7 @@ class SocketRobotArm:
|
||||||
|
|
||||||
def make_world_step(self, type, point):
|
def make_world_step(self, type, point):
|
||||||
step = {
|
step = {
|
||||||
"oneshot": "0",
|
"oneshot": "1",
|
||||||
"delay": "0.0",
|
"delay": "0.0",
|
||||||
"speed": str(self.line_speed),
|
"speed": str(self.line_speed),
|
||||||
"smooth": str(self.line_smooth),
|
"smooth": str(self.line_smooth),
|
||||||
|
|
|
@ -7,3 +7,23 @@ X100 Y50
|
||||||
X100 Y0
|
X100 Y0
|
||||||
X50 Y0
|
X50 Y0
|
||||||
X0 Y0
|
X0 Y0
|
||||||
|
|
||||||
|
X165 Y0
|
||||||
|
X330 Y0
|
||||||
|
X500 Y165
|
||||||
|
X500 Y330
|
||||||
|
X330 Y500
|
||||||
|
X165 Y500
|
||||||
|
X0 Y330
|
||||||
|
X0 Y165
|
||||||
|
Z-50 V40 X0 Y0
|
||||||
|
Z-50 V40 X165 Y0
|
||||||
|
Z-50 V40 X330 Y0
|
||||||
|
Z-50 V-40 X500 Y165
|
||||||
|
Z-50 V-40 X500 Y330
|
||||||
|
Z-50 V-40 X330 Y500
|
||||||
|
Z-50 V-40 X165 Y500
|
||||||
|
Z-50 V40 X0 Y330
|
||||||
|
Z-50 V40 X0 Y165
|
||||||
|
Z-50 V40 X0 Y0
|
||||||
|
X0 Y0
|
||||||
|
|
6
func.py
6
func.py
|
@ -1,7 +1,9 @@
|
||||||
# Настройки клиента Modbus
|
# Настройки клиента Modbus
|
||||||
MODBUS_SERVER_HOST = "192.168.70.55" # IP-адрес Modbus-сервера
|
# MODBUS_SERVER_HOST = "192.168.70.55" # IP-адрес Modbus-сервера
|
||||||
|
MODBUS_SERVER_HOST = "192.168.70.65" # IP-адрес Modbus-сервера
|
||||||
MODBUS_SERVER_PORT = 502
|
MODBUS_SERVER_PORT = 502
|
||||||
MODBUS_SLAVE_ID = 11
|
# MODBUS_SLAVE_ID = 11
|
||||||
|
MODBUS_SLAVE_ID = 22
|
||||||
|
|
||||||
indent = 21100
|
indent = 21100
|
||||||
s = 800
|
s = 800
|
||||||
|
|
Loading…
Reference in New Issue