def sendCommand(self): try: # Todas las columnas de la fila seleccionadas name, instr, place = sorted( self._widget.TablaInstrucciones.selectedIndexes()) except: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Ejecución de Instrucción:") msg.setInformativeText( "No se ha seleccionado toda la fila. Seleccione el índice de la instrucción" ) msg.setWindowTitle("Error") ret = msg.exec_() return # Selección correcta name, place = str(name.data()), str(place.data()) i = 0 if name == inc.SERVER_USERNAME[0]: i = 0 #SDVUN_LAST_COMMAND[0] = self.sender.pose elif name == inc.SERVER_USERNAME[1]: i = 1 #SDVUN_LAST_COMMAND[1] = self.sender.pose elif name == inc.SERVER_USERNAME[2]: i = 2 #SDVUN_LAST_COMMAND[2] = self.sender.pose # HOME if inc.PLACES[place] == 0: self.sdvs[i].sender.sendSDVtoHome() # MALLA elif inc.PLACES[place] == 1: self.sdvs[i].sender.sendSDVtoCeldaExperimental() # INDUSTRIAL elif inc.PLACES[place] == 2: self.sdvs[i].sender.sendSDVtoCeldaIndustrial() # MANUFACTURA elif inc.PLACES[place] == 3: self.sdvs[i].sender.sendSDVtoCeldaManufactura() else: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Asignación de Comando:") msg.setInformativeText("No se ha reconocido el destino del SDV") msg.setWindowTitle("Error") ret = msg.exec_() return if name == inc.SERVER_USERNAME[0]: self.sdvs[i].sender.publishPoseStamped() elif name == inc.SERVER_USERNAME[1]: self.sdvs[i].sender.publishPoseStamped() elif name == inc.SERVER_USERNAME[2]: self.sdvs[i].sender.publishPoseStamped() else: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Asignación de Comando:") msg.setInformativeText("No se ha reconocido el robot SDV") msg.setWindowTitle("Error") ret = msg.exec_() return
def resetSDV(self): indexes = self._widget.EstadosDeConexion.selectedIndexes() # SI no se ha seleccionado ningun robot SDV arrojar error if not indexes: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Asignación de Comando:") msg.setInformativeText( "Seleccione al menos un robot de la lista de conexiones") msg.setWindowTitle("Error") ret = msg.exec_() else: for index in indexes: sdv = index.data() if sdv == inc.SERVER_USERNAME[0]: self.sdvs[0].sender.publishResetGoal() elif sdv == inc.SERVER_USERNAME[1]: self.sdvs[1].sender.publishResetGoal() elif sdv == inc.SERVER_USERNAME[2]: self.sdvs[2].sender.publishResetGoal() else: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Asignación de Comando:") msg.setInformativeText("No se ha reconocido el robot SDV") msg.setWindowTitle("Error") ret = msg.exec_() return
def show_pop_up(self): msg = QMessageBox() msg.setWindowTitle('Alternative flight plan received') msg.setText('Accept alternative flight plan?') msg.setIcon(QMessageBox.Question) msg.setStandardButtons(QMessageBox.Yes|QMessageBox.No) msg.setDefaultButton(QMessageBox.No) # msg.setInformativeText('Accept new plan?') msg.setDetailedText('{}'.format(self.alternative_flight_plan)) # msg.buttonClicked.connect(self.handle_message_box) # TODO: do handling here? pop_up_response = msg.exec_() ros_response = RPSFlightPlanAccept() ros_response.icao = self.alternative_flight_plan.icao ros_response.flight_plan_id = self.alternative_flight_plan.flight_plan_id if pop_up_response == QMessageBox.Yes: ros_response.accept = True # Try to call light_sim service to change flight plan try: light_sim_change_flight_plan = rospy.ServiceProxy('/gauss_light_sim/change_flight_plan', ChangeFlightPlan) light_sim_change_flight_plan(ChangeFlightPlanRequest(alternative=copy.deepcopy(self.alternative_flight_plan))) except rospy.ServiceException as e: print("[RQt] Service call failed: %s"%e) if pop_up_response == QMessageBox.No: ros_response.accept = False self.acceptance_pub.publish(ros_response) self.alternative_flight_plan = None
def __init__(self, bagFiles, parent=None): super(CompareDataTab, self).__init__() self.parent = parent # attributes self.bagFiles = bagFiles self.plotData = ([], [], 0.0, 0.0) self.plotInfo = { 'label': '', 'y_label': '', } # widgets self.operationSelector = OperationSelectorWidget(self) self.thresholdSetter = ThresholdSetter(self) self.waitMessageBox = QMessageBox(self) self.waitMessageBox.setIcon(QMessageBox.Information) self.waitMessageBox.setWindowTitle('Computation') # layout: layout = QHBoxLayout() layout.addWidget(self.operationSelector) layout.addWidget(self.thresholdSetter) self.setLayout(layout)
def loginView(self): # Login correcto if self.login.user: print 'Autenticado usuario: %s' % (self.login.user.display_name) self.sdvoice = SDVoice(self.mainwindow_file, self.login.user) # Show _widget.windowTitle on left-top of each plugin (when # it's set in _widget). This is useful when you open multiple # plugins at once. Also if you open multiple instances of your # plugin at once, these lines add number to make it easy to # tell from pane to pane. if self.context.serial_number() > 1: self.login._widget.setWindowTitle( self.login._widget.windowTitle() + (' (%d)' % self.context.serial_number())) self.sdvoice._widget.setWindowTitle( self.sdvoice._widget.windowTitle() + (' (%d)' % self.context.serial_number())) # Agregar widget al panel de rqt self.context.add_widget(self.sdvoice._widget) # TODO: CERRAR WIDGET LOGIN self.login._widget.close() # Error de datos de usuario else: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Verificación de Usuario:") msg.setInformativeText(u"Usuario o contraseña no válidos!") msg.setWindowTitle("Error") ret = msg.exec_()
def connectSSH(self): i = self._widget.ListaConexiones.currentIndex() # Let the user know we're connecting to the server self._widget.statusBar.showMessage("Connecting to server.") self.sdvs[i].ssh = ssh(inc.SERVER_IP[i], inc.SERVER_USERNAME[i], inc.SERVER_PASSWORD[i]) # Agregar a EstadosDeConexion lista de hosts conectados if self.sdvs[i].ssh.client != None: # Actualizar GUI item = QtGui.QStandardItem( self._widget.ListaConexiones.currentText()) self.EstadosDeConexion_model.appendRow(item) # TODO: Lanzar el proyecto de sdvoice en el robot SDV #node = roslaunch.core.Node('sdvoice', 'agv_nav.launch') #launch = roslaunch.scriptapi.ROSLaunch() #launch.start() #process = launch.launch(node) #print process.is_alive() #self.ssh_clients[i].sendCommand("roslaunch sdvoice agv_nav.launch") #self.ssh_clients[i].sendCommand("ls") else: # QDialog de Warning por error de conexión # TODO: Cambiar tamaño de la ventana del mensaje msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText("Error de Conexión:") msg.setInformativeText( "No se pudo conectar a %s!" % (self._widget.ListaConexiones.currentText())) msg.setWindowTitle("Error") ret = msg.exec_() self._widget.statusBar.showMessage("")
def _check_for_master(self): # check if master is available try: rospy.get_master().getSystemState() return except Exception: pass # spawn thread to detect when master becomes available self._wait_for_master_thread = threading.Thread( target=self._wait_for_master) self._wait_for_master_thread.start() self._wait_for_master_dialog = QMessageBox( QMessageBox.Question, self.tr('Waiting for ROS master'), self. tr("Could not find ROS master. Either start a 'roscore' or abort loading the plugin." ), QMessageBox.Abort) self._master_found_signal.connect(self._wait_for_master_dialog.done, Qt.QueuedConnection) button = self._wait_for_master_dialog.exec_() # check if master existence was not detected by background thread no_master = button != QMessageBox.Ok self._wait_for_master_dialog.deleteLater() self._wait_for_master_dialog = None if no_master: raise PluginLoadError( 'RosPyPluginProvider._init_node() could not find ROS master')
def startPressed(self): ''' is called when the start button is clicked calls the function to get the data to plot dependent on what tab is selected ''' currentTab = self.tabWidget.currentIndex() try: if currentTab == 0: # rawDataTab is active plotData, plotInfo = self.rawDataTab.getPlotData() elif currentTab == 1: # plotData, plotInfo = self.compareTab.getPlotData() elif currentTab == 2: plotData, plotInfo = self.diffTab.getPlotData() # emit signal with data self.newPlotData.emit(plotData, plotInfo) # close dialog self.close() except Exception as e: msg_box = QMessageBox(QMessageBox.Critical, 'Error', str(e)) msg_box.exec_()
def question_yn( qmsg='Message', title='Question' ): msgbox = QMessageBox() result = msgbox.question( msgbox, title, qmsg, msgbox.Yes | msgbox.No, msgbox.No ) if result == msgbox.Yes: return True else: return False
def on_qt_delete_btn_clicked(self): msgbox = QMessageBox( QMessageBox.Warning, 'Do you want to delete this?', 'Name: {0}\nPath: {1}'.format(self._path_model.cur_bagfilename, self._path_model.cur_bagpath)) msgbox.addButton('DELETE', QMessageBox.AcceptRole) msgbox.addButton('cancel', QMessageBox.RejectRole) if msgbox.exec_() == 0: self._path_model.delete_file()
def show(self): try: # append folder of 'qt_gui_cpp/lib' to module search path qt_gui_cpp_path = os.path.realpath(get_package_path('qt_gui_cpp')) except Exception: qt_gui_cpp = None else: sys.path.append(os.path.join(qt_gui_cpp_path, 'lib')) sys.path.append(os.path.join(qt_gui_cpp_path, 'src')) from qt_gui_cpp.cpp_binding_helper import qt_gui_cpp logo = os.path.join(self._qtgui_path, 'share', 'qt_gui', 'resource', 'ros_org_vertical.png') text = '<img src="%s" width="56" height="200" style="float: left;"/>' % logo text += '<h3 style="margin-top: 1px;">%s</h3>' % self.tr('rqt') text += '<p>%s %s</p>' % ( self.tr('rqt is a framework for graphical user interfaces.'), self. tr('It is extensible with plugins which can be written in either Python or C++.' )) text += '<p>%s</p>' % (self.tr( 'Please see the <a href="%s">Wiki</a> for more information on rqt and available ' 'plugins.' % 'http://wiki.ros.org/rqt')) text += '<p>%s: ' % self.tr('Utilized libraries:') text += 'Python %s, ' % platform.python_version() if QT_BINDING == 'pyside': text += 'PySide' elif QT_BINDING == 'pyqt': text += 'PyQt' text += ' %s (%s), ' % (QT_BINDING_VERSION, ', '.join( sorted(QT_BINDING_MODULES))) text += 'Qt %s, ' % qVersion() if qt_gui_cpp is not None: if QT_BINDING == 'pyside': text += '%s' % (self.tr('%s C++ bindings available') % 'Shiboken') elif QT_BINDING == 'pyqt': text += '%s' % (self.tr('%s C++ bindings available') % 'SIP') else: text += '%s' % self.tr('C++ bindings available') else: text += '%s' % self.tr( 'no C++ bindings found - no C++ plugins available') text += '.</p>' mb = QMessageBox(QMessageBox.NoIcon, self.tr('About rqt'), text, QMessageBox.Ok, self.parent()) mb.exec_()
def _export_region(self, path, topics, start_stamp, end_stamp): """ Starts a thread to save the current selection to a new bag file :param path: filesystem path to write to, ''str'' :param topics: topics to write to the file, ''list(str)'' :param start_stamp: start of area to save, ''rospy.Time'' :param end_stamp: end of area to save, ''rospy.Time'' """ if not self.start_background_task('Copying messages to "%s"' % path): return # TODO implement a status bar area with information on the current save status bag_entries = list( self.get_entries_with_bags(topics, start_stamp, end_stamp)) if self.background_task_cancel: return # Get the total number of messages to copy total_messages = len(bag_entries) # If no messages, prompt the user and return if total_messages == 0: QMessageBox(QMessageBox.Warning, 'rqt_bag', 'No messages found', QMessageBox.Ok).exec_() self.stop_background_task() return # Open the path for writing try: export_bag = rosbag.Bag(path, 'w') except Exception: QMessageBox(QMessageBox.Warning, 'rqt_bag', 'Error opening bag file [%s] for writing' % path, QMessageBox.Ok).exec_() self.stop_background_task() return # Run copying in a background thread self._export_thread = threading.Thread(target=self._run_export_region, args=(export_bag, topics, start_stamp, end_stamp, bag_entries)) self._export_thread.start()
def __init__(self, context, bag_widget, publish_clock): super(AnnotatorWidget, self).__init__() rp = rospkg.RosPack() ui_file = os.path.join(rp.get_path('rqt_bag_meri_annotator'), 'resource', 'MeriPlugin.ui') loadUi(ui_file, self, {'AnnotatorGraphicsView': AnnotatorGraphicsView}) self.setObjectName('AnnotatorWidget') self.setMouseTracking(True) self.annotation_data = list() self.interaction_time = 120.0 self.bag_widget = bag_widget self.bagtimeline = self.bag_widget._timeline self._child_index = 0 self.settings = QSettings("UFES", "MERI Annotator Widget") #self.settings.setValue("Last_child_index",self._child_index) self.instance = vlc.Instance() self.mediaplayer = self.instance.media_player_new() self.isPaused = False self.msgBox = QMessageBox() self.msgBox.setIcon(QMessageBox.Information) self.msgBox.setWindowTitle('Annotator Interface Information') self.msgBox.setStandardButtons(QMessageBox.Ok) self.BtnSaveJson.clicked.connect(self.BtnSaveJsonClicked) self.BtnLoadJson.clicked.connect(self.BtnLoadJsonClicked) self.BtnNext.clicked.connect(self.BtnNextClicked) self.BtnSetupBag.clicked.connect(self.BtnSetupBagClicked) self.BtnPrevious.clicked.connect(self.BtnPreviousClicked) self.BtnZero.clicked.connect(self.BtnZeroClicked) self.BtnOne.clicked.connect(self.BtnOneClicked) self.BtnTwo.clicked.connect(self.BtnTwoClicked) self.BtnAimLess.clicked.connect(self.BtnAimLessClicked) self.BtnGoalOriented.clicked.connect(self.BtnGoalOrientedClicked) self.BtnRobotStarted.clicked.connect(self.BtnRobotStartedClicked) self.BtnPointing.clicked.connect(self.BtnPointingClicked) self.BtnFollowLor.clicked.connect(self.BtnFollowLorClicked) self.BtnAdultSeek.clicked.connect(self.BtnAdultSeekClicked) self.BtnECTwC.clicked.connect(self.BtnECTwCClicked) self.BtnECTwR.clicked.connect(self.BtnECTwRClicked) self.BtnECTwT.clicked.connect(self.BtnECTwTClicked) self.BtnPlay.clicked.connect(self.BtnPlayClicked) self.BtnPause.clicked.connect(self.BtnPauseClicked) self.BtnStop.clicked.connect(self.BtnStopClicked) self.BtnPlay.setIcon(QIcon.fromTheme('media-playback-start')) self.BtnPause.setIcon(QIcon.fromTheme('media-playback-pause')) self.BtnLoadJson.setIcon(QIcon.fromTheme('document-open')) self.BtnSaveJson.setIcon(QIcon.fromTheme('document-save')) self.BtnStop.setIcon(QIcon.fromTheme('media-playback-stop')) self.BtnNext.setIcon(QIcon.fromTheme('go-next')) self.BtnSetupBag.setIcon(QIcon.fromTheme('document-properties')) self.BtnPrevious.setIcon(QIcon.fromTheme('go-previous'))
def dialog_window(self, message, detail, check): self.message = QMessageBox() self.has_message_opened = 1 self.message.setIcon(QMessageBox.Warning) self.message.setText(message) self.message.setInformativeText(detail) self.message.setWindowTitle("Items are unchecked") self.message.setStandardButtons(QMessageBox.Yes | QMessageBox.No) self.message.show() if check == True: # Check == True means it is from ok_clicked self.message.buttonClicked.connect(self.message_action) else: self.message.buttonClicked.connect(self.message_action_uncheck)
def _start_experiment(self): for i, rb in enumerate(self.radiobuttons): if rb.isChecked(): self.experiment_type = i for i, rb in enumerate(self.skipradio): if rb.isChecked(): self.skip = i if self.skip != -1: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText("Are you sure you want to skip phases?") msg.setWindowTitle("Careful") msg.exec_() if self.skip_check: self.skip_check = False return if self.experiment_type == None: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText("Select which experiment to run!") msg.setWindowTitle("Careful") msg.exec_() return rospy.loginfo('Starting the experiment ' + str(self.experiment_type)) # Create the message message = ExperimentTrigger() message.type = self.experiment_type message.finnish = self._widget.finnish_box.isChecked() message.skip = self.skip message.name = self._widget.name_text.text() self.start_publisher.publish(message) self._widget.startButton.setEnabled(False)
def start_background_task(self, background_task): """ Verify that a background task is not currently running before starting a new one :param background_task: name of the background task, ''str'' """ if self.background_task is not None: QMessageBox( QMessageBox.Warning, 'Exclamation', 'Background operation already running:\n\n%s' % self.background_task, QMessageBox.Ok).exec_() return False self.background_task = background_task self.background_task_cancel = False return True
def registro(self): email = self._widget.email.text() user_name = self._widget.userName.text() phone = self._widget.phone.text() passw = self._widget.passw.text() repassw = self._widget.repass.text() # Error de contraseñas if passw != repassw: self.user = None msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Contraseña:") msg.setInformativeText(u"Las contraseñas no coinciden") msg.setWindowTitle("Error") ret = msg.exec_() else: try: self.user = firebase.addUser(email, passw, phone, user_name) firebase.newDataBase(self.user.display_name) # Error de registro except: self.user = None msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Registro:") msg.setInformativeText( u"No se ha podido registrar usuario: \n Datos erroneos, revisar:\n - Contraseña debe tener más de 6 digitos.\n - Verifique símbolos de los datos personales." ) msg.setWindowTitle("Error") ret = msg.exec_() # Registro exitoso msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText(u"Bienvenido:") msg.setInformativeText(u"Usuario creado exitosamente!") msg.setWindowTitle(u"Información") ret = msg.exec_()
def _run_export_region(self, export_bag, topics, start_stamp, end_stamp, bag_entries): """ Threaded function that saves the current selection to a new bag file :param export_bag: bagfile to write to, ''rosbag.bag'' :param topics: topics to write to the file, ''list(str)'' :param start_stamp: start of area to save, ''rospy.Time'' :param end_stamp: end of area to save, ''rospy.Time'' """ total_messages = len(bag_entries) update_step = max(1, total_messages / 100) message_num = 1 progress = 0 # Write out the messages for bag, entry in bag_entries: if self.background_task_cancel: break try: topic, msg, t = self.read_message(bag, entry.position) export_bag.write(topic, msg, t) except Exception as ex: qWarning('Error exporting message at position %s: %s' % (str(entry.position), str(ex))) export_bag.close() self.stop_background_task() return if message_num % update_step == 0 or message_num == total_messages: new_progress = int(100.0 * (float(message_num) / total_messages)) if new_progress != progress: progress = new_progress if not self.background_task_cancel: self.background_progress = progress self.status_bar_changed_signal.emit() message_num += 1 # Close the bag try: self.background_progress = 0 self.status_bar_changed_signal.emit() export_bag.close() except Exception as ex: QMessageBox( QMessageBox.Warning, 'rqt_bag', 'Error closing bag file [%s]: %s' % (export_bag.filename, str(ex)), QMessageBox.Ok).exec_() self.stop_background_task()
def dasherr(msg, obj, title='Error'): """ Logs a message with ``rospy.logerr`` and displays a ``QMessageBox`` to the user :param msg: Message to display. :type msg: str :param obj: Parent object for the ``QMessageBox`` :type obj: QObject :param title: An optional title for the `QMessageBox`` :type title: str """ rospy.logerr(msg) box = QMessageBox() box.setText(msg) box.setWindowTitle(title) box.show() obj._message_box = box
def check_client_set_up(self): '''Checks to see if the client is initialized, if not we check if the server is running before initializing the client. If server is not yet running we send a popup informing the user and return False.''' #checks to see if we have connected to service yet if self.plan_select_client == None: #we get list of services and see if any match plexil_plan_selection services = rosservice.get_service_list() service_running = [i for i in services if "plexil_plan_selection" in i] #if none exist we send a popup and return if len(service_running) == 0: popup = QMessageBox() popup.setWindowTitle("ow_plexil service not yet connected") popup.setText("ow_plexil plan selection service not connected yet, please make sure the ow_plexil launch file is running.") popup.exec_() return False else: #client setup rospy.wait_for_service('plexil_plan_selection') self.plan_select_client = rospy.ServiceProxy('plexil_plan_selection', PlanSelection) return True else: return True
def addManualCommand(self): indexes = self._widget.EstadosDeConexion.selectedIndexes() # SI no se ha seleccionado ningun robot SDV arrojar error if not indexes: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Asignación de Comando:") msg.setInformativeText( "Seleccione al menos un robot de la lista de conexiones") msg.setWindowTitle("Error") ret = msg.exec_() else: for index in indexes: sdv = index.data() self._comm = [ QtGui.QStandardItem(str(sdv)), QtGui.QStandardItem( str(self._widget.ListaInstrucciones.currentText())), QtGui.QStandardItem( str(self._widget.ListaMaquinas.currentText())) ] self.TablaInstrucciones_model.appendRow(self._comm)
def question_yn(qmsg='Message', title='Question'): ''' Asking Yes or No using PyQt QMessgageBox() Return 'True' only in the case that 'Yes' is chosen. @type qmsg : str @param qmsg : Question message for Yes/No answer (Default='Message') @type title : str @param title : Title of the message box window (Default='Question') @rtype : bool @return : Return when 'Yes' is chosen. ''' msgbox = QMessageBox() result = msgbox.question(msgbox, title, qmsg, msgbox.Yes | msgbox.No, msgbox.No) if result == msgbox.Yes: return True else: return False
def _import(self): print "import" array = pd.read_excel(self.gui.file_path, index_col=[0]).values.tolist() if len(self.data_replay) > 0: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) msg.setText("Data is not empty!\n Force clear") retval = msg.exec_() if retval == QMessageBox.Cancel: return else: self.data_replay = [] self.gui.listVeiw.clear() if isinstance(array, list): self.data_replay = array for i in range(0, len(self.data_replay)): self.gui.listView_add_item(i) pass
def create_alert(alert_msg): alert = QMessageBox() alert.setText(alert_msg) alert.exec_()
def showMessage(msgText): msgBox = QMessageBox() msgBox.setText(msgText) msgBox.exec_()
def errorPopup(self, title, e): msg_box = QMessageBox() msg_box.setWindowTitle(title) msg_box.setIcon(QMessageBox.Warning) msg_box.setText("%s"%e) msg_box.exec_()
def _no_support_warning(self): msg = QMessageBox() msg.setWindowTitle("Saving dataset...") msg.setIcon(QMessageBox.Critical) msg.setText("This format is not yet supported.") x = msg.exec_()