class MainWindow(QMainWindow, Ui_MainWindow): updGUI = pyqtSignal() def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.teleop = TeleopWidget(self) self.map = MapWidget(self) self.tlLayout.addWidget(self.teleop) self.teleop.setVisible(True) self.mapLayout.addWidget(self.map) self.map.setVisible(True) self.pushButton.clicked.connect(self.playClicked) self.pushButton.setCheckable(True) self.updGUI.connect(self.updateGUI) self.camera1 = CameraWidget(self) self.stopButton.clicked.connect(self.stopClicked) def updateGUI(self): self.camera1.updateImage() (cx, cy) = self.algorithm.getCarDirection() (ox, oy) = self.algorithm.getObstaclesDirection() (ax, ay) = self.algorithm.getAverageDirection() (tx, ty) = self.algorithm.getCurrentTarget() self.map.setCarArrow(cx, cy) self.map.setObstaclesArrow(ox, oy) self.map.setAverageArrow(ax, ay) if (self.pose3d): self.map.setTarget(tx, ty, self.pose3d.getX() / 1000, self.pose3d.getY() / 1000, self.pose3d.getYaw()) laserdata = self.laser.getLaserData() if (laserdata): self.map.setLaserValues(laserdata) self.map.update() def getCameraL(self): return self.cameraL def setCameraL(self, camera): self.cameraL = camera def getCameraR(self): return self.cameraR def setCameraR(self, camera): self.cameraR = camera def getPose3D(self): return self.pose3d def setPose3D(self, pose3d): self.pose3d = pose3d def getLaser(self): return self.laser def setLaser(self, laser): self.laser = laser def getMotors(self): return self.motors def setMotors(self, motors): self.motors = motors def playClicked(self): if self.pushButton.isChecked(): self.pushButton.setText('RUNNING') self.pushButton.setStyleSheet("background-color: green") self.algorithm.play() else: self.pushButton.setText('STOPPED') self.pushButton.setStyleSheet("background-color: red") self.algorithm.stop() def setAlgorithm(self, algorithm): self.algorithm = algorithm def getAlgorithm(self): return self.algorithm def setXYValues(self, newX, newY): myW = -newX * self.motors.getMaxW() myV = -newY * self.motors.getMaxV() self.motors.setV(myV) self.motors.setW(myW) self.motors.sendVelocities() def stopClicked(self): self.motors.setV(0) self.motors.setW(0) self.motors.sendVelocities() self.teleop.returnToOrigin()
class MainWindow(QMainWindow, Ui_MainWindow): updGUI = pyqtSignal() def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.teleop = TeleopWidget(self) self.map = MapWidget(self) self.tlLayout.addWidget(self.teleop) self.teleop.setVisible(True) self.mapLayout.addWidget(self.map) self.map.setVisible(True) self.verticalLayout_2.addWidget(self.stopButton, 3) self.logo = LogoWidget(self, 60, 60) self.verticalLayout_2.addWidget(self.logo, 4) self.logo.setVisible(True) self.playButton.clicked.connect(self.playClicked) self.playButton.setCheckable(True) self.updGUI.connect(self.updateGUI) #self.camera1=CameraWidget(self) self.stopButton.clicked.connect(self.stopClicked) def updateGUI(self): #self.camera1.updateImage() (cx, cy) = self.algorithm.getCarDirection() (ox, oy) = self.algorithm.getObstaclesDirection() (ax, ay) = self.algorithm.getAverageDirection() (tx, ty, id) = self.algorithm.getCurrentTarget() self.map.setCarArrow(cx, cy) self.map.setObstaclesArrow(ox, oy) self.map.setAverageArrow(ax, ay) if (self.pose3d): self.map.setTarget(tx, ty, self.pose3d.getPose3d().x, self.pose3d.getPose3d().y, self.pose3d.getPose3d().yaw, id) laserdata = self.laser.getLaserData() if (laserdata): self.map.setLaserValues(laserdata) self.map.update() #def getCamera(self): #return self.camera #def setCamera(self,camera): #self.camera=camera def getPose3D(self): return self.pose3d def setPose3D(self, pose3d): self.pose3d = pose3d def getLaser(self): return self.laser def setLaser(self, laser): self.laser = laser def getMotors(self): return self.motors def setMotors(self, motors): self.motors = motors def playClicked(self): if self.playButton.isChecked(): icon = QtGui.QIcon() self.playButton.setStyleSheet("background-color: #ec7063") icon.addPixmap(QtGui.QPixmap(":/images/stop.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.playButton.setIcon(icon) self.algorithm.play() else: icon = QtGui.QIcon() self.playButton.setStyleSheet("background-color: #7dcea0") icon.addPixmap(QtGui.QPixmap(":/images/play.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.playButton.setIcon(icon) self.algorithm.stop() self.motors.sendV(0) self.motors.sendW(0) #self.motors.sendVelocities() self.teleop.returnToOrigin() def setAlgorithm(self, algorithm): self.algorithm = algorithm def getAlgorithm(self): return self.algorithm def setXYValues(self, newX, newY): myW = -newX * self.motors.getMaxW() myV = -newY * self.motors.getMaxV() self.motors.sendV(myV) self.motors.sendW(myW) #self.motors.sendVelocities(self.motors) def stopClicked(self): self.motors.sendV(0) self.motors.sendW(0) # self.motors.sendVelocities() self.teleop.returnToOrigin()
class MainWindow(QMainWindow, Ui_MainWindow): updGUI=pyqtSignal() def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.teleop=TeleopWidget(self) self.map=MapWidget(self) self.tlLayout.addWidget(self.teleop) self.teleop.setVisible(True) self.mapLayout.addWidget(self.map) self.map.setVisible(True) self.pushButton.clicked.connect(self.playClicked) self.pushButton.setCheckable(True) self.updGUI.connect(self.updateGUI) self.camera1=CameraWidget(self) self.stopButton.clicked.connect(self.stopClicked) def updateGUI(self): self.camera1.updateImage() (cx, cy) = self.algorithm.getCarDirection() (ox, oy) = self.algorithm.getObstaclesDirection() (ax, ay) = self.algorithm.getAverageDirection() (tx, ty) = self.algorithm.getCurrentTarget() self.map.setCarArrow(cx, cy) self.map.setObstaclesArrow(ox, oy) self.map.setAverageArrow(ax, ay) if (self.pose3d): self.map.setTarget(tx, ty, self.pose3d.getX()/1000, self.pose3d.getY()/1000, self.pose3d.getYaw()) laserdata = self.laser.getLaserData() if (laserdata): self.map.setLaserValues(laserdata) self.map.update() def getCameraL(self): return self.cameraL def setCameraL(self,camera): self.cameraL=camera def getCameraR(self): return self.cameraR def setCameraR(self,camera): self.cameraR=camera def getPose3D(self): return self.pose3d def setPose3D(self,pose3d): self.pose3d=pose3d def getLaser(self): return self.laser def setLaser(self,laser): self.laser=laser def getMotors(self): return self.motors def setMotors(self,motors): self.motors=motors def playClicked(self): if self.pushButton.isChecked(): self.pushButton.setText('RUNNING') self.pushButton.setStyleSheet("background-color: green") self.algorithm.play() else: self.pushButton.setText('STOPPED') self.pushButton.setStyleSheet("background-color: red") self.algorithm.stop() def setAlgorithm(self, algorithm ): self.algorithm=algorithm def getAlgorithm(self): return self.algorithm def setXYValues(self,newX,newY): myW=-newX*self.motors.getMaxW() myV=-newY*self.motors.getMaxV() self.motors.setV(myV) self.motors.setW(myW) self.motors.sendVelocities() def stopClicked(self): self.motors.setV(0) self.motors.setW(0) self.motors.sendVelocities() self.teleop.returnToOrigin()
class MainWindow(QMainWindow, Ui_MainWindow): updGUI=pyqtSignal() def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.teleop=TeleopWidget(self) self.map=MapWidget(self) self.tlLayout.addWidget(self.teleop) self.teleop.setVisible(True) self.mapLayout.addWidget(self.map) self.map.setVisible(True) self.verticalLayout_2.addWidget(self.stopButton,3) self.logo = LogoWidget(self, 60, 60) self.verticalLayout_2.addWidget(self.logo,4) self.logo.setVisible(True) self.playButton.clicked.connect(self.playClicked) self.playButton.setCheckable(True) self.updGUI.connect(self.updateGUI) self.camera1=CameraWidget(self) self.stopButton.clicked.connect(self.stopClicked) def updateGUI(self): self.camera1.updateImage() (cx, cy) = self.algorithm.getCarDirection() (ox, oy) = self.algorithm.getObstaclesDirection() (ax, ay) = self.algorithm.getAverageDirection() (tx, ty, id) = self.algorithm.getCurrentTarget() self.map.setCarArrow(cx, cy) self.map.setObstaclesArrow(ox, oy) self.map.setAverageArrow(ax, ay) if (self.pose3d): self.map.setTarget(tx, ty, self.pose3d.getPose3d().x/1000, self.pose3d.getPose3d().y/1000, self.pose3d.getPose3d().yaw, id) laserdata = self.laser.getLaserData() if (laserdata): self.map.setLaserValues(laserdata) self.map.update() def getCamera(self): return self.camera def setCamera(self,camera): self.camera=camera def getPose3D(self): return self.pose3d def setPose3D(self,pose3d): self.pose3d=pose3d def getLaser(self): return self.laser def setLaser(self,laser): self.laser=laser def getMotors(self): return self.motors def setMotors(self,motors): self.motors=motors def playClicked(self): if self.playButton.isChecked(): icon = QtGui.QIcon() self.playButton.setStyleSheet("background-color: #ec7063") icon.addPixmap(QtGui.QPixmap(":/images/stop.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.playButton.setIcon(icon) self.algorithm.play() else: icon = QtGui.QIcon() self.playButton.setStyleSheet("background-color: #7dcea0") icon.addPixmap(QtGui.QPixmap(":/images/play.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.playButton.setIcon(icon) self.algorithm.stop() self.motors.sendV(0) self.motors.sendW(0) #self.motors.sendVelocities() self.teleop.returnToOrigin() def setAlgorithm(self, algorithm ): self.algorithm=algorithm def getAlgorithm(self): return self.algorithm def setXYValues(self,newX,newY): myW=-newX*self.motors.getMaxW() myV=-newY*self.motors.getMaxV() self.motors.sendV(myV) self.motors.sendW(myW) #self.motors.sendVelocities(self.motors) def stopClicked(self): self.motors.sendV(0) self.motors.sendW(0) # self.motors.sendVelocities() self.teleop.returnToOrigin()
class MainWindow(QtGui.QMainWindow, Ui_MainWindow): updGUI=QtCore.pyqtSignal() def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.teleop=TeleopWidget(self) self.map=MapWidget(self) self.tlLayout.addWidget(self.teleop) self.teleop.setVisible(True) self.mapLayout.addWidget(self.map) self.map.setVisible(True) self.pushButton.clicked.connect(self.playClicked) self.pushButton.setCheckable(True) self.updGUI.connect(self.updateGUI) self.camera1=CameraWidget(self) self.stopButton.clicked.connect(self.stopClicked) def updateGUI(self): self.camera1.updateImage() (cx, cy) = self.algorithm.getCarDirection() (ox, oy) = self.algorithm.getObstaclesDirection() (ax, ay) = self.algorithm.getAverageDirection() (tx, ty) = self.algorithm.getCurrentTarget() self.map.setCarArrow(cx, cy) self.map.setObstaclesArrow(ox, oy) self.map.setAverageArrow(ax, ay) self.map.setTarget(tx, ty, self.sensor.getRobotX(), self.sensor.getRobotY(), self.sensor.getRobotTheta()) self.map.setLaserValues(self.sensor.getLaserData()) self.map.update() def getSensor(self): return self.sensor def setSensor(self,sensor): self.sensor=sensor def playClicked(self): self.sensor.setPlayButton(self.pushButton.isChecked()) if self.pushButton.isChecked(): self.pushButton.setText('RUNNING') self.pushButton.setStyleSheet("background-color: green") else: self.pushButton.setText('STOPPED') self.pushButton.setStyleSheet("background-color: red") def setAlgorithm(self, algorithm ): self.algorithm=algorithm def getAlgorithm(self): return self.algorithm def setXYValues(self,newX,newY): self.sensor.setV(-newY) self.sensor.setW(newX) def stopClicked(self): self.sensor.setV(0) self.sensor.setW(0) self.teleop.returnToOrigin()