예제 #1
0
    def setupUi(self, MainWindow):
        self.lock = Lock()
        self.talker = Talker('taskview')
        rospy.Subscriber('BbSync', bbsynch, self.taskview)

        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.listView = QtWidgets.QListWidget(self.centralwidget)
        self.listView.setGeometry(QtCore.QRect(10, 40, 771, 521))
        self.listView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.listView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.listView.setObjectName("listView")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(10, 10, 67, 17))
        self.label.setObjectName("label")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
        self.tasklist = []
        self.markers = rviz_tools.RvizMarkers('/map', 'markers')
예제 #2
0
class UploadWorker(QtCore.QObject):
    ret = QtCore.pyqtSignal(object)
    finished = QtCore.pyqtSignal()
    program_progress = QtCore.pyqtSignal(int, int)
    verify_progress = QtCore.pyqtSignal(int, int)

    def __init__(self, fun=None, path=None):
        super(UploadWorker, self).__init__()
        self.upload = fun
        self.path = path

    def set_fun(self, fun):
        self.upload = fun

    def set_path(self, path):
        self.path = path

    def on_program_progress(self, progress, total):
        self.program_progress.emit(progress, total)

    def on_verify_progress(self, progress, total):
        self.verify_progress.emit(progress, total)

    def run(self):
        ret = None
        try:
            ret = self.upload(self.path)
        except Exception as e:
            logger.error("Error during firmware upload: %s", e)
        self.ret.emit(ret)
        self.finished.emit()
예제 #3
0
class ReadWriteParamsWorker(QtCore.QObject):
    ret = QtCore.pyqtSignal(object)
    finished = QtCore.pyqtSignal()
    progress = QtCore.pyqtSignal(int, int)

    def __init__(self, fun, param_names=None, param_values=None):
        super(ReadWriteParamsWorker, self).__init__()
        self.names = param_names
        self.values = param_values
        self.fun = fun

    def set_params(self, names, values=None):
        self.names = names
        self.values = values

    def run(self):
        ret_values = dict()
        if self.names is not None:
            self.progress.emit(0, len(self.names))
            for i, param in enumerate(self.names):
                if self.values is None:
                    ret_values[param] = self.fun(param)
                else:
                    ret_values[param] = self.fun(param, self.values[i])
                self.progress.emit(i + 1, len(self.names))
        self.ret.emit(ret_values)
        self.finished.emit()
예제 #4
0
class ServiceThread(QtCore.QObject, threading.Thread):
    '''
  A thread to to retrieve the list of nodes from the default configuration 
  service and publish it by sending a QT signal.
  '''
    update_signal = QtCore.Signal(str, str, list)
    err_signal = QtCore.Signal(str, str, str)

    def __init__(self, service_uri, service, delay_exec=0.0, parent=None):
        QtCore.QObject.__init__(self)
        threading.Thread.__init__(self)
        self._service_uri = service_uri
        self._service = service
        self._delay_exec = delay_exec
        self.setDaemon(True)

    def run(self):
        '''
    '''
        if self._service and self._service_uri:
            try:
                if self._delay_exec > 0:
                    time.sleep(self._delay_exec)
                _, resp = nm.starter().callService(self._service_uri,
                                                   self._service, ListNodes)
                self.update_signal.emit(self._service_uri, self._service,
                                        resp.nodes)
            except:
                import traceback
                lines = traceback.format_exc().splitlines()
                rospy.logwarn(
                    "Error while retrieve the node list from %s[%s]: %s",
                    str(self._service), str(self._service_uri), str(lines[-1]))
                self.err_signal.emit(self._service_uri, self._service,
                                     lines[-1])
예제 #5
0
class Worker(QObject):
    progress = QtCore.Signal(int)
    finished = QtCore.Signal()
    error = QtCore.Signal(str)

    def __init__(self, run):
        super(Worker, self).__init__()
        self.run_function = run

    def process(self):
        self.progress.emit(0)
        try:
            if isinstance(self.run_function, types.GeneratorType):
                p = 0
                self.progress.emit(p)
                while p < 100:
                    p = self.run_function()
                    self.progress.emit(p)
            else:
                self.run_function()
            self.progress.emit(100)
            self.finished.emit()
        except Exception as e:
            self.error.emit(str(e))
            raise
