当前位置: 首页>>代码示例>>Python>>正文


Python Relay.Relay类代码示例

本文整理汇总了Python中BAL.Devices.Relay.Relay的典型用法代码示例。如果您正苦于以下问题:Python Relay类的具体用法?Python Relay怎么用?Python Relay使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Relay类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addRelay

 def addRelay(self):
     if self.relayPorts.count() == 0:
         QMessageBox.critical(self, "Relay Error", "Out of relay ports.")
         return
     self.interruptHandler()
     self.newDevMode = True
     self.currentShowDev = Relay(self.DevFrame, self.data, self.relayPorts)
     self.currentShowDev.showDetails()
     self.pushButton.clicked.connect(self.addDevToList)
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:9,代码来源:MainWindow.py

示例2: MainWindow

class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.data = []
        self.motors = []
        self.currentShowDev = None
        self.root = Element("launch")

        self.actionAbout_RIC.triggered.connect(self.about)
        self.actionServo.triggered.connect(self.addServo)
        self.actionBattery_Monitor.triggered.connect(self.addBattery)
        self.actionSwitch.triggered.connect(self.addSwitch)
        self.actionIMU.triggered.connect(self.addImu)
        self.actionPPM.triggered.connect(self.addPpm)
        self.actionGPS.triggered.connect(self.addGps)
        self.actionRelay.triggered.connect(self.addRelay)
        self.actionURF.triggered.connect(self.addURF)
        self.actionMotor_with_one_encoder.triggered.connect(self.addCloseMotorOne)
        self.actionMotor_with_two_encoder.triggered.connect(self.addCloseMotorTwo)
        self.actionOpen_Loop.triggered.connect(self.addOpenMotor)
        self.actionWith_two_motors.triggered.connect(self.addDiffClose)
        self.actionWith_four_motors.triggered.connect(self.addDiffCloseFour)
        self.actionOpen_Loop_Drive.triggered.connect(self.addDiffOpen)
        self.actionUSB_Camera.triggered.connect(self.addUsbCam)
        self.actionOPENNI.triggered.connect(self.addOpenni)
        self.actionHakoyo.triggered.connect(self.addOHokuyo)
        self.actionSave.triggered.connect(self.save)
        self.actionOpen.triggered.connect(self.load)
        self.actionNew.triggered.connect(self.new)
        self.actionReconfig_RiC_Board.triggered.connect(self.configRiCBoard)
        self.actionRobot_Model.triggered.connect(self.addRobotModel)
        self.actionAbout_RiC_Board.triggered.connect(self.aboutRiCBoard)
        self.actionSLAM.triggered.connect(self.addSLAM)
        self.actionRemote_robot_launch.triggered.connect(self.launchRemote)
        self.actionPPM_Reader.triggered.connect(self.addPPmReader)
        self.actionSet_parameters.triggered.connect(self.paramManager)
        self.actionKeyboard.triggered.connect(self.addKeyboard)
        self.actionJoystick.triggered.connect(self.addJoystick)
        self.actionDifferential_Drive_smoother.triggered.connect(self.addDiffSmooth)

        self.fileName.textChanged.connect(self.fileNameEven)
        self.nameSpace.textChanged.connect(self.namespaceEven)

        self.devList.itemPressed.connect(self.clickListEven)
        self.devList.doubleClicked.connect(self.devEdit)

        self.servoPorts = QComboBox()
        self.servoPorts.addItems([self.tr("1"), self.tr("2")])

        self.switchPorts = QComboBox()
        self.switchPorts.addItems([self.tr("1"), self.tr("2")])

        self.relayPorts = QComboBox()
        self.relayPorts.addItems([self.tr("1"), self.tr("2")])

        self.urfPorts = QComboBox()
        self.urfPorts.addItems([self.tr("1"), self.tr("2"), self.tr("3")])

        self.encoders = QComboBox()
        self.encoders.addItems([self.tr("1"), self.tr("2"), self.tr("3"), self.tr("4")])

        self._ns = ""
        self._fileName = ""

        self.haveBattery = False
        self.haveIMU = False
        self.havePPM = False
        self.haveGPS = False
        self.haveCloseLoop = False
        self.haveOpenLoop = False
        self.haveDiff = False
        self.haveReader = False

        self.diffEnable = False

        self.editMode = False
        self.listMode = False
        self.newDevMode = False
        self.override = True
        self.pushButton_2.setEnabled(False)
        self.pushButton_2.clicked.connect(self.launch)

        allDev = subprocess.check_output(shlex.split("ls /dev"))

        conDevs = re.findall("ttyUSB.*", allDev) + re.findall("ttyACM.*", allDev) + re.findall("RiCBoard", allDev)

        for dev in conDevs:
            self.ConPortList.addItem(self.tr(dev))

        self.ConPortList.setCurrentIndex(self.ConPortList.count() - 1)

    def launchRemote(self):
        dialog = RemoteLaunch(self)
        dialog.show()
        dialog.exec_()

    def paramManager(self):
        subprocess.Popen(shlex.split("roslaunch ric_board startParamMsg.launch"))

#.........这里部分代码省略.........
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:101,代码来源:MainWindow.py

示例3: load

    def load(self):
        pkg = rospkg.RosPack().get_path("ric_board")
        fileName = QFileDialog.getOpenFileName(self, self.tr("Load File"), "%s/DATA" % pkg, self.tr("RiC File (*.RIC)"))
        if fileName != "":
            self.new()
            self.override = False
            load = open(fileName)
            data = pickle.load(load)

            self._fileName = data[0]
            self._ns = data[1]

            yaml = open("%s/config/%s.yaml" % (pkg, self._fileName))

            conDev = yaml.readline().split(": ")[1][:-1]

            allDevs = [str(self.ConPortList.itemText(i)) for i in xrange(self.ConPortList.count())]

            for i in xrange(len(allDevs)):
                if conDev == allDevs[i]:
                    self.ConPortList.setCurrentIndex(i)
                    break

            self.nameSpace.setText(self._ns)
            self.fileName.setText(self._fileName)

            devices = data[2]

            # print devices

            for dev in devices:
                if dev["type"] == BATTERY:
                    self.currentShowDev = Battery(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == SERVO:
                    self.currentShowDev = Servo(self.DevFrame, self.data, self.servoPorts)
                    self.currentShowDev.fromDict(dev)
                    self.servoPorts.removeItem(self.currentShowDev.findItem())
                elif dev["type"] == SWITCH:
                    self.currentShowDev = Switch(self.DevFrame, self.data, self.switchPorts)
                    self.currentShowDev.fromDict(dev)
                    self.switchPorts.removeItem(self.currentShowDev.findItem())
                elif dev["type"] == IMU:
                    self.currentShowDev = Imu(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == PPM:
                    self.currentShowDev = Ppm(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == GPS:
                    self.currentShowDev = Gps(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == RELAY:
                    self.currentShowDev = Relay(self.DevFrame, self.data, self.relayPorts)
                    self.currentShowDev.fromDict(dev)
                    self.relayPorts.removeItem(self.currentShowDev.findItem())
                elif dev["type"] == URF:
                    self.currentShowDev = Urf(self.DevFrame, self.data, self.urfPorts)
                    self.currentShowDev.fromDict(dev)
                    self.urfPorts.removeItem(self.currentShowDev.findItem())
                elif dev["type"] == CLOSE_LOP_ONE:
                    self.currentShowDev = CloseLoop(self.DevFrame, self.data, self.encoders)
                    self.currentShowDev.fromDict(dev)
                    self.encoders.removeItem(self.currentShowDev.findItem())
                elif dev["type"] == CLOSE_LOP_TWO:
                    self.currentShowDev = CloseLoopTwo(self.DevFrame, self.data, self.encoders)
                    self.currentShowDev.fromDict(dev)
                    self.encoders.removeItem(self.currentShowDev.findItem())
                    self.encoders.removeItem(self.currentShowDev.findItem2())
                elif dev["type"] == OPEN_LOP:
                    self.currentShowDev = OpenLoop(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == DIFF_CLOSE:
                    self.currentShowDev = DiffClose(self.DevFrame, self.data, self.motors)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == DIFF_CLOSE_FOUR:
                    self.currentShowDev = DiffCloseFour(self.DevFrame, self.data, self.motors)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == DIFF_OPEN:
                    self.currentShowDev = DiffOpen(self.DevFrame, self.data, self.motors)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == HOKUYO:
                    self.currentShowDev = Hokuyo(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == OPRNNI:
                    self.currentShowDev = Opennni(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == USBCAM:
                    self.currentShowDev = UsbCam(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == ROBOT_MODEL:
                    self.currentShowDev = RobotModel(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == SLAM:
                    self.currentShowDev = Slam(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == PPMReader:
                    self.currentShowDev = PPMReader(self.DevFrame, self.data)
                    self.currentShowDev.fromDict(dev)
                elif dev["type"] == Keyboard:
                    self.currentShowDev = KeyboardTeleop(self.DevFrame, self.data)
#.........这里部分代码省略.........
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:101,代码来源:MainWindow.py

示例4: addOpenMotor

 def addOpenMotor(self):
     if self.haveCloseLoop:
         QMessageBox.critical(self, "Error", "Open and close motors can not exist in the same configuration.")
         return
     self.interruptHandler()
     self.newDevMode = True
     self.currentShowDev = OpenLoop(self.DevFrame, self.data)
     self.currentShowDev.showDetails()
     self.pushButton.clicked.connect(self.addDevToList)
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:9,代码来源:MainWindow.py

示例5: addGps

 def addGps(self):
     if self.haveGPS:
         QMessageBox.critical(self, "GPS Error", "Can't add another GPS to ric board.")
         return
     self.interruptHandler()
     self.newDevMode = True
     self.currentShowDev = Gps(self.DevFrame, self.data)
     self.currentShowDev.showDetails()
     self.pushButton.clicked.connect(self.addDevToList)
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:9,代码来源:MainWindow.py

示例6: addCloseMotorOne

 def addCloseMotorOne(self):
     if self.haveOpenLoop:
         QMessageBox.critical(self, "Error", "Open and close motors can not exist in the same configuration.")
         return
     if self.encoders.count() == 0:
         QMessageBox.critical(self, "Close Motor Error", "Out of encoder ports.")
         return
     self.interruptHandler()
     self.newDevMode = True
     self.currentShowDev = CloseLoop(self.DevFrame, self.data, self.encoders)
     self.currentShowDev.showDetails()
     self.pushButton.clicked.connect(self.addDevToList)
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:12,代码来源:MainWindow.py

示例7: addDiffClose

 def addDiffClose(self):
     if not self.haveCloseLoop or len(self.motors) < 2:
         QMessageBox.critical(self, "Driver error", "Need to have at less two close loop motors.")
         return
     if self.haveDiff:
         QMessageBox.critical(self, "Driver error", "Can not have more.")
         return
     self.interruptHandler()
     self.newDevMode = True
     self.currentShowDev = DiffClose(self.DevFrame, self.data, self.motors)
     self.currentShowDev.showDetails()
     self.pushButton.clicked.connect(self.addDevToList)
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:12,代码来源:MainWindow.py

示例8: addUsbCam

 def addUsbCam(self):
     self.interruptHandler()
     self.newDevMode = True
     self.currentShowDev = UsbCam(self.DevFrame, self.data)
     self.currentShowDev.showDetails()
     self.pushButton.clicked.connect(self.addDevToList)
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:6,代码来源:MainWindow.py

示例9: addDiffSmooth

 def addDiffSmooth(self):
     self.interruptHandler()
     self.newDevMode = True
     self.currentShowDev = VelocitySmoother(self.DevFrame, self.data)
     self.currentShowDev.showDetails()
     self.pushButton.clicked.connect(self.addDevToList)
开发者ID:nirlevi5,项目名称:bgumodo_ws,代码行数:6,代码来源:MainWindow.py


注:本文中的BAL.Devices.Relay.Relay类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。