上位机调参-滑条

master
45coll 2021-10-15 09:27:26 +08:00
parent 4036f89940
commit 3f8700eee3
4 changed files with 462 additions and 195 deletions

View File

@ -63,13 +63,13 @@ float LQR_K3_1 = 0.15; //
//电机参数 //电机参数
BLDCMotor motor = BLDCMotor(5); BLDCMotor motor = BLDCMotor(5);
BLDCDriver3PWM driver = BLDCDriver3PWM(32, 33, 25, 22); BLDCDriver3PWM driver = BLDCDriver3PWM(32, 33, 25, 22);
//命令设置
Command comm;
float target_velocity = 0; float target_velocity = 0;
float target_angle = 90; float target_angle = 90;
float target_voltage = 0; float target_voltage = 0;
//命令设置
Command comm;
bool Motor_enable_flag = 0;
void do_K11(char* cmd) { comm.scalar(&LQR_K1, cmd); } void do_K11(char* cmd) { comm.scalar(&LQR_K1, cmd); }
void do_K12(char* cmd) { comm.scalar(&LQR_K2, cmd); } void do_K12(char* cmd) { comm.scalar(&LQR_K2, cmd); }
void do_K13(char* cmd) { comm.scalar(&LQR_K3, cmd); } void do_K13(char* cmd) { comm.scalar(&LQR_K3, cmd); }
@ -77,6 +77,15 @@ void do_K21(char* cmd) { comm.scalar(&LQR_K1_1, cmd); }
void do_K22(char* cmd) { comm.scalar(&LQR_K2_1, cmd); } void do_K22(char* cmd) { comm.scalar(&LQR_K2_1, cmd); }
void do_K23(char* cmd) { comm.scalar(&LQR_K3_1, cmd); } void do_K23(char* cmd) { comm.scalar(&LQR_K3_1, cmd); }
void do_TA(char* cmd) { comm.scalar(&target_angle, cmd); } void do_TA(char* cmd) { comm.scalar(&target_angle, cmd); }
void do_START(char* cmd) { wifi_flag = 1; }
void do_MOTOR(char* cmd)
{
if(Motor_enable_flag)
digitalWrite(22,HIGH);
else
digitalWrite(22,LOW);
Motor_enable_flag = !Motor_enable_flag;
}
void onPacketCallBack(AsyncUDPPacket packet) void onPacketCallBack(AsyncUDPPacket packet)
{ {
char* da; char* da;
@ -84,10 +93,6 @@ void onPacketCallBack(AsyncUDPPacket packet)
Serial.println(da); Serial.println(da);
comm.run(da); comm.run(da);
// target_velocity = atoi();
// Serial.print("数据内容: ");
// Serial.println(target_velocity);
wifi_flag = 1;
// packet.print("reply data"); // packet.print("reply data");
} }
// instantiate the commander // instantiate the commander
@ -101,6 +106,8 @@ void setup() {
comm.add("K22",do_K22); comm.add("K22",do_K22);
comm.add("K23",do_K23); comm.add("K23",do_K23);
comm.add("TA",do_TA); comm.add("TA",do_TA);
comm.add("START",do_START);
comm.add("MOTOR",do_MOTOR);
// kalman mpu6050 init // kalman mpu6050 init
Wire.begin(19, 18,400000);// Set I2C frequency to 400kHz Wire.begin(19, 18,400000);// Set I2C frequency to 400kHz
i2cData[0] = 7; // Set the sample rate to 1000Hz - 8kHz/(7+1) = 1000Hz i2cData[0] = 7; // Set the sample rate to 1000Hz - 8kHz/(7+1) = 1000Hz
@ -192,7 +199,7 @@ void setup() {
Serial.println(F("Motor ready.")); Serial.println(F("Motor ready."));
Serial.println(F("Set the target velocity using serial terminal:")); Serial.println(F("Set the target velocity using serial terminal:"));
// digitalWrite(22,LOW);
} }
char buf[255]; char buf[255];
@ -256,7 +263,7 @@ void loop() {
#else #else
motor.move(0); motor.move(0);
#endif #endif
#if 1 #if 0
//Serial.print(gyroZangle);Serial.print("\t"); //Serial.print(gyroZangle);Serial.print("\t");
Serial.print(kalAngleZ);Serial.print("\t"); Serial.print(kalAngleZ);Serial.print("\t");

View File

@ -26,7 +26,9 @@ class MyWindow(QMainWindow, Ui_MainWindow):
# 设置信号与槽 # 设置信号与槽
def CreateSignalSlot(self): def CreateSignalSlot(self):
self.velocity_horizontalSlider.valueChanged.connect(self.velocity_horizontalSlider_valueChanged) self.horizontalSlider_1.valueChanged.connect(self.horizontalSlider_1_valueChanged)
self.horizontalSlider_2.valueChanged.connect(self.horizontalSlider_2_valueChanged)
self.horizontalSlider_3.valueChanged.connect(self.horizontalSlider_3_valueChanged)
self.wifi_config_pushButton.clicked.connect(self.wifi_config_pushButton_clicked) self.wifi_config_pushButton.clicked.connect(self.wifi_config_pushButton_clicked)
self.wifi_command_pushButton_1.clicked.connect(self.wifi_command_pushButton_1_clicked) self.wifi_command_pushButton_1.clicked.connect(self.wifi_command_pushButton_1_clicked)
self.wifi_command_pushButton_2.clicked.connect(self.wifi_command_pushButton_2_clicked) self.wifi_command_pushButton_2.clicked.connect(self.wifi_command_pushButton_2_clicked)
@ -42,6 +44,7 @@ class MyWindow(QMainWindow, Ui_MainWindow):
# self.wifi_IP_lineEdit.setText(self.udp.user_ip) # self.wifi_IP_lineEdit.setText(self.udp.user_ip)
def variable_init(self): def variable_init(self):
# 图表数据变量 # 图表数据变量
self.wifi_open_flag = 0
self.wifi_recv_flag = 0 self.wifi_recv_flag = 0
self.udp_data = 0 self.udp_data = 0
self.target_velocity = 0 self.target_velocity = 0
@ -76,11 +79,24 @@ class MyWindow(QMainWindow, Ui_MainWindow):
self.gridLayout.addWidget(self.plotWidget) self.gridLayout.addWidget(self.plotWidget)
self.tool_layout.addWidget(self.controlPlotWidget) self.tool_layout.addWidget(self.controlPlotWidget)
# 滑条绑定 # 滑条绑定
def velocity_horizontalSlider_valueChanged(self): def horizontalSlider_1_valueChanged(self):
self.target_velocity = self.velocity_horizontalSlider.value() value = self.horizontalSlider_1.value()
self.velocity_lineEdit.setText(str(self.target_velocity)) value = float(self.left_lineEdit_1.text())+(value+100)*(float(self.right_lineEdit_1.text())-float(self.left_lineEdit_1.text()))/200
self.udp.send_message(str(self.target_velocity)) self.num_lineEdit_1.setText(str(value))
print(str(self.target_velocity)) value = self.command_lineEdit_1.text()+str(value)
self.udp.send_message(str(value))
def horizontalSlider_2_valueChanged(self):
value = self.horizontalSlider_2.value()
value = float(self.left_lineEdit_2.text())+(value+100)*(float(self.right_lineEdit_2.text())-float(self.left_lineEdit_2.text()))/200
self.num_lineEdit_2.setText(str(value))
value = self.command_lineEdit_2.text()+str(value)
self.udp.send_message(str(value))
def horizontalSlider_3_valueChanged(self):
value = self.horizontalSlider_3.value()
value = float(self.left_lineEdit_3.text())+(value+100)*(float(self.right_lineEdit_3.text())-float(self.left_lineEdit_3.text()))/200
self.num_lineEdit_3.setText(str(value))
value = self.command_lineEdit_3.text()+str(value)
self.udp.send_message(str(value))
# command命令发送事件 # command命令发送事件
def wifi_command_pushButton_1_clicked(self): def wifi_command_pushButton_1_clicked(self):
self.udp.send_message(self.wifi_command_lineEdit_1.text()) self.udp.send_message(self.wifi_command_lineEdit_1.text())
@ -96,7 +112,7 @@ class MyWindow(QMainWindow, Ui_MainWindow):
print(self.wifi_IP_lineEdit.text(),type(self.wifi_IP_lineEdit.text())) print(self.wifi_IP_lineEdit.text(),type(self.wifi_IP_lineEdit.text()))
self.udp.udpClientSocket.bind((self.wifi_IP_lineEdit.text(), 2333)) self.udp.udpClientSocket.bind((self.wifi_IP_lineEdit.text(), 2333))
# 第一次接受数据,用于判断项目数, # 第一次接受数据,用于判断项目数,
self.udp.send_message("s") self.udp.send_message("START")
recv_data = self.udp.udpClientSocket.recv(1024) recv_data = self.udp.udpClientSocket.recv(1024)
recv_data = recv_data.decode('utf-8') recv_data = recv_data.decode('utf-8')
recv_data = recv_data[:-1] recv_data = recv_data[:-1]
@ -109,6 +125,7 @@ class MyWindow(QMainWindow, Ui_MainWindow):
self.plot_init() self.plot_init()
t1 = threading.Thread(target=self.udp_recv) t1 = threading.Thread(target=self.udp_recv)
t1.start() t1.start()
self.wifi_open_flag = 1
except Exception as e: except Exception as e:
print(e) print(e)
QMessageBox.critical(self, "错误", '该请求的地址无效') QMessageBox.critical(self, "错误", '该请求的地址无效')
@ -143,6 +160,10 @@ class ControlPlotPanel(QtWidgets.QWidget):
def __init__(self, parent=None, controllerPlotWidget=None): def __init__(self, parent=None, controllerPlotWidget=None):
'''Constructor for ToolsWidget''' '''Constructor for ToolsWidget'''
super().__init__(parent) super().__init__(parent)
# 变量
self.MotorEnable_flag = 0
# 继承主窗口对象
self.controlledPlot = controllerPlotWidget self.controlledPlot = controllerPlotWidget
self.horizontalLayout1 = QtWidgets.QHBoxLayout() self.horizontalLayout1 = QtWidgets.QHBoxLayout()
@ -156,6 +177,13 @@ class ControlPlotPanel(QtWidgets.QWidget):
self.startStopButton.setIcon(GUIToolKit.getIconByName('start')) self.startStopButton.setIcon(GUIToolKit.getIconByName('start'))
self.horizontalLayout1.addWidget(self.startStopButton) self.horizontalLayout1.addWidget(self.startStopButton)
self.MotorEnableButton = QtWidgets.QPushButton(self)
self.MotorEnableButton.setText('Disable')
self.MotorEnableButton.setObjectName('Disable')
self.MotorEnableButton.clicked.connect(self.MotorEnableButton_clicked)
self.MotorEnableButton.setIcon(GUIToolKit.getIconByName('stop'))
self.horizontalLayout1.addWidget(self.MotorEnableButton)
self.zoomAllButton = QtWidgets.QPushButton(self) self.zoomAllButton = QtWidgets.QPushButton(self)
self.zoomAllButton.setObjectName('zoomAllButton') self.zoomAllButton.setObjectName('zoomAllButton')
self.zoomAllButton.setText('View all') self.zoomAllButton.setText('View all')
@ -183,6 +211,16 @@ class ControlPlotPanel(QtWidgets.QWidget):
else: else:
self.controlledPlot.wifi_recv_flag = 0 self.controlledPlot.wifi_recv_flag = 0
self.startStopButton.setText('Start') self.startStopButton.setText('Start')
def MotorEnableButton_clicked(self):
if self.MotorEnable_flag == 0:
# Motor关闭
self.MotorEnable_flag = 1
self.MotorEnableButton.setText('Enable')
self.controlledPlot.udp.send_message("MOTOR")
else:
self.MotorEnable_flag = 0
self.MotorEnableButton.setText('Disable')
self.controlledPlot.udp.send_message("MOTOR")
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(sys.argv) app = QApplication(sys.argv)
myWin = MyWindow() myWin = MyWindow()

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'main_ui.ui' # Form implementation generated from reading ui file 'main_ui.ui'
# #
# Created by: PyQt5 UI code generator 5.15.4 # Created by: PyQt5 UI code generator 5.15.2
# #
# WARNING: Any manual changes made to this file will be lost when pyuic5 is # WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing. # run again. Do not edit this file unless you know what you are doing.
@ -33,40 +33,8 @@ class Ui_MainWindow(object):
self.wifi_config_pushButton = QtWidgets.QPushButton(self.horizontalLayoutWidget) self.wifi_config_pushButton = QtWidgets.QPushButton(self.horizontalLayoutWidget)
self.wifi_config_pushButton.setObjectName("wifi_config_pushButton") self.wifi_config_pushButton.setObjectName("wifi_config_pushButton")
self.horizontalLayout.addWidget(self.wifi_config_pushButton) self.horizontalLayout.addWidget(self.wifi_config_pushButton)
self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(590, 480, 104, 31))
self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label = QtWidgets.QLabel(self.horizontalLayoutWidget_2)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
self.velocity_lineEdit = QtWidgets.QLineEdit(self.horizontalLayoutWidget_2)
self.velocity_lineEdit.setObjectName("velocity_lineEdit")
self.horizontalLayout_2.addWidget(self.velocity_lineEdit)
self.velocity_horizontalSlider = QtWidgets.QSlider(self.centralwidget)
self.velocity_horizontalSlider.setGeometry(QtCore.QRect(430, 460, 261, 22))
self.velocity_horizontalSlider.setMinimum(-150)
self.velocity_horizontalSlider.setMaximum(150)
self.velocity_horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
self.velocity_horizontalSlider.setTickPosition(QtWidgets.QSlider.TicksAbove)
self.velocity_horizontalSlider.setTickInterval(10)
self.velocity_horizontalSlider.setObjectName("velocity_horizontalSlider")
self.horizontalLayoutWidget_3 = QtWidgets.QWidget(self.centralwidget)
self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(420, 480, 134, 31))
self.horizontalLayoutWidget_3.setObjectName("horizontalLayoutWidget_3")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_3)
self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_2 = QtWidgets.QLabel(self.horizontalLayoutWidget_3)
self.label_2.setObjectName("label_2")
self.horizontalLayout_3.addWidget(self.label_2)
self.angle_lineEdit = QtWidgets.QLineEdit(self.horizontalLayoutWidget_3)
self.angle_lineEdit.setObjectName("angle_lineEdit")
self.horizontalLayout_3.addWidget(self.angle_lineEdit)
self.groupBox_2 = QtWidgets.QGroupBox(self.centralwidget) self.groupBox_2 = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_2.setGeometry(QtCore.QRect(370, 10, 811, 431)) self.groupBox_2.setGeometry(QtCore.QRect(370, 10, 811, 441))
self.groupBox_2.setObjectName("groupBox_2") self.groupBox_2.setObjectName("groupBox_2")
self.gridLayoutWidget = QtWidgets.QWidget(self.groupBox_2) self.gridLayoutWidget = QtWidgets.QWidget(self.groupBox_2)
self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 20, 791, 361)) self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 20, 791, 361))
@ -75,50 +43,158 @@ class Ui_MainWindow(object):
self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout") self.gridLayout.setObjectName("gridLayout")
self.horizontalLayoutWidget_4 = QtWidgets.QWidget(self.groupBox_2) self.horizontalLayoutWidget_4 = QtWidgets.QWidget(self.groupBox_2)
self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(10, 370, 791, 51)) self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(10, 380, 791, 51))
self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4") self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4")
self.tool_layout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_4) self.tool_layout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_4)
self.tool_layout.setContentsMargins(0, 0, 0, 0) self.tool_layout.setContentsMargins(0, 0, 0, 0)
self.tool_layout.setObjectName("tool_layout") self.tool_layout.setObjectName("tool_layout")
self.groupBox_3 = QtWidgets.QGroupBox(self.centralwidget) self.groupBox_3 = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_3.setGeometry(QtCore.QRect(10, 20, 291, 121)) self.groupBox_3.setGeometry(QtCore.QRect(10, 10, 291, 321))
self.groupBox_3.setObjectName("groupBox_3") self.groupBox_3.setObjectName("groupBox_3")
self.horizontalLayoutWidget_5 = QtWidgets.QWidget(self.groupBox_3) self.formLayoutWidget = QtWidgets.QWidget(self.groupBox_3)
self.horizontalLayoutWidget_5.setGeometry(QtCore.QRect(10, 20, 271, 31)) self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 271, 291))
self.horizontalLayoutWidget_5.setObjectName("horizontalLayoutWidget_5") self.formLayoutWidget.setObjectName("formLayoutWidget")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_5) self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0) self.formLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.formLayout.setObjectName("formLayout")
self.wifi_command_lineEdit_1 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_5) self.wifi_command_lineEdit_1 = QtWidgets.QLineEdit(self.formLayoutWidget)
self.wifi_command_lineEdit_1.setObjectName("wifi_command_lineEdit_1") self.wifi_command_lineEdit_1.setObjectName("wifi_command_lineEdit_1")
self.horizontalLayout_4.addWidget(self.wifi_command_lineEdit_1) self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.wifi_command_lineEdit_1)
self.wifi_command_pushButton_1 = QtWidgets.QPushButton(self.horizontalLayoutWidget_5) self.wifi_command_pushButton_1 = QtWidgets.QPushButton(self.formLayoutWidget)
self.wifi_command_pushButton_1.setObjectName("wifi_command_pushButton_1") self.wifi_command_pushButton_1.setObjectName("wifi_command_pushButton_1")
self.horizontalLayout_4.addWidget(self.wifi_command_pushButton_1) self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.wifi_command_pushButton_1)
self.horizontalLayoutWidget_6 = QtWidgets.QWidget(self.groupBox_3) self.wifi_command_lineEdit_2 = QtWidgets.QLineEdit(self.formLayoutWidget)
self.horizontalLayoutWidget_6.setGeometry(QtCore.QRect(10, 50, 271, 31)) self.wifi_command_lineEdit_2.setObjectName("wifi_command_lineEdit_2")
self.horizontalLayoutWidget_6.setObjectName("horizontalLayoutWidget_6") self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.wifi_command_lineEdit_2)
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_6) self.wifi_command_lineEdit_3 = QtWidgets.QLineEdit(self.formLayoutWidget)
self.wifi_command_lineEdit_3.setObjectName("wifi_command_lineEdit_3")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.wifi_command_lineEdit_3)
self.wifi_command_pushButton_2 = QtWidgets.QPushButton(self.formLayoutWidget)
self.wifi_command_pushButton_2.setObjectName("wifi_command_pushButton_2")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.wifi_command_pushButton_2)
self.wifi_command_pushButton_3 = QtWidgets.QPushButton(self.formLayoutWidget)
self.wifi_command_pushButton_3.setObjectName("wifi_command_pushButton_3")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.wifi_command_pushButton_3)
self.groupBox_4 = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_4.setGeometry(QtCore.QRect(370, 460, 591, 131))
self.groupBox_4.setObjectName("groupBox_4")
self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.groupBox_4)
self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(10, 20, 571, 31))
self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.left_lineEdit_1 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_2)
self.left_lineEdit_1.setObjectName("left_lineEdit_1")
self.horizontalLayout_2.addWidget(self.left_lineEdit_1)
self.horizontalSlider_1 = QtWidgets.QSlider(self.horizontalLayoutWidget_2)
self.horizontalSlider_1.setMinimum(-100)
self.horizontalSlider_1.setMaximum(100)
self.horizontalSlider_1.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSlider_1.setTickPosition(QtWidgets.QSlider.TicksAbove)
self.horizontalSlider_1.setTickInterval(10)
self.horizontalSlider_1.setObjectName("horizontalSlider_1")
self.horizontalLayout_2.addWidget(self.horizontalSlider_1)
self.right_lineEdit_1 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_2)
self.right_lineEdit_1.setObjectName("right_lineEdit_1")
self.horizontalLayout_2.addWidget(self.right_lineEdit_1)
self.label = QtWidgets.QLabel(self.horizontalLayoutWidget_2)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
self.command_lineEdit_1 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_2)
self.command_lineEdit_1.setObjectName("command_lineEdit_1")
self.horizontalLayout_2.addWidget(self.command_lineEdit_1)
self.label_4 = QtWidgets.QLabel(self.horizontalLayoutWidget_2)
self.label_4.setObjectName("label_4")
self.horizontalLayout_2.addWidget(self.label_4)
self.num_lineEdit_1 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_2)
self.num_lineEdit_1.setObjectName("num_lineEdit_1")
self.horizontalLayout_2.addWidget(self.num_lineEdit_1)
self.horizontalLayout_2.setStretch(0, 1)
self.horizontalLayout_2.setStretch(1, 18)
self.horizontalLayout_2.setStretch(2, 1)
self.horizontalLayout_2.setStretch(3, 1)
self.horizontalLayout_2.setStretch(4, 1)
self.horizontalLayout_2.setStretch(5, 1)
self.horizontalLayout_2.setStretch(6, 1)
self.horizontalLayoutWidget_3 = QtWidgets.QWidget(self.groupBox_4)
self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(10, 50, 571, 31))
self.horizontalLayoutWidget_3.setObjectName("horizontalLayoutWidget_3")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_3)
self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.wifi_command_lineEdit_2 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_6) self.left_lineEdit_2 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_3)
self.wifi_command_lineEdit_2.setObjectName("wifi_command_lineEdit_2") self.left_lineEdit_2.setObjectName("left_lineEdit_2")
self.horizontalLayout_5.addWidget(self.wifi_command_lineEdit_2) self.horizontalLayout_5.addWidget(self.left_lineEdit_2)
self.wifi_command_pushButton_2 = QtWidgets.QPushButton(self.horizontalLayoutWidget_6) self.horizontalSlider_2 = QtWidgets.QSlider(self.horizontalLayoutWidget_3)
self.wifi_command_pushButton_2.setObjectName("wifi_command_pushButton_2") self.horizontalSlider_2.setMinimum(-100)
self.horizontalLayout_5.addWidget(self.wifi_command_pushButton_2) self.horizontalSlider_2.setMaximum(100)
self.horizontalLayoutWidget_7 = QtWidgets.QWidget(self.groupBox_3) self.horizontalSlider_2.setOrientation(QtCore.Qt.Horizontal)
self.horizontalLayoutWidget_7.setGeometry(QtCore.QRect(10, 80, 271, 31)) self.horizontalSlider_2.setTickPosition(QtWidgets.QSlider.TicksAbove)
self.horizontalLayoutWidget_7.setObjectName("horizontalLayoutWidget_7") self.horizontalSlider_2.setTickInterval(10)
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_7) self.horizontalSlider_2.setObjectName("horizontalSlider_2")
self.horizontalLayout_5.addWidget(self.horizontalSlider_2)
self.right_lineEdit_2 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_3)
self.right_lineEdit_2.setObjectName("right_lineEdit_2")
self.horizontalLayout_5.addWidget(self.right_lineEdit_2)
self.label_5 = QtWidgets.QLabel(self.horizontalLayoutWidget_3)
self.label_5.setObjectName("label_5")
self.horizontalLayout_5.addWidget(self.label_5)
self.command_lineEdit_2 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_3)
self.command_lineEdit_2.setObjectName("command_lineEdit_2")
self.horizontalLayout_5.addWidget(self.command_lineEdit_2)
self.label_6 = QtWidgets.QLabel(self.horizontalLayoutWidget_3)
self.label_6.setObjectName("label_6")
self.horizontalLayout_5.addWidget(self.label_6)
self.num_lineEdit_2 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_3)
self.num_lineEdit_2.setObjectName("num_lineEdit_2")
self.horizontalLayout_5.addWidget(self.num_lineEdit_2)
self.horizontalLayout_5.setStretch(0, 1)
self.horizontalLayout_5.setStretch(1, 18)
self.horizontalLayout_5.setStretch(2, 1)
self.horizontalLayout_5.setStretch(3, 1)
self.horizontalLayout_5.setStretch(4, 1)
self.horizontalLayout_5.setStretch(5, 1)
self.horizontalLayout_5.setStretch(6, 1)
self.horizontalLayoutWidget_5 = QtWidgets.QWidget(self.groupBox_4)
self.horizontalLayoutWidget_5.setGeometry(QtCore.QRect(10, 80, 571, 31))
self.horizontalLayoutWidget_5.setObjectName("horizontalLayoutWidget_5")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_5)
self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.wifi_command_lineEdit_3 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_7) self.left_lineEdit_3 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_5)
self.wifi_command_lineEdit_3.setObjectName("wifi_command_lineEdit_3") self.left_lineEdit_3.setObjectName("left_lineEdit_3")
self.horizontalLayout_6.addWidget(self.wifi_command_lineEdit_3) self.horizontalLayout_6.addWidget(self.left_lineEdit_3)
self.wifi_command_pushButton_3 = QtWidgets.QPushButton(self.horizontalLayoutWidget_7) self.horizontalSlider_3 = QtWidgets.QSlider(self.horizontalLayoutWidget_5)
self.wifi_command_pushButton_3.setObjectName("wifi_command_pushButton_3") self.horizontalSlider_3.setMinimum(-100)
self.horizontalLayout_6.addWidget(self.wifi_command_pushButton_3) self.horizontalSlider_3.setMaximum(100)
self.horizontalSlider_3.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSlider_3.setTickPosition(QtWidgets.QSlider.TicksAbove)
self.horizontalSlider_3.setTickInterval(10)
self.horizontalSlider_3.setObjectName("horizontalSlider_3")
self.horizontalLayout_6.addWidget(self.horizontalSlider_3)
self.right_lineEdit_3 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_5)
self.right_lineEdit_3.setObjectName("right_lineEdit_3")
self.horizontalLayout_6.addWidget(self.right_lineEdit_3)
self.label_7 = QtWidgets.QLabel(self.horizontalLayoutWidget_5)
self.label_7.setObjectName("label_7")
self.horizontalLayout_6.addWidget(self.label_7)
self.command_lineEdit_3 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_5)
self.command_lineEdit_3.setObjectName("command_lineEdit_3")
self.horizontalLayout_6.addWidget(self.command_lineEdit_3)
self.label_8 = QtWidgets.QLabel(self.horizontalLayoutWidget_5)
self.label_8.setObjectName("label_8")
self.horizontalLayout_6.addWidget(self.label_8)
self.num_lineEdit_3 = QtWidgets.QLineEdit(self.horizontalLayoutWidget_5)
self.num_lineEdit_3.setObjectName("num_lineEdit_3")
self.horizontalLayout_6.addWidget(self.num_lineEdit_3)
self.horizontalLayout_6.setStretch(0, 1)
self.horizontalLayout_6.setStretch(1, 18)
self.horizontalLayout_6.setStretch(2, 1)
self.horizontalLayout_6.setStretch(3, 1)
self.horizontalLayout_6.setStretch(4, 1)
self.horizontalLayout_6.setStretch(5, 1)
self.horizontalLayout_6.setStretch(6, 1)
MainWindow.setCentralWidget(self.centralwidget) MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1187, 26)) self.menubar.setGeometry(QtCore.QRect(0, 0, 1187, 26))
@ -137,12 +213,27 @@ class Ui_MainWindow(object):
self.groupBox.setTitle(_translate("MainWindow", "wifi_IP")) self.groupBox.setTitle(_translate("MainWindow", "wifi_IP"))
self.wifi_IP_lineEdit.setText(_translate("MainWindow", "192.168.4.2")) self.wifi_IP_lineEdit.setText(_translate("MainWindow", "192.168.4.2"))
self.wifi_config_pushButton.setText(_translate("MainWindow", "设置")) self.wifi_config_pushButton.setText(_translate("MainWindow", "设置"))
self.label.setText(_translate("MainWindow", "速度:")) self.groupBox_2.setTitle(_translate("MainWindow", "可视化图表"))
self.velocity_lineEdit.setText(_translate("MainWindow", "0"))
self.label_2.setText(_translate("MainWindow", "目标角度:"))
self.angle_lineEdit.setText(_translate("MainWindow", "149"))
self.groupBox_2.setTitle(_translate("MainWindow", "GroupBox"))
self.groupBox_3.setTitle(_translate("MainWindow", "command命令")) self.groupBox_3.setTitle(_translate("MainWindow", "command命令"))
self.wifi_command_pushButton_1.setText(_translate("MainWindow", "发送")) self.wifi_command_pushButton_1.setText(_translate("MainWindow", "发送"))
self.wifi_command_pushButton_2.setText(_translate("MainWindow", "发送")) self.wifi_command_pushButton_2.setText(_translate("MainWindow", "发送"))
self.wifi_command_pushButton_3.setText(_translate("MainWindow", "发送")) self.wifi_command_pushButton_3.setText(_translate("MainWindow", "发送"))
self.groupBox_4.setTitle(_translate("MainWindow", "滑条command命令"))
self.left_lineEdit_1.setText(_translate("MainWindow", "0"))
self.right_lineEdit_1.setText(_translate("MainWindow", "15"))
self.label.setText(_translate("MainWindow", "command:"))
self.command_lineEdit_1.setText(_translate("MainWindow", "K11"))
self.label_4.setText(_translate("MainWindow", "num:"))
self.num_lineEdit_1.setText(_translate("MainWindow", "0"))
self.left_lineEdit_2.setText(_translate("MainWindow", "0"))
self.right_lineEdit_2.setText(_translate("MainWindow", "3"))
self.label_5.setText(_translate("MainWindow", "command:"))
self.command_lineEdit_2.setText(_translate("MainWindow", "K12"))
self.label_6.setText(_translate("MainWindow", "num:"))
self.num_lineEdit_2.setText(_translate("MainWindow", "0"))
self.left_lineEdit_3.setText(_translate("MainWindow", "0"))
self.right_lineEdit_3.setText(_translate("MainWindow", "1.5"))
self.label_7.setText(_translate("MainWindow", "command:"))
self.command_lineEdit_3.setText(_translate("MainWindow", "K13"))
self.label_8.setText(_translate("MainWindow", "num:"))
self.num_lineEdit_3.setText(_translate("MainWindow", "0"))

