控制包括五个舵机的机械臂
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLineEdit
import socket
class RobotControlClient(QWidget):
def __init__(self):
super().__init__()
self.init_ui()
def init_ui(self):
self.setWindowTitle('机器人控制客户端')
layout = QVBoxLayout()
# 添加输入服务器IP地址的行
self.ip_edit = QLineEdit()
self.ip_edit.setPlaceholderText("服务器IP地址")
layout.addWidget(self.ip_edit)
# 添加输入服务器端口号的行
self.port_edit = QLineEdit()
self.port_edit.setPlaceholderText("服务器端口号")
layout.addWidget(self.port_edit)
commands = ["Stop", "Forward", "Backward", "TurnLeft", "TurnRight", "Up", "Down", "Left", "Right"]
for command in commands:
button = QPushButton(command)
button.clic