123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import time
- from concurrent.futures import ThreadPoolExecutor
- from PyQt5.QtCore import QTimer,Qt
- from PyQt5.QtWidgets import QFrame, QLabel, QPushButton,QCheckBox
- import Count
- import MapGLWidget as viewer
- class JointControlFrame(QFrame):
- threadPool_ = ThreadPoolExecutor(5)
- def __init__(self, robot1, robot2):
- QFrame.__init__(self)
- self.targetId_ = None
- self.begId_ = None
- self.robot1 = robot1
- self.robot2 = robot2
- self.robot1_parameters = dict()
- self.robot2_parameters = dict()
- self.InitUI()
- self.setFrameShape(self.StyledPanel)
- self.timer_ = QTimer()
- self.timer_.timeout.connect(self.Update)
- self.timer_.start(100)
- def testadjust(self, beg, target):
- autoDirect = True
- self.threadPool_.submit(self.robot1.Navigatting,
- beg, target, autoDirect)
- time.sleep(2)
- self.threadPool_.submit(self.robot2.Navigatting,
- beg, target, autoDirect)
- def InitUI(self):
- self.btnSend = QPushButton(self)
- self.btnSend.setGeometry(80, 5, 100, 40)
- self.btnSend.setText("双单车协动")
- self.btnSend.clicked.connect(self.btnSendClick)
- self.btnCancel = QPushButton(self)
- self.btnCancel.setGeometry(200, 5, 100, 40)
- self.btnCancel.setText(" 取消")
- self.btnCancel.clicked.connect(self.btnCancelClick)
- def Update(self):
- if self.robot1.IsNavigating() is True or self.robot2.IsNavigating() is True:
- if self.btnSend.isEnabled():
- self.btnSend.setEnabled(False)
- else:
- self.btnSend.setEnabled(True)
- def btnSendClick(self):
- autoDirect = True
- self.threadPool_.submit(self.robot1.Navigatting,
- self.robot1_parameters["begId_"], self.robot1_parameters["targetId_"], autoDirect, "DoubleAGV")
- time.sleep(0.5)
- self.threadPool_.submit(self.robot2.Navigatting,
- self.robot2_parameters["begId_"], self.robot2_parameters["targetId_"], autoDirect, "DoubleAGV")
- def btnCancelClick(self):
- self.threadPool_.submit(self.robot1.CancelNavTask)
- self.threadPool_.submit(self.robot2.CancelNavTask)
- def SetRobot1_BaTID(self, begId_, targetId_):
- self.robot1_parameters["begId_"] = begId_
- self.robot1_parameters["targetId_"] = targetId_
- def SetRobot2_BaTID(self, begId_, targetId_):
- self.robot2_parameters["begId_"] = begId_
- self.robot2_parameters["targetId_"] = targetId_
- class CountFrame(QFrame):
- def __init__(self):
- QFrame.__init__(self)
- self.InitUI()
- self.timer_ = QTimer()
- self.timer_.timeout.connect(self.UpdateUI)
- self.timer_.start(200)
- def InitUI(self):
- self.static1 = QLabel(self)
- self.static1.setText("重载导航次数 : /")
- #self.static1.setGeometry(5, 5, 100, 30)
- self.static2 = QLabel(self)
- self.static2.setText("单车导航次数 : /")
- #self.static2.setGeometry(5, 40, 100, 30)
- self.btnFrontCheck = QCheckBox("前车地图", self)
- self.btnFrontCheck.setGeometry(5, 5, 40, 30)
- self.btnFrontCheck.clicked.connect(self.FrontChecked)
- self.btnBackCheck = QCheckBox("后车地图", self)
- self.btnBackCheck.setGeometry(260, 40, 40, 30)
- self.btnBackCheck.clicked.connect(self.FrontChecked)
- self.btnMainCheck = QCheckBox("整车地图", self)
- self.btnMainCheck.setGeometry(310, 40, 40, 30)
- self.btnMainCheck.clicked.connect(self.FrontChecked)
- self.btnBaseCheck = QCheckBox("原始地图", self)
- self.btnBaseCheck.setGeometry(360, 40, 40, 30)
- self.btnBaseCheck.clicked.connect(self.FrontChecked)
- def UpdateUI(self):
- load_str = "重载导航次数 : %d" % (Count.TestCount().loadCount())
- single_str = "单车导航次数 : %d" % (Count.TestCount().singleCount())
- self.static1.setText(load_str)
- self.static2.setText(single_str)
- def FrontChecked(self):
- maps=[]
- if self.btnFrontCheck.checkState() == Qt.Checked:
- maps.append("Front")
- if self.btnBackCheck.checkState() == Qt.Checked:
- maps.append("Back")
- if self.btnMainCheck.checkState() == Qt.Checked:
- maps.append("Main")
- if self.btnBaseCheck.checkState() == Qt.Checked:
- maps.append("Base")
- view=viewer.MapGLWidget()
- view.SetMaps(maps)
|