上位机添加了调试模式,可以显示原始文本数据。更新了物料清单里面的电机购买链接
parent
3b5ff6d51c
commit
f69c3008c8
|
@ -135,10 +135,14 @@ void setup() {
|
|||
ESP.restart();
|
||||
}
|
||||
// eeprom 读取
|
||||
|
||||
float nan = EEPROM.readFloat(0);
|
||||
int k,j;
|
||||
j = 0;
|
||||
for(k=0;k<=24;k=k+4)
|
||||
{
|
||||
float nan = EEPROM.readFloat(k);
|
||||
if(isnan(nan))
|
||||
{
|
||||
j = 1;
|
||||
Serial.println("frist write");
|
||||
EEPROM.writeFloat(0, target_angle); delay(10);EEPROM.commit();
|
||||
EEPROM.writeFloat(4, swing_up_voltage); delay(10);EEPROM.commit();
|
||||
|
@ -148,7 +152,8 @@ if(isnan(nan))
|
|||
EEPROM.writeFloat(20, v_p_2); delay(10);EEPROM.commit();
|
||||
EEPROM.writeFloat(24, v_i_2); delay(10);EEPROM.commit();
|
||||
}
|
||||
else
|
||||
}
|
||||
if(j == 0)
|
||||
{
|
||||
target_angle = EEPROM.readFloat(0);
|
||||
swing_up_voltage = EEPROM.readFloat(4);
|
||||
|
@ -364,12 +369,14 @@ if (abs(pendulum_angle) < swing_up_angle) // if angle small enough stabilize 0.5
|
|||
Serial.print(pitch);Serial.print("\t");
|
||||
Serial.print(kalAngleZ);Serial.print("\t");
|
||||
|
||||
// Serial.print(target_voltage);Serial.print("\t");
|
||||
//// Serial.print(target_velocity);Serial.print("\t");
|
||||
// Serial.print(motor.shaft_velocity);Serial.print("\t");
|
||||
// Serial.print(target_angle);Serial.print("\t");
|
||||
// Serial.print(pendulum_angle);Serial.print("\t");
|
||||
// Serial.print(gyroZrate);Serial.print("\t");
|
||||
Serial.print(target_voltage);Serial.print("\t");
|
||||
// Serial.print(target_velocity);Serial.print("\t");
|
||||
Serial.print(motor.shaft_velocity);Serial.print("\t");
|
||||
Serial.print(motor.voltage.q);Serial.print("\t");
|
||||
|
||||
Serial.print(target_angle);Serial.print("\t");
|
||||
Serial.print(pendulum_angle);Serial.print("\t");
|
||||
Serial.print(gyroZrate);Serial.print("\t");
|
||||
Serial.print("\r\n");
|
||||
#endif
|
||||
// motor.move(target_velocity);
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox
|
||||
from PyQt5.QtGui import QTextCursor
|
||||
from main_ui import *
|
||||
from wifi_udp import *
|
||||
import threading #引入并行
|
||||
|
@ -7,12 +8,13 @@ import numpy as np
|
|||
import pyqtgraph as pg
|
||||
import re
|
||||
from sharedcomponets import GUIToolKit
|
||||
import copy
|
||||
|
||||
class MyWindow(QMainWindow, Ui_MainWindow):
|
||||
signalColors = [GUIToolKit.RED_COLOR, GUIToolKit.BLUE_COLOR, GUIToolKit.PURPLE_COLOR, GUIToolKit.YELLOW_COLOR,
|
||||
GUIToolKit.MAROON_COLOR, GUIToolKit.ORANGE_COLOR, GUIToolKit.GREEN_COLOR]
|
||||
signalIcons = ['reddot', 'bluedot', 'purpledot', 'yellowdot', 'maroondot', 'orangedot', 'greendot']
|
||||
|
||||
textColors = ['FF5C5C','398AD9','5BEC8D','FD42AC','FF33FF','4B8200','DE87B8']
|
||||
def __init__(self, parent=None):
|
||||
super(MyWindow, self).__init__(parent)
|
||||
self.setupUi(self)
|
||||
|
@ -23,8 +25,6 @@ class MyWindow(QMainWindow, Ui_MainWindow):
|
|||
# self.CreateItems()
|
||||
# 设置信号与槽
|
||||
self.CreateSignalSlot()
|
||||
|
||||
|
||||
# 设置信号与槽
|
||||
def CreateSignalSlot(self):
|
||||
self.horizontalSlider_1.valueChanged.connect(self.horizontalSlider_1_valueChanged)
|
||||
|
@ -41,6 +41,25 @@ class MyWindow(QMainWindow, Ui_MainWindow):
|
|||
self.VI1_pushButton.clicked.connect(self.VI1_pushButton_clicked)
|
||||
self.VP2_pushButton.clicked.connect(self.VP2_pushButton_clicked)
|
||||
self.VI2_pushButton.clicked.connect(self.VI2_pushButton_clicked)
|
||||
|
||||
self.raw_pushButton.clicked.connect(self.raw_pushButton_clicked)
|
||||
self.wave_pushButton.clicked.connect(self.wave_pushButton_clicked)
|
||||
def raw_pushButton_clicked(self):
|
||||
self.change_state = 1
|
||||
self.stackedWidget.setCurrentIndex(1)
|
||||
# for i in range(self.gridLayout.count()):
|
||||
# self.gridLayout.removeWidget(self.gridLayout.itemAt(i).widget())
|
||||
# self.gridLayout.addWidget(self.raw_line)
|
||||
|
||||
def wave_pushButton_clicked(self):
|
||||
self.change_state = 0
|
||||
self.stackedWidget.setCurrentIndex(0)
|
||||
# for i in range(self.gridLayout.count()):
|
||||
# self.gridLayout.removeWidget(self.gridLayout.itemAt(i).widget())
|
||||
#
|
||||
#
|
||||
# self.gridLayout.addWidget(self.plotWidget)
|
||||
|
||||
# 设置实例
|
||||
def CreateItems(self):
|
||||
# 定时器-绘图刷新
|
||||
|
@ -54,7 +73,9 @@ class MyWindow(QMainWindow, Ui_MainWindow):
|
|||
# wifi变量
|
||||
self.wifi_recv_flag = 0
|
||||
self.close_flag = 1
|
||||
self.change_state = 0
|
||||
self.re_item = []
|
||||
self.raw_roll = 0
|
||||
def plot_init(self):
|
||||
# 绘图对象
|
||||
pg.setConfigOptions(antialias=True)
|
||||
|
@ -81,8 +102,16 @@ class MyWindow(QMainWindow, Ui_MainWindow):
|
|||
self.signalPlotFlags.append(True)
|
||||
# add callback
|
||||
checkBox.stateChanged.connect(self.signalPlotFlagUpdate)
|
||||
self.gridLayout.addWidget(self.plotWidget)
|
||||
self.stackedWidget = QtWidgets.QStackedWidget()
|
||||
self.gridLayout.addWidget(self.stackedWidget)
|
||||
self.raw_line = QtWidgets.QTextEdit()
|
||||
self.raw_line.setStyleSheet('background: rgb(0, 0, 0)')
|
||||
self.stackedWidget.addWidget(self.plotWidget)
|
||||
self.stackedWidget.addWidget(self.raw_line)
|
||||
self.tool_layout.addWidget(self.controlPlotWidget)
|
||||
|
||||
|
||||
|
||||
# checkbox
|
||||
def signalPlotFlagUpdate(self):
|
||||
for i, (checkBox, plotFlag) in enumerate(zip(self.controlPlotWidget.signalCheckBox, self.signalPlotFlags)):
|
||||
|
@ -178,16 +207,23 @@ class MyWindow(QMainWindow, Ui_MainWindow):
|
|||
recv_data = recv_data.split(',')
|
||||
"""处理接受的信息"""
|
||||
# print(recv_data)
|
||||
self.re_text = ''
|
||||
for i, data in enumerate(recv_data):
|
||||
if self.signalPlotFlags[i]:
|
||||
self.re_item.append(''.join(re.split(r'[^A-Za-z]', data)))
|
||||
# self.re_item.append(''.join(re.split(r'[^A-Za-z]', data)))
|
||||
data = data.replace(self.re_item[i],'')
|
||||
|
||||
if self.change_state:
|
||||
self.re_text += '<font color=\"#{1}\">{0}\t</font>'.format(data,self.textColors[i])
|
||||
else:
|
||||
self.signalDataArrays[i] = np.roll(self.signalDataArrays[i], -1)
|
||||
self.signalDataArrays[i][-1] = data
|
||||
|
||||
def update_plot(self):
|
||||
if self.wifi_recv_flag:
|
||||
if self.change_state:
|
||||
self.raw_line.append(self.re_text)
|
||||
if self.raw_roll:
|
||||
self.raw_line.moveCursor(QTextCursor.End)
|
||||
else:
|
||||
for i, plotFlag in enumerate(self.signalPlotFlags):
|
||||
if plotFlag:
|
||||
self.signalPlots[i].setData(self.timeArray, self.signalDataArrays[i])
|
||||
|
@ -196,6 +232,7 @@ class MyWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
|
||||
print("关闭")
|
||||
self.udp.send_message('START')
|
||||
self.close_flag = 0
|
||||
self.udp.udpClientSocket.close()
|
||||
|
||||
|
@ -247,6 +284,9 @@ class ControlPlotPanel(QtWidgets.QWidget):
|
|||
self.signalCheckBox.append(checkBox)
|
||||
self.horizontalLayout1.addWidget(checkBox)
|
||||
def zoomAllPlot(self):
|
||||
if self.controlledPlot.change_state:
|
||||
self.controlledPlot.raw_roll = ~self.controlledPlot.raw_roll
|
||||
else:
|
||||
self.controlledPlot.plotWidget.enableAutoRange()
|
||||
def wifi_recv_open_pushButton_clicked(self):
|
||||
if self.controlledPlot.wifi_recv_flag == 0:
|
||||
|
|
|
@ -54,6 +54,12 @@ class Ui_MainWindow(object):
|
|||
self.tool_layout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_6)
|
||||
self.tool_layout_2.setContentsMargins(0, 0, 0, 0)
|
||||
self.tool_layout_2.setObjectName("tool_layout_2")
|
||||
self.wave_pushButton = QtWidgets.QPushButton(self.horizontalLayoutWidget_6)
|
||||
self.wave_pushButton.setObjectName("wave_pushButton")
|
||||
self.tool_layout_2.addWidget(self.wave_pushButton)
|
||||
self.raw_pushButton = QtWidgets.QPushButton(self.horizontalLayoutWidget_6)
|
||||
self.raw_pushButton.setObjectName("raw_pushButton")
|
||||
self.tool_layout_2.addWidget(self.raw_pushButton)
|
||||
self.groupBox_3 = QtWidgets.QGroupBox(self.centralwidget)
|
||||
self.groupBox_3.setGeometry(QtCore.QRect(10, 10, 291, 381))
|
||||
self.groupBox_3.setObjectName("groupBox_3")
|
||||
|
@ -354,6 +360,8 @@ class Ui_MainWindow(object):
|
|||
self.wifi_IP_lineEdit.setText(_translate("MainWindow", "192.168.4.2"))
|
||||
self.wifi_config_pushButton.setText(_translate("MainWindow", "设置"))
|
||||
self.groupBox_2.setTitle(_translate("MainWindow", "可视化图表"))
|
||||
self.wave_pushButton.setText(_translate("MainWindow", "波形图"))
|
||||
self.raw_pushButton.setText(_translate("MainWindow", "原始数据"))
|
||||
self.groupBox_3.setTitle(_translate("MainWindow", "command命令"))
|
||||
self.wifi_command_pushButton_1.setText(_translate("MainWindow", "发送"))
|
||||
self.wifi_command_pushButton_2.setText(_translate("MainWindow", "发送"))
|
||||
|
|
|
@ -99,7 +99,22 @@
|
|||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="tool_layout_2"/>
|
||||
<layout class="QHBoxLayout" name="tool_layout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="wave_pushButton">
|
||||
<property name="text">
|
||||
<string>波形图</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="raw_pushButton">
|
||||
<property name="text">
|
||||
<string>原始数据</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
|
|
Loading…
Reference in New Issue