View File

@ -56,94 +56,17 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>590</x>
<y>480</y>
<width>104</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>速度:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="velocity_lineEdit">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QSlider" name="velocity_horizontalSlider">
<property name="geometry">
<rect>
<x>430</x>
<y>460</y>
<width>261</width>
<height>22</height>
</rect>
</property>
<property name="minimum">
<number>-150</number>
</property>
<property name="maximum">
<number>150</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
<rect>
<x>420</x>
<y>480</y>
<width>134</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>目标角度:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="angle_lineEdit">
<property name="text">
<string>149</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>370</x> <x>370</x>
<y>10</y> <y>10</y>
<width>811</width> <width>811</width>
<height>431</height> <height>441</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>GroupBox</string> <string>可视化图表</string>
</property> </property>
<widget class="QWidget" name="gridLayoutWidget"> <widget class="QWidget" name="gridLayoutWidget">
<property name="geometry"> <property name="geometry">
@ -160,7 +83,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>370</y> <y>380</y>
<width>791</width> <width>791</width>
<height>51</height> <height>51</height>
</rect> </rect>
@ -172,75 +95,283 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>20</y> <y>10</y>
<width>291</width> <width>291</width>
<height>121</height> <height>321</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>command命令</string> <string>command命令</string>
</property> </property>
<widget class="QWidget" name="horizontalLayoutWidget_5"> <widget class="QWidget" name="formLayoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>271</width> <width>271</width>
<height>31</height> <height>291</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QFormLayout" name="formLayout">
<item> <item row="0" column="0">
<widget class="QLineEdit" name="wifi_command_lineEdit_1"/> <widget class="QLineEdit" name="wifi_command_lineEdit_1"/>
</item> </item>
<item> <item row="0" column="1">
<widget class="QPushButton" name="wifi_command_pushButton_1"> <widget class="QPushButton" name="wifi_command_pushButton_1">
<property name="text"> <property name="text">
<string>发送</string> <string>发送</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="1" column="0">
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_6">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>271</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLineEdit" name="wifi_command_lineEdit_2"/> <widget class="QLineEdit" name="wifi_command_lineEdit_2"/>
</item> </item>
<item> <item row="2" column="0">
<widget class="QLineEdit" name="wifi_command_lineEdit_3"/>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="wifi_command_pushButton_2"> <widget class="QPushButton" name="wifi_command_pushButton_2">
<property name="text"> <property name="text">
<string>发送</string> <string>发送</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QPushButton" name="wifi_command_pushButton_3">
<property name="text">
<string>发送</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="horizontalLayoutWidget_7"> </widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
<rect>
<x>370</x>
<y>460</y>
<width>591</width>
<height>131</height>
</rect>
</property>
<property name="title">
<string>滑条command命令</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>571</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,18,1,1,1,1,1">
<item>
<widget class="QLineEdit" name="left_lineEdit_1">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider_1">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="right_lineEdit_1">
<property name="text">
<string>15</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>command:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="command_lineEdit_1">
<property name="text">
<string>K11</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>num:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="num_lineEdit_1">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>571</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="1,18,1,1,1,1,1">
<item>
<widget class="QLineEdit" name="left_lineEdit_2">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider_2">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="right_lineEdit_2">
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>command:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="command_lineEdit_2">
<property name="text">
<string>K12</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>num:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="num_lineEdit_2">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_5">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>80</y> <y>80</y>
<width>271</width> <width>571</width>
<height>31</height> <height>31</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,18,1,1,1,1,1">
<item> <item>
<widget class="QLineEdit" name="wifi_command_lineEdit_3"/> <widget class="QLineEdit" name="left_lineEdit_3">
<property name="text">
<string>0</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="wifi_command_pushButton_3"> <widget class="QSlider" name="horizontalSlider_3">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="right_lineEdit_3">
<property name="text"> <property name="text">
<string>发送</string> <string>1.5</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>command:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="command_lineEdit_3">
<property name="text">
<string>K13</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>num:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="num_lineEdit_3">
<property name="text">
<string>0</string>
</property> </property>
</widget> </widget>
</item> </item>