mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-05-26 23:19:33 +00:00
Added ui ability to send aruco map files
This commit is contained in:
@@ -385,6 +385,12 @@ class Client:
|
||||
{'section': option.section, 'option': option.option, 'value': option.value}))
|
||||
Client.send_to_selected(Client.form_message("config_reload"))
|
||||
|
||||
@staticmethod
|
||||
def get_by_id(copter_id):
|
||||
for copter in Client.clients.values():
|
||||
if copter.copter_id == copter_id:
|
||||
return copter
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
server = Server()
|
||||
|
||||
@@ -11,7 +11,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
MainWindow.setObjectName("MainWindow")
|
||||
MainWindow.resize(1257, 770)
|
||||
MainWindow.resize(1239, 706)
|
||||
self.centralwidget = QtWidgets.QWidget(MainWindow)
|
||||
self.centralwidget.setEnabled(True)
|
||||
self.centralwidget.setObjectName("centralwidget")
|
||||
@@ -65,20 +65,23 @@ class Ui_MainWindow(object):
|
||||
self.takeoff_button = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.takeoff_button.setEnabled(True)
|
||||
self.takeoff_button.setObjectName("takeoff_button")
|
||||
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.takeoff_button)
|
||||
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.SpanningRole, self.takeoff_button)
|
||||
self.land_button = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.land_button.setObjectName("land_button")
|
||||
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.SpanningRole, self.land_button)
|
||||
self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.SpanningRole, self.land_button)
|
||||
self.disarm_button = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.disarm_button.setObjectName("disarm_button")
|
||||
self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.SpanningRole, self.disarm_button)
|
||||
self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.disarm_button)
|
||||
self.leds_button = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.leds_button.setObjectName("leds_button")
|
||||
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.leds_button)
|
||||
self.verticalLayout.addLayout(self.formLayout_2)
|
||||
self.horizontalLayout.addLayout(self.verticalLayout)
|
||||
self.horizontalLayout.setStretch(0, 1)
|
||||
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QtWidgets.QMenuBar(MainWindow)
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 1257, 39))
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 1239, 39))
|
||||
self.menubar.setObjectName("menubar")
|
||||
self.menuOptions = QtWidgets.QMenu(self.menubar)
|
||||
self.menuOptions.setObjectName("menuOptions")
|
||||
@@ -87,8 +90,11 @@ class Ui_MainWindow(object):
|
||||
self.action_send_animations.setObjectName("action_send_animations")
|
||||
self.action_send_configurations = QtWidgets.QAction(MainWindow)
|
||||
self.action_send_configurations.setObjectName("action_send_configurations")
|
||||
self.action_send_Aruco_map = QtWidgets.QAction(MainWindow)
|
||||
self.action_send_Aruco_map.setObjectName("action_send_Aruco_map")
|
||||
self.menuOptions.addAction(self.action_send_animations)
|
||||
self.menuOptions.addAction(self.action_send_configurations)
|
||||
self.menuOptions.addAction(self.action_send_Aruco_map)
|
||||
self.menubar.addAction(self.menuOptions.menuAction())
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
@@ -106,9 +112,11 @@ class Ui_MainWindow(object):
|
||||
self.takeoff_button.setText(_translate("MainWindow", "Takeoff"))
|
||||
self.land_button.setText(_translate("MainWindow", "Land"))
|
||||
self.disarm_button.setText(_translate("MainWindow", "Disarm"))
|
||||
self.leds_button.setText(_translate("MainWindow", "Test leds"))
|
||||
self.menuOptions.setTitle(_translate("MainWindow", "Actions"))
|
||||
self.action_send_animations.setText(_translate("MainWindow", "Send Animations"))
|
||||
self.action_send_configurations.setText(_translate("MainWindow", "Send Configurations"))
|
||||
self.action_send_Aruco_map.setText(_translate("MainWindow", "Send Aruco map"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1257</width>
|
||||
<height>770</height>
|
||||
<width>1239</width>
|
||||
<height>706</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -102,7 +102,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="takeoff_button">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@@ -112,20 +112,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="land_button">
|
||||
<property name="text">
|
||||
<string>Land</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="disarm_button">
|
||||
<property name="text">
|
||||
<string>Disarm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="leds_button">
|
||||
<property name="text">
|
||||
<string>Test leds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -139,7 +146,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1257</width>
|
||||
<width>1239</width>
|
||||
<height>39</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -149,6 +156,7 @@
|
||||
</property>
|
||||
<addaction name="action_send_animations"/>
|
||||
<addaction name="action_send_configurations"/>
|
||||
<addaction name="action_send_Aruco_map"/>
|
||||
</widget>
|
||||
<addaction name="menuOptions"/>
|
||||
</widget>
|
||||
@@ -162,6 +170,11 @@
|
||||
<string>Send Configurations</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_send_Aruco_map">
|
||||
<property name="text">
|
||||
<string>Send Aruco map</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -35,6 +35,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
self.ui.action_send_animations.triggered.connect(self.send_animations)
|
||||
self.ui.action_send_configurations.triggered.connect(self.send_configurations)
|
||||
self.ui.action_send_Aruco_map.triggered.connect(self.send_aruco)
|
||||
|
||||
#Initing table and table model
|
||||
self.ui.tableView.setModel(model)
|
||||
@@ -43,6 +44,16 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
@pyqtSlot()
|
||||
def check_selected(self):
|
||||
#Client.request_to_selected("selfcheck")
|
||||
#for row_num in range(model.rowCount()):
|
||||
# item = model.index(row_num, 0)
|
||||
# data = model.itemData(item)
|
||||
# print(item.data())
|
||||
# print(item, data)
|
||||
# if data.isCheckable() and data.checkState() == Qt.Checked:
|
||||
# print("Copter checked")
|
||||
# batt = Client.get_by_id(data.text()).get_response("batt_voltage")
|
||||
# model.setData(model.index(0, 2), batt)
|
||||
|
||||
self.ui.start_button.setEnabled(True)
|
||||
self.ui.takeoff_button.setEnabled(True)
|
||||
|
||||
@@ -107,6 +118,15 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
options.append(ConfigOption(section, option, value))
|
||||
Client.send_config_options(*options)
|
||||
|
||||
@pyqtSlot()
|
||||
def send_aruco(self):
|
||||
path = QFileDialog.getOpenFileName(self, "Select aruco map configuration file", filter="Configs (*.txt)")[0]
|
||||
if path:
|
||||
filename = os.path.basename(path)
|
||||
print("Selected file:", path, filename)
|
||||
for copter in Client.clients.values():
|
||||
copter.send_file(path, "/home/pi/catkin_ws/src/clever/aruco_pose/map/animation_map.txt")
|
||||
|
||||
|
||||
model = QStandardItemModel()
|
||||
model.setHorizontalHeaderLabels(
|
||||
@@ -117,11 +137,9 @@ model.setRowCount(0)
|
||||
|
||||
|
||||
def client_connected(self: Client):
|
||||
batt = self.get_response("batt_voltage")
|
||||
model.appendRow((QStandardItem(self.copter_id), )) # TODO: get responses for another columns
|
||||
model.setData(model.index(0, 2), batt)
|
||||
|
||||
|
||||
copter_id_item = QStandardItem(self.copter_id)
|
||||
copter_id_item.setCheckable(True)
|
||||
model.appendRow((copter_id_item, )) # TODO: get responses for another columns
|
||||
|
||||
|
||||
Client.on_connect = client_connected
|
||||
|
||||
Reference in New Issue
Block a user