예제 #6
0
 def handleMessage(self):
     socket = self._server.nextPendingConnection()
     if socket.waitForReadyRead(self._timeout):
         self.messageAvailable.emit(socket.readAll().data().decode('utf-8'))
         socket.disconnectFromServer()
     else:
         QtCore.qDebug(socket.errorString())
예제 #7
0
    def minimumSize(self):
        size = QtCore.QSize()
        for item in self._items:
            size = size.expandedTo(item.minimumSize())

        size += QtCore.QSize(2 * self.margin(), 2 * self.margin())
        return size
예제 #8
0
    def __init__(self, parent=None):
        QtGui.QSyntaxHighlighter.__init__(self, parent)
        self.rules = []
        self.commentStart = QtCore.QRegExp("#")
        self.commentEnd = QtCore.QRegExp("\n")
        self.commentFormat = QtGui.QTextCharFormat()
        self.commentFormat.setFontItalic(True)
        self.commentFormat.setForeground(QtCore.Qt.darkGray)
        f = QtGui.QTextCharFormat()
        r = QtCore.QRegExp()
        r.setMinimal(True)
        f.setFontWeight(QtGui.QFont.Normal)
        f.setForeground(QtCore.Qt.darkBlue)
        tagList = [
            "\\bignore_hosts\\b", "\\bsync_hosts\\b", "\\bignore_nodes\\b",
            "\\bsync_nodes\\b", "\\bignore_topics\\b", "\\bsync_topics\\b",
            "\\bignore_services\\b", "\\bsync_services\\b",
            "\\bsync_topics_on_demand\\b", "\\bsync_remote_nodes\\b"
        ]
        for tag in tagList:
            r.setPattern(tag)
            self.rules.append((QtCore.QRegExp(r), QtGui.QTextCharFormat(f)))

        f.setForeground(QtCore.Qt.darkGreen)
        f.setFontWeight(QtGui.QFont.Bold)
        attrList = ["\\b\\*|\\*\\B|\\/\\*"]
        for attr in attrList:
            r.setPattern(attr)
            self.rules.append((QtCore.QRegExp(r), QtGui.QTextCharFormat(f)))
예제 #9
0
    def paintSection(self, painter, rect, logicalIndex):
        '''
    The method paint the robot or capability images in the backgroud of the cell.
    @see: L{QtGui.QHeaderView.paintSection()} 
    '''
        painter.save()
        QtGui.QHeaderView.paintSection(self, painter, rect, logicalIndex)
        painter.restore()

        if logicalIndex in range(len(
                self._data)) and self._data[logicalIndex]['images']:
            if len(self._data[logicalIndex]['images']) == 1:
                pix = self._data[logicalIndex]['images'][0]
                pix = pix.scaled(rect.width(),
                                 rect.height() - 20, QtCore.Qt.KeepAspectRatio,
                                 QtCore.Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, rect, 5, pix)
            elif len(self._data[logicalIndex]['images']) > 1:
                new_rect = QtCore.QRect(rect.left(), rect.top(), rect.width(),
                                        (rect.height() - 20) / 2.)
                pix = self._data[logicalIndex]['images'][0]
                pix = pix.scaled(new_rect.width(), new_rect.height(),
                                 QtCore.Qt.KeepAspectRatio,
                                 QtCore.Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, new_rect, 5, pix)
                new_rect = QtCore.QRect(rect.left(),
                                        rect.top() + new_rect.height(),
                                        rect.width(), new_rect.height())
                pix = self._data[logicalIndex]['images'][1]
                pix = pix.scaled(new_rect.width(), new_rect.height(),
                                 QtCore.Qt.KeepAspectRatio,
                                 QtCore.Qt.SmoothTransformation)
                self.style().drawItemPixmap(painter, new_rect, 5, pix)
예제 #10
0
class MasterListService(QtCore.QObject):
    '''
  A class to retrieve the ROS master list from a ROS service. The service
  will be determine using L{master_discovery_fkie.interface_finder.get_listmaster_service()}

  '''
    masterlist_signal = QtCore.Signal(str, str, list)
    '''@ivar: a signal with a list of the masters retrieved from the master_discovery service 'list_masters'.
  ParameterB{:} C{masteruri}, C{service name}, C{[L{master_discovery_fkie.ROSMaster}, ...]}'''
    masterlist_err_signal = QtCore.Signal(str, str)
    '''@ivar: this signal is emitted if an error while calling #list_masters' 
  service of master_discovery is failed.
  ParameterB{:} C{masteruri}, C{error}'''
    def __init__(self):
        QtCore.QObject.__init__(self)
        self.__serviceThreads = {}
        self._lock = threading.RLock()

    def stop(self):
        print "  Shutdown discovery listener..."
        for _, thread in self.__serviceThreads.iteritems():
            thread.join(3)
        print "  Discovery listener is off!"

    def retrieveMasterList(self, masteruri, wait=False):
        '''
    This method use the service 'list_masters' of the master_discovery to get 
    the list of discovered ROS master. The retrieved list will be emitted as 
    masterlist_signal.
    @param masteruri: the ROS master URI
    @type masteruri: C{str}
    @param wait: wait for the service
    @type wait: C{boolean}
    '''
        with self._lock:
            if not (self.__serviceThreads.has_key(masteruri)):
                upthread = MasterListThread(masteruri, wait)
                upthread.master_list_signal.connect(self._on_master_list)
                upthread.err_signal.connect(self._on_err)
                self.__serviceThreads[masteruri] = upthread
                upthread.start()

    def _on_master_list(self, masteruri, service_name, items):
        with self._lock:
            try:
                thread = self.__serviceThreads.pop(masteruri)
                del thread
            except KeyError:
                pass
        self.masterlist_signal.emit(masteruri, service_name, items)

    def _on_err(self, masteruri, msg):
        with self._lock:
            try:
                thread = self.__serviceThreads.pop(masteruri)
                del thread
            except KeyError:
                pass
        self.masterlist_err_signal.emit(masteruri, msg)
예제 #11
0
 def handleMessage(self):
     socket = self._server.nextPendingConnection()
     if socket.waitForReadyRead(self._timeout):
         self.messageAvailable.emit(
             socket.readAll().data().decode('utf-8'))
         socket.disconnectFromServer()
     else:
         QtCore.qDebug(socket.errorString())
예제 #12
0
class UpdateThread(QtCore.QObject, threading.Thread):
    '''
  A thread to retrieve the state about ROS master from remote discovery node and 
  publish it be sending a QT signal.
  '''
    update_signal = QtCore.Signal(MasterInfo)
    '''
  @ivar: update_signal is a signal, which is emitted, if a new 
  L{aster_discovery_fkie.MasterInfo} is retrieved.
  '''

    error_signal = QtCore.Signal(str, str)
    '''
  @ivar: error_signal is a signal (masteruri, error message), which is emitted, 
  if an error while retrieving a master info was occurred.
  '''
    def __init__(self, monitoruri, masteruri, delayed_exec=0., parent=None):
        '''
    @param masteruri: the URI of the remote ROS master
    @type masteruri: C{str}
    @param monitoruri: the URI of the monitor RPC interface of the master_discovery node
    @type monitoruri: C{str}
    @param delayed_exec: Delay the execution of the request for given seconds.
    @type delayed_exec: C{float}
    '''
        QtCore.QObject.__init__(self)
        threading.Thread.__init__(self)
        self._monitoruri = monitoruri
        self._masteruri = masteruri
        self._delayed_exec = delayed_exec
        self.setDaemon(True)

    def run(self):
        '''
    '''
        try:
            delay = self._delayed_exec + 0.5 + random.random()
            #'print "wait request update", self._monitoruri, delay
            time.sleep(delay)
            #'print "request update", self._monitoruri
            socket.setdefaulttimeout(25)
            remote_monitor = xmlrpclib.ServerProxy(self._monitoruri)
            remote_info = remote_monitor.masterInfo()
            master_info = MasterInfo.from_list(remote_info)
            master_info.check_ts = time.time()
            #'print "request success", self._monitoruri
            self.update_signal.emit(master_info)
        except:
            import traceback
            #      print traceback.print_exc()
            formatted_lines = traceback.format_exc(1).splitlines()
            rospy.logwarn("Connection to %s failed:\n\t%s",
                          str(self._monitoruri), formatted_lines[-1])
            #'print "request failed", self._monitoruri
            self.error_signal.emit(self._masteruri, formatted_lines[-1])
        finally:
            if not socket is None:
                socket.setdefaulttimeout(None)
예제 #13
0
    def _subscribe(self):

        self._depGraph = rospy.Subscriber(
            "dependency_graph", String,
            lambda data: self.emit(QtCore.SIGNAL("onDepGraph"), data.data))
        self._pnGraph = rospy.Subscriber(
            "petri_net_graph", String,
            lambda data: self.emit(QtCore.SIGNAL("onPNGraph"), data.data))
        pass
예제 #14
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle('Select Binary')
        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.content = QtGui.QWidget()
        self.contentLayout = QtGui.QFormLayout(self.content)
        self.contentLayout.setVerticalSpacing(0)
        self.verticalLayout.addWidget(self.content)

        self.packages = None

        package_label = QtGui.QLabel("Package:", self.content)
        self.package_field = QtGui.QComboBox(self.content)
        self.package_field.setInsertPolicy(
            QtGui.QComboBox.InsertAlphabetically)
        self.package_field.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Fixed))
        self.package_field.setEditable(True)
        self.contentLayout.addRow(package_label, self.package_field)
        binary_label = QtGui.QLabel("Binary:", self.content)
        self.binary_field = QtGui.QComboBox(self.content)
        #    self.binary_field.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
        self.binary_field.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Fixed))
        self.binary_field.setEditable(True)
        self.contentLayout.addRow(binary_label, self.binary_field)

        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok
                                          | QtGui.QDialogButtonBox.Cancel)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)

        self.package_field.setFocus(QtCore.Qt.TabFocusReason)
        self.package = ''
        self.binary = ''

        if self.packages is None:
            self.package_field.addItems(['packages searching...'])
            self.package_field.setCurrentIndex(0)
            self._fill_packages_thread = PackagesThread()
            self._fill_packages_thread.packages.connect(self._fill_packages)
            self._fill_packages_thread.start()

        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"),
                               self.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"),
                               self.reject)
        QtCore.QMetaObject.connectSlotsByName(self)
        self.package_field.activated[str].connect(self.on_package_selected)
        self.package_field.textChanged.connect(self.on_package_selected)
예제 #15
0
 def readSettings(self):
   if nm.settings().store_geometry:
     settings = nm.settings().qsettings(nm.settings().CFG_GUI_FILE)
     settings.beginGroup("editor")
     maximized = settings.value("maximized", 'false') == 'true'
     if maximized:
       self.showMaximized()
     else:
       self.resize(settings.value("size", QtCore.QSize(800,640)))
       self.move(settings.value("pos", QtCore.QPoint(0, 0)))
     settings.endGroup()
예제 #16
0
    def __init__(self, guimgr):
        super(AwRosbagSimulatorWidget, self).__init__()
        self.rosbag_mode_proc = QtCore.QProcess(self)
        self.rosbag_info_proc = QtCore.QProcess(self)
        self.rosbag_play_proc = QtCore.QProcess(self)

        self.rosbag_file = widgets.AwFileSelect(self)
        self.rosbag_info = QtWidgets.QPushButton("Info")
        self.rosbag_text = QtWidgets.QLabel("No information")
        self.rosbag_enable = QtWidgets.QCheckBox()
        self.rosbag_label = QtWidgets.QLabel("Simulation Mode")
        self.rosbag_play = QtWidgets.QPushButton("Play")
        self.rosbag_stop = QtWidgets.QPushButton("Stop")
        self.rosbag_pause = QtWidgets.QPushButton("Pause")
        self.rosbag_state = QtWidgets.QLabel()
        #self.rosbag_stime  = QtWidgets.QLineEdit()
        #start time
        #repeat
        #rate

        self.rosbag_enable.stateChanged.connect(self.simulation_mode_changed)
        self.rosbag_info.clicked.connect(self.rosbag_info_requested)
        self.rosbag_info_proc.finished.connect(self.rosbag_info_completed)

        self.rosbag_play.clicked.connect(self.rosbag_started)
        self.rosbag_stop.clicked.connect(self.rosbag_stopped)
        self.rosbag_play_proc.finished.connect(self.rosbag_finished)
        self.rosbag_play_proc.readyReadStandardOutput.connect(
            self.rosbag_output)

        self.rosbag_pause.setCheckable(True)
        self.rosbag_pause.toggled.connect(self.rosbag_paused)

        self.setStyleSheet(
            "QCheckBox::indicator { width: 28px; height: 28px; }")
        self.rosbag_label.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                        QtWidgets.QSizePolicy.Preferred)
        self.rosbag_text.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                       QtWidgets.QSizePolicy.Expanding)

        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.rosbag_enable, 0, 0)
        layout.addWidget(self.rosbag_label, 0, 1)
        layout.addWidget(self.rosbag_play, 0, 2)
        layout.addWidget(self.rosbag_stop, 0, 3)
        layout.addWidget(self.rosbag_pause, 0, 4)
        layout.addWidget(self.rosbag_state, 1, 0, 1, 5)
        layout.addWidget(self.rosbag_file.path, 2, 0, 1, 3)
        layout.addWidget(self.rosbag_file.button, 2, 3)
        layout.addWidget(self.rosbag_info, 2, 4)
        layout.addWidget(self.rosbag_text, 3, 0, 1, 5)
        self.setLayout(layout)
        self.simulation_mode_disabled()
예제 #17
0
class Worker(QtCore.QObject):
    ret = QtCore.pyqtSignal(object)
    finished = QtCore.pyqtSignal()

    def __init__(self, fun, *args, **kwargs):
        super(Worker, self).__init__()
        self.fun = fun
        self.args = args
        self.kwargs = kwargs

    def run(self):
        self.ret.emit(self.fun(*self.args, **self.kwargs))
        self.finished.emit()
예제 #18
0
  def updateCapabilities(self, masteruri, cfg_name, description):
    '''
    Updates the capabilities view.
    @param masteruri: the ROS master URI of updated ROS master.
    @type masteruri: C{str}
    @param cfg_name: The name of the node provided the capabilities description.
    @type cfg_name: C{str}
    @param description: The capabilities description object.
    @type description: L{default_cfg_fkie.Description}
    '''
    # if it is a new masteruri add a new column
    robot_index = self._robotHeader.index(masteruri)
    robot_name = description.robot_name if description.robot_name else nm.nameres().mastername(masteruri)
    if robot_index == -1:
      # append a new robot
      robot_index = self._robotHeader.insertSortedItem(masteruri, robot_name)
      self.insertColumn(robot_index)
#      robot_index = self.columnCount()-1
#      self._robotHeader.insertItem(robot_index)
      self._robotHeader.setDescription(robot_index, cfg_name, masteruri, robot_name, description.robot_type, description.robot_descr.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), description.robot_images)
      item = QtGui.QTableWidgetItem()
      item.setSizeHint(QtCore.QSize(96,96))
      self.setHorizontalHeaderItem(robot_index, item)
      self.horizontalHeaderItem(robot_index).setText(robot_name)
    else:
      #update
      self._robotHeader.setDescription(robot_index, cfg_name, masteruri, robot_name, description.robot_type, description.robot_descr.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), description.robot_images)
    
    #set the capabilities
    for c in description.capabilities:
      cap_index = self._capabilityHeader.index(c.name.decode(sys.getfilesystemencoding()))
      if cap_index == -1:
        # append a new capability
        cap_index = self._capabilityHeader.insertSortedItem(c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()))
        self.insertRow(cap_index)
        self.setRowHeight(cap_index, 96)
        self._capabilityHeader.setDescription(cap_index, cfg_name, c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()), c.type, c.description.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), c.images)
        item = QtGui.QTableWidgetItem()
        item.setSizeHint(QtCore.QSize(96,96))
        self.setVerticalHeaderItem(cap_index, item)
        self.verticalHeaderItem(cap_index).setText(c.name.decode(sys.getfilesystemencoding()))
        # add the capability control widget
        controlWidget = CapabilityControlWidget(masteruri, cfg_name, c.namespace, c.nodes)
        controlWidget.start_nodes_signal.connect(self._start_nodes)
        controlWidget.stop_nodes_signal.connect(self._stop_nodes)
        self.setCellWidget(cap_index, robot_index, controlWidget)
        self._capabilityHeader.controlWidget.insert(cap_index, controlWidget)
      else:
        self._capabilityHeader.updateDescription(cap_index, cfg_name, c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()), c.type, c.description.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), c.images)
        self._capabilityHeader.controlWidget[cap_index].updateNodes(cfg_name, c.namespace, c.nodes)
예제 #19
0
  def __init__(self, filename, parent=None):
    self.parent = parent
    QtGui.QTextEdit.__init__(self, parent)
    self.setObjectName(' - '.join(['Editor', filename]))
    font = QtGui.QFont()
    font.setFamily("Fixed".decode("utf-8"))
    font.setPointSize(12)
    self.setFont(font)
    self.setLineWrapMode(QtGui.QTextEdit.NoWrap)
    self.setTabStopWidth(25)
    self.setAcceptRichText(False)
    self.setCursorWidth(2)
    self.setFontFamily("courier new")
    self.setProperty("backgroundVisible", True)
    self.regexp_list = [QtCore.QRegExp("\\binclude\\b"), QtCore.QRegExp("\\btextfile\\b"),
                        QtCore.QRegExp("\\bfile\\b"), QtCore.QRegExp("\\bvalue=.*pkg:\/\/\\b"),
                        QtCore.QRegExp("\\bvalue=.*package:\/\/\\b"),
                        QtCore.QRegExp("\\bvalue=.*\$\(find\\b")]
    self.filename = filename
    self.file_info = None
    if self.filename:
      f = QtCore.QFile(filename);
      if f.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text):
        self.file_info = QtCore.QFileInfo(filename)
        self.setText(unicode(f.readAll(), "utf-8"))

    self.path = '.'
    # enables drop events
    self.setAcceptDrops(True)
예제 #20
0
class Channels(QtCore.QObject):
    vehicle_create = QtCore.pyqtSignal(str, str, dict, list)
    vehicle_move = QtCore.pyqtSignal(str, dict)
    vehicle_hide = QtCore.pyqtSignal(str)
    vehicle_show = QtCore.pyqtSignal(str)

    rqt_vviz_resize = QtCore.pyqtSignal(list)
    rqt_vviz_clear = QtCore.pyqtSignal()

    road_marking_set_size = QtCore.pyqtSignal(list, int)
    road_marking_edit_first = QtCore.pyqtSignal(str, int)

    draw_circle = QtCore.pyqtSignal(str, dict, int, str)

    remove_circle = QtCore.pyqtSignal(str)
예제 #21
0
class SupervisedPopen(QtCore.QObject, subprocess.Popen):
  '''
  The class overrides the subprocess.Popen and waits in a thread for its finish.
  If an error is printed out, it will be shown in a message dialog.
  '''
  error = QtCore.Signal(str, str, str)
  '''@ivar: the signal is emitted if error output was detected (id, decription, message)'''

  finished = QtCore.Signal(str)
  '''@ivar: the signal is emitted on exit (id)'''

  def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=subprocess.PIPE, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, id='', description=''):
    '''
    For arguments see https://docs.python.org/2/library/subprocess.html
    Additional arguments:
    :param id: the identification string of this object and title of the error message dialog 
    :type id: str
    :param description: the description string used as addiotional information 
                        in dialog if an error was occured
    :type description: str
    '''
    try:
      subprocess.Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
      QtCore.QObject.__init__(self)
      self._args = args
      self._id = id
      self._description = description
      self.error.connect(self.on_error)
      # wait for process to avoid 'defunct' processes
      thread = threading.Thread(target=self.supervise)
      thread.setDaemon(True)
      thread.start()
    except Exception as e:
      raise

#   def __del__(self):
#     print "Deleted:", self._description

  def supervise(self):
    # wait for process to avoid 'defunct' processes
    self.wait()
    result_err = self.stderr.read()
    if result_err:
      self.error.emit(self._id, self._description, result_err)
    self.finished.emit(self._id)

  def on_error(self, id, descr, msg):
    WarningMessageBox(QtGui.QMessageBox.Warning, id, '%s\n\n%s'%(descr, msg), ' '.join(self._args)).exec_()
예제 #22
0
    def paintEvent(self,event):
        if not self._initialized:
            self.placeStickAtCenter()
            self._initialized = True

        borderWidth = 1
        joyRange = 80
        center = QtCore.QPoint(self.height()/2,self.width()/2)
        
        qp = QPainter()
        qp.begin(self)
        qp.setRenderHint(QPainter.Antialiasing, True)
        qp.setPen(QPen(QtCore.Qt.lightGray, borderWidth, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap,QtCore.Qt.RoundJoin))

        if self._mode == "circle":

            qp.drawEllipse(center,joyRange,joyRange)

        if self._mode == "square":
            x = center.x() - joyRange
            y = center.y() - joyRange
            width = joyRange * 2
            height = joyRange * 2
            qp.drawRect(x,y,width,height)
       
        qp.end()

        super(JoystickView,self).paintEvent(event)
예제 #23
0
    def limitStickMove(self,pos,mode = "square"):
        # Give joystick position from (0,0)
        x = 0
        y = 0

        if mode == "circle":

            norm = math.sqrt(pos.x() ** 2 + pos.y() ** 2)
   
            if  norm > self._range:
                ratio = self._range / norm
            else:
                ratio = 1.0
            
            x = pos.x() * ratio
            y = pos.y() * ratio


        if mode == "square":
        
            if abs(pos.x()) > self._range:
                sign = pos.x() / abs(pos.x())
                x = sign * self._range
            else:
                x = pos.x()

            if abs(pos.y()) > self._range:
                sign = pos.y() / abs(pos.y())
                y = sign * self._range
            else:
                y = pos.y()

        return QtCore.QPoint(x,y)
예제 #24
0
    def setup_gui(self, two_columns=True):
        if qt_version_below_5:
            widget_layout = QtGui.QHBoxLayout()
        else:
            widget_layout = QtWidgets.QHBoxLayout()
        widget_layout.addLayout(self._column_1)
        if two_columns:
            widget_layout.addLayout(self._column_2)

        if qt_version_below_5:
            main_layout = QtGui.QHBoxLayout()
        else:
            main_layout = QtWidgets.QHBoxLayout()
        main_layout = QtWidgets.QVBoxLayout()
        main_layout.addLayout(widget_layout)

        self._column_1.setAlignment(QtCore.Qt.AlignTop)
        if two_columns:
            self._column_2.setAlignment(QtCore.Qt.AlignTop)
        widget_layout.setAlignment(QtCore.Qt.AlignTop)
        main_layout.setAlignment(QtCore.Qt.AlignTop)

        self.setLayout(main_layout)

        self._update_info_timer = QtCore.QTimer(self)
        self._update_info_timer.timeout.connect(self.update_gui)
        self._update_info_timer.start(100)
예제 #25
0
 def set_timer(self, parent=None):
     interval = self.publish_interval
     if not self._timer:
         self._timer = QtCore.QTimer(parent=parent)
         self._timer.timeout.connect(self.publish)
     self._timer.setInterval(interval)
     self._timer.start()
예제 #26
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        path = rospkg.RosPack().get_path('cyplam_data')
        loadUi(os.path.join(path, 'resources', 'data.ui'), self)

        rospy.Subscriber('/supervisor/status',
                         MsgStatus,
                         self.cbStatus,
                         queue_size=1)

        self.btnConnect.clicked.connect(self.btnConnectClicked)
        self.btnJob.clicked.connect(self.btnJobClicked)
        self.btnPredict.clicked.connect(self.btnPredictClicked)
        self.btnRecord.clicked.connect(self.btnRecordClicked)
        self.btnTransfer.clicked.connect(self.btnTransferClicked)

        dirdata = os.path.join(HOME, DIRDATA)
        if not os.path.exists(dirdata):
            os.mkdir(dirdata)

        self.job = ''
        self.name = ''
        self.status = False
        self.running = False
        self.process = QtCore.QProcess(self)

        if rospy.has_param('/material'):
            self.setMaterialParameters(rospy.get_param('/material'))

        self.btnJobClicked()
예제 #27
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        loadUi(os.path.join(path, 'resources', 'part.ui'), self)

        self.pub_marker_array = rospy.Publisher('visualization_marker_array',
                                                MarkerArray,
                                                queue_size=1)

        self.btnLoad.clicked.connect(self.btnLoadClicked)
        self.btnProcessMesh.clicked.connect(self.btnProcessMeshClicked)
        self.btnProcessLayer.clicked.connect(self.btnProcessLayerClicked)
        self.btnAcceptPath.clicked.connect(self.btnAcceptPathClicked)

        self.sbPositionX.valueChanged.connect(self.changePosition)
        self.sbPositionY.valueChanged.connect(self.changePosition)
        self.sbPositionZ.valueChanged.connect(self.changePosition)

        self.sbSizeX.valueChanged.connect(self.changeSize)
        self.sbSizeY.valueChanged.connect(self.changeSize)
        self.sbSizeZ.valueChanged.connect(self.changeSize)

        self.processing = False
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.updateProcess)

        self.robpath = RobPath()
예제 #28
0
    def __init__(self, guimgr):
        super(AwLgsvlSimulatorWidget, self).__init__()
        self.process = QtCore.QProcess(self)
        self.console = AwProcessViewer(self.process)
        self.button = QtWidgets.QPushButton("Launch Simulator")
        self.button.setCheckable(True)
        self.button.toggled.connect(self.launch_lgsvm)

        self.server_addr = QtWidgets.QLineEdit()
        self.server_port = QtWidgets.QLineEdit()
        self.client_addr = QtWidgets.QLineEdit()
        self.client_port = QtWidgets.QLineEdit()

        self.server_addr.setText("10.100.2.1")
        self.server_port.setText("5000")
        for host in QtNetwork.QNetworkInterface.allAddresses():
            if not host.isLoopback():
                if host.protocol() == QtNetwork.QAbstractSocket.IPv4Protocol:
                    self.client_addr.setText(host.toString())
        self.client_port.setText("9090")

        layout = QtWidgets.QGridLayout()
        layout.addWidget(QtWidgets.QLabel("Server Address"), 0, 0)
        layout.addWidget(QtWidgets.QLabel("Server Port"), 1, 0)
        layout.addWidget(QtWidgets.QLabel("Client Address"), 2, 0)
        layout.addWidget(QtWidgets.QLabel("Client Port"), 3, 0)
        layout.addWidget(self.server_addr, 0, 1)
        layout.addWidget(self.server_port, 1, 1)
        layout.addWidget(self.client_addr, 2, 1)
        layout.addWidget(self.client_port, 3, 1)
        layout.addWidget(self.button, 4, 0, 1, 2)
        layout.addWidget(self.console, 5, 0, 1, 2)
        self.setLayout(layout)
예제 #29
0
class RawDataSelector(QGroupBox):

    dataSourceChanged = QtCore.Signal(int)

    def __init__(self, parent=None):
        super(RawDataSelector, self).__init__()
        self.parent = parent
        self.setTitle('Select bag file')

        # Init the components
        self.bag1RadioBtn = QRadioButton('ground truth')
        self.bag2RadioBtn = QRadioButton('camera')

        # connect the signals to the slots
        self.bag1RadioBtn.clicked.connect(self.btn1Clicked)
        self.bag2RadioBtn.clicked.connect(self.btn2Clicked)

        # layout
        layout = QVBoxLayout()
        layout.addWidget(self.bag1RadioBtn)
        layout.addWidget(self.bag2RadioBtn)
        self.setLayout(layout)

    def btn1Clicked(self):
        '''
            "ground truth" is selected
        '''
        self.dataSourceChanged.emit(0)

    def btn2Clicked(self):
        '''
            "camera" is selected
        '''
        self.dataSourceChanged.emit(1)
예제 #30
0
 def on_topic_control_btn_clicked(self):
     try:
         if self.sub is None and self.ssh_output_file is None:
             if self.__msg_class:
                 self.sub = rospy.Subscriber(self.topic, self.__msg_class,
                                             self._msg_handle)
             else:
                 self._on_display_anchorClicked(QtCore.QUrl(
                     self._masteruri))
             self.topic_control_button.setText('stop')
             self.topic_control_button.setIcon(
                 QtGui.QIcon(':/icons/deleket_deviantart_stop.png'))
         else:
             if not self.sub is None:
                 self.sub.unregister()
                 self.sub = None
             elif not self.ssh_output_file is None:
                 self.ssh_output_file.close()
                 self.ssh_error_file.close()
                 self.ssh_output_file = None
             self.topic_control_button.setText('play')
             self.topic_control_button.setIcon(
                 QtGui.QIcon(':/icons/deleket_deviantart_play.png'))
             self.no_str_checkbox.setEnabled(True)
             self.no_arr_checkbox.setEnabled(True)
     except Exception as e:
         rospy.logwarn('Error while stop/play echo for topic %s: %s' %
                       (self.topic, e))
예제 #31
0
    def paintEvent(self,event):
        super(JoystickPointView,self).paintEvent(event)

        try:
            if self._initialized:
                pass
        except: 
            self._origPos = self.pos()
            self._initialized = True

        qp = QPainter()
        qp.begin(self)
        
        borderWidth = 2
        radius = self.height()/2
        center = QtCore.QPoint(self.height()/2,self.width()/2) 
        
        # Outer Circle
        qp.setRenderHint(QPainter.Antialiasing, True)
        qp.setPen(QPen(QtCore.Qt.darkGray, borderWidth, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap,QtCore.Qt.RoundJoin))
        qp.setBrush(QBrush(QtCore.Qt.white, QtCore.Qt.SolidPattern))
        qp.drawEllipse(center,radius-borderWidth,radius-borderWidth)

        # Inner Circle
        qp.setPen(QPen(QtCore.Qt.lightGray, borderWidth, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap,QtCore.Qt.RoundJoin))
        qp.setBrush(QBrush(QtCore.Qt.white, QtCore.Qt.SolidPattern))
        qp.drawEllipse(center,radius-borderWidth-1,radius-borderWidth-1)

        qp.end()