Example #1
0
    def _connect_rocon_master(self):
        rocon_master_name = str(
            self.rocon_masters[self.cur_selected_rocon_master].name)
        rocon_master_uri = str(
            self.rocon_masters[self.cur_selected_rocon_master].uri)
        rocon_master_host_name = str(
            self.rocon_masters[self.cur_selected_rocon_master].host_name)

        rocon_master_index = str(self.cur_selected_rocon_master)
        self.rocon_masters[rocon_master_index].check()
        # Todo this use of flags is spanky
        if self.rocon_masters[rocon_master_index].flag == '0':
            QMessageBox.warning(
                self, 'Rocon Master Connection Error',
                "Could not find a rocon master at %s" %
                self.rocon_masters[rocon_master_index].uri, QMessageBox.Ok)
            return
        if self.rocon_masters[rocon_master_index].flag == '1':
            QMessageBox.warning(
                self, 'Rocon Master Communication Error',
                "Found a rocon master at %s but cannot communicate with it (are ROS_IP/ROS_MASTER_URI correctly configured locally and remotely?)"
                % self.rocon_masters[rocon_master_index].uri, QMessageBox.Ok)
            return

        self._widget_main.hide()
        arguments = ["", rocon_master_uri, rocon_master_host_name]
        os.execv(QMasterChooser.rocon_remocon_sub_script, arguments)
        console.logdebug("Spawning: %s with args %s" %
                         (QMasterChooser.rocon_remocon_sub_script, arguments))
 def on_save_motion_button_clicked(self):
     motion_name = str(self.motion_name_combo.currentText())
     if len(motion_name) == 0:
         QMessageBox.warning(self, 'Error', 'No name given to save this motion.')
         return
     self._motion_data.save(motion_name, self.get_motion_from_timeline())
     self.update_motion_name_combo()
    def _rightclick_menu(self, event):
        menu = QMenu()
        text_action = QAction(self.tr('View Text'), menu)
        menu.addAction(text_action)
        raw_action = QAction(self.tr('View Raw'), menu)
        menu.addAction(raw_action)

        action = menu.exec_(event.globalPos())

        if action == raw_action or action == text_action:
            selected = self.messages_tree.selectedIndexes()
            selected_type = selected[1].data()

            if selected_type[-2:] == '[]':
                selected_type = selected_type[:-2]
            browsetext = None
            try:
                if self._mode == rosmsg.MODE_MSG:
                    browsetext = rosmsg.get_msg_text(selected_type,
                                                     action == raw_action)
                elif self._mode == rosmsg.MODE_SRV:
                    browsetext = rosmsg.get_srv_text(selected_type,
                                                     action == raw_action)
                else:
                    raise
            except rosmsg.ROSMsgException, e:
                QMessageBox.warning(
                    self, self.tr('Warning'),
                    self.
                    tr('The selected item component does not have text to view.'
                       ))
            if browsetext is not None:
                self._browsers.append(TextBrowseDialog(browsetext))
                self._browsers[-1].show()
Example #4
0
 def on_save_motion_button_clicked(self):
     motion_name = str(self.motion_name_combo.currentText())
     if len(motion_name) == 0:
         QMessageBox.warning(self, 'Error',
                             'No name given to save this motion.')
         return
     self._motion_data.save(motion_name, self.get_motion_from_timeline())
     self.update_motion_name_combo()
 def on_move_button_clicked(self):
     position_name = str(self.move_name_combo.currentText())
     if len(position_name) == 0:
         QMessageBox.warning(self, 'Error', 'No position selected to move to.')
         return
     appendix_name = str(self.move_appendix_combo.currentText())
     target_positions = self._position_data[self.robot_config.groups[appendix_name].group_type][position_name]
     target_positions = self.robot_config.groups[appendix_name].adapt_to_side(target_positions)
     print '[Motion Editor] Moving %s to "%s": %s' % (appendix_name, position_name, target_positions)
     self._motion_publisher.move_to_position(appendix_name, target_positions)
 def on_delete_motion_button_clicked(self):
     motion_name = str(self.motion_name_combo.currentText())
     if len(motion_name) == 0:
         QMessageBox.warning(self, 'Error', 'No motion selected to delete.')
         return
     if motion_name not in self._motion_data:
         QMessageBox.warning(self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
         return
     self._motion_data.delete(motion_name)
     self.update_motion_name_combo()
Example #7
0
 def show_saved_map_message(self, rtn):
     (success, message) = rtn
     if success:
         QMessageBox.warning(self, 'SUCCESS', "SAVE!!!!",
                             QMessageBox.Ok | QMessageBox.Ok)
     else:
         QMessageBox.warning(self, 'FAIL',
                             "FAIURE CAPTURE[%s]" % str(message),
                             QMessageBox.Ok | QMessageBox.Ok)
     self.setDisabled(False)
Example #8
0
 def on_delete_motion_button_clicked(self):
     motion_name = str(self.motion_name_combo.currentText())
     if len(motion_name) == 0:
         QMessageBox.warning(self, 'Error', 'No motion selected to delete.')
         return
     if motion_name not in self._motion_data:
         QMessageBox.warning(
             self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
         return
     self._motion_data.delete(motion_name)
     self.update_motion_name_combo()
 def on_run_motion_button_clicked(self):
     motion_name = str(self.motion_name_combo.currentText())
     if len(motion_name) == 0:
         QMessageBox.warning(self, 'Error', 'No motion selected to run.')
         return
     if motion_name not in self._motion_data:
         QMessageBox.warning(self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
         return
     self._clear_playback_marker()
     self._motion_publisher.publish_motion(self._motion_data[motion_name], self.time_factor_spin.value())
     print '[Motion Editor] Running motion:', motion_name
Example #10
0
 def _stop_interaction(self):
     console.logdebug("Interactions Chooser : stopping interaction %s " % str(self.cur_selected_interaction.name))
     (result, message) = self.interactive_client.stop_interaction(self.cur_selected_interaction.hash)
     if result:
         if self.cur_selected_interaction.is_paired_type():
             self._refresh_interactions_list()  # make sure the highlight is disabled
         self._set_stop_interactions_button()
         #self.interactions_widget.stop_interactions_button.setDisabled(True)
     else:
         QMessageBox.warning(self, 'Stop Interaction Failed', "%s." % message.capitalize(), QMessageBox.Ok)
         console.logwarn("Interactions Chooser : stop interaction failed [%s]" % message)
	def _send_comand_cb(self):
		'''
			Sends a mission command
		'''
		msg = MissionCommand()	
		msg.command = self._widget.comboBox_command.currentText()
		
		try:
			msg.variable = float(self._widget.lineEdit_parameter.text().encode("utf8"))
		except ValueError, e:
			rospy.logerr('MissionCommanderGUI:_send_command_cb: %s',e)
			QMessageBox.warning(self._widget, 'Error', 'Incorrect format of the parameter. A number is expected')
 def on_delete_button_clicked(self):
     appendix_name = str(self.save_appendix_combo.currentText())
     position_name = str(self.save_name_combo.currentText())
     if len(position_name) == 0 or \
        position_name not in self._position_data[self.robot_config.groups[appendix_name].group_type]:
         QMessageBox.warning(self, 'Error', 'Position "%s" not in position list.')
         return
     self._position_data[self.robot_config.groups[appendix_name].group_type].delete(position_name)
     self.position_list_updated.emit(self._position_data)
     self.on_save_appendix_combo_currentIndexChanged(appendix_name)
     if self.robot_config.groups[self.move_appendix_combo.currentText()].group_type \
        == self.robot_config.groups[appendix_name].group_type:
         self.on_move_appendix_combo_currentIndexChanged(appendix_name)
Example #13
0
 def save_map(self):
     if self._slam_widget_interface:
         self.setDisabled(True)
         map_name = str(self.map_name_txt.toPlainText()).lower().replace(
             ' ', '_')
         world_name = str(
             self.world_name_txt.toPlainText()).lower().replace(' ', '_')
         self.map_name_txt.setPlainText(map_name)
         self.world_name_txt.setPlainText(world_name)
         self._callback['save_map'](world=world_name, map_name=map_name)
     else:
         QMessageBox.warning(self, 'FAIL', "No map has created",
                             QMessageBox.Ok | QMessageBox.Ok)
Example #14
0
 def on_run_motion_button_clicked(self):
     motion_name = str(self.motion_name_combo.currentText())
     if len(motion_name) == 0:
         QMessageBox.warning(self, 'Error', 'No motion selected to run.')
         return
     if motion_name not in self._motion_data:
         QMessageBox.warning(
             self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
         return
     self._clear_playback_marker()
     self._motion_publisher.publish_motion(self._motion_data[motion_name],
                                           self.time_factor_spin.value())
     print '[Motion Editor] Running motion:', motion_name
 def on_load_motion_button_clicked(self):
     motion_name = str(self.motion_name_combo.currentText())
     if len(motion_name) == 0:
         QMessageBox.warning(self, 'Error', 'No motion selected to load.')
         return
     if motion_name not in self._motion_data:
         QMessageBox.warning(self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
         return
     self.on_clear_motion_button_clicked()
     motion = self._motion_data[motion_name]
     for group_name, poses in motion.items():
         for pose in poses:
             data = self.robot_config.groups[group_name].adapt_to_side(pose['positions'])
             self._timeline_widget.scene().add_clip(group_name, pose['name'], pose['starttime'], pose['duration'], data)
Example #16
0
    def _choose_new_perspective_name(self, show_cloning=True):
        # input dialog for new perspective name
        if self._create_perspective_dialog is None:
            ui_file = os.path.join(self._qtgui_path, 'resource',
                                   'perspective_create.ui')
            self._create_perspective_dialog = loadUi(ui_file)

            # custom validator preventing forward slashs
            class CustomValidator(QValidator):
                def __init__(self, parent=None):
                    super(CustomValidator, self).__init__(parent)

                def fixup(self, value):
                    value = value.replace('/', '')

                def validate(self, value, pos):
                    if value.find('/') != -1:
                        pos = value.find('/')
                        return (QValidator.Invalid, value, pos)
                    if value == '':
                        return (QValidator.Intermediate, value, pos)
                    return (QValidator.Acceptable, value, pos)

            self._create_perspective_dialog.perspective_name_edit.setValidator(
                CustomValidator())

        # set default values
        self._create_perspective_dialog.perspective_name_edit.setText('')
        self._create_perspective_dialog.clone_checkbox.setChecked(True)
        self._create_perspective_dialog.clone_checkbox.setVisible(show_cloning)

        # show dialog and wait for it's return value
        return_value = self._create_perspective_dialog.exec_()
        if return_value == self._create_perspective_dialog.Rejected:
            return

        name = str(self._create_perspective_dialog.perspective_name_edit.text(
        )).lstrip(self.HIDDEN_PREFIX)
        if name == '':
            QMessageBox.warning(
                self._menu_manager.menu, self.tr('Empty perspective name'),
                self.tr('The name of the perspective must be non-empty.'))
            return
        if name in self.perspectives:
            QMessageBox.warning(
                self._menu_manager.menu, self.tr('Duplicate perspective name'),
                self.tr('A perspective with the same name already exists.'))
            return
        return name
 def on_delete_button_clicked(self):
     appendix_name = str(self.save_appendix_combo.currentText())
     position_name = str(self.save_name_combo.currentText())
     if len(position_name) == 0 or \
        position_name not in self._position_data[self.robot_config.groups[appendix_name].group_type]:
         QMessageBox.warning(self, 'Error',
                             'Position "%s" not in position list.')
         return
     self._position_data[self.robot_config.groups[appendix_name].
                         group_type].delete(position_name)
     self.position_list_updated.emit(self._position_data)
     self.on_save_appendix_combo_currentIndexChanged(appendix_name)
     if self.robot_config.groups[self.move_appendix_combo.currentText()].group_type \
        == self.robot_config.groups[appendix_name].group_type:
         self.on_move_appendix_combo_currentIndexChanged(appendix_name)
 def on_move_button_clicked(self):
     position_name = str(self.move_name_combo.currentText())
     if len(position_name) == 0:
         QMessageBox.warning(self, 'Error',
                             'No position selected to move to.')
         return
     appendix_name = str(self.move_appendix_combo.currentText())
     target_positions = self._position_data[
         self.robot_config.groups[appendix_name].group_type][position_name]
     target_positions = self.robot_config.groups[
         appendix_name].adapt_to_side(target_positions)
     print '[Motion Editor] Moving %s to "%s": %s' % (
         appendix_name, position_name, target_positions)
     self._motion_publisher.move_to_position(appendix_name,
                                             target_positions)
Example #19
0
    def _rightclick_menu(self, event):
        """
        :type event: QEvent
        """

        # QTreeview.selectedIndexes() returns 0 when no node is selected.
        # This can happen when after booting no left-click has been made yet
        # (ie. looks like right-click doesn't count). These lines are the
        # workaround for that problem.
        selected = self._messages_tree.selectedIndexes()
        if len(selected) == 0:
            return

        menu = QMenu()
        text_action = QAction(self.tr('View Text'), menu)
        menu.addAction(text_action)
        raw_action = QAction(self.tr('View Raw'), menu)
        menu.addAction(raw_action)

        action = menu.exec_(event.globalPos())

        if action == raw_action or action == text_action:
            rospy.logdebug('_rightclick_menu selected={}'.format(selected))
            selected_type = selected[1].data()

            if selected_type[-2:] == '[]':
                selected_type = selected_type[:-2]
            browsetext = None
            try:
                if (self._mode == rosmsg.MODE_MSG
                        or self._mode == rosaction.MODE_ACTION):
                    browsetext = rosmsg.get_msg_text(selected_type,
                                                     action == raw_action)
                elif self._mode == rosmsg.MODE_SRV:
                    browsetext = rosmsg.get_srv_text(selected_type,
                                                     action == raw_action)

                else:
                    raise
            except rosmsg.ROSMsgException, e:
                QMessageBox.warning(
                    self, self.tr('Warning'),
                    self.tr('The selected item component ' +
                            'does not have text to view.'))
            if browsetext is not None:
                self._browsers.append(
                    TextBrowseDialog(browsetext, self._rospack))
                self._browsers[-1].show()
	def _reset_steering_encoder_cb(self):
		'''
			Resets the steering encoder
		'''
		msg = Empty()
		ret = QMessageBox.question(self._widget, "Reset Encoder", 'Are you sure of resetting the encoder?', QMessageBox.Ok, QMessageBox.Cancel)
		
		if ret == QMessageBox.Ok:
			try:
				self._reset_steering_encoder_service_client()
			except rospy.ROSInterruptException,e: 
				rospy.logerr('MissionCommanderGUI:_reset_steering_encoder_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
			except rospy.ServiceException,e: 
				rospy.logerr('MissionCommanderGUI:_reset_steering_encoder_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
 def on_save_button_clicked(self):
     position_name = str(self.save_name_combo.currentText())
     if len(position_name) == 0:
         QMessageBox.warning(self, 'Error', 'No name given to save this position.')
         return
     appendix_name = str(self.save_appendix_combo.currentText())
     group = self.robot_config.groups[appendix_name]
     current_positions = self._motion_publisher.get_current_positions(group)
     current_positions = self.robot_config.groups[appendix_name].adapt_to_side(current_positions)
     print '[Motion Editor] Saving %s as "%s": %s' % (appendix_name, position_name, current_positions)
     self._position_data[self.robot_config.groups[appendix_name].group_type].save(position_name, current_positions)
     self.position_list_updated.emit(self._position_data)
     self.on_save_appendix_combo_currentIndexChanged(appendix_name)
     if self.robot_config.groups[self.move_appendix_combo.currentText()].group_type \
        == self.robot_config.groups[appendix_name].group_type:
         self.on_move_appendix_combo_currentIndexChanged(appendix_name)
    def _rightclick_menu(self, event):
        """
        :type event: QEvent
        """

        # QTreeview.selectedIndexes() returns 0 when no node is selected.
        # This can happen when after booting no left-click has been made yet
        # (ie. looks like right-click doesn't count). These lines are the
        # workaround for that problem.
        selected = self._messages_tree.selectedIndexes()
        if len(selected) == 0:
            return

        menu = QMenu()
        text_action = QAction(self.tr('View Text'), menu)
        menu.addAction(text_action)
        raw_action = QAction(self.tr('View Raw'), menu)
        menu.addAction(raw_action)

        action = menu.exec_(event.globalPos())

        if action == raw_action or action == text_action:
            rospy.logdebug('_rightclick_menu selected={}'.format(selected))
            selected_type = selected[1].data()

            if selected_type[-2:] == '[]':
                selected_type = selected_type[:-2]
            browsetext = None
            try:
                if (self._mode == rosmsg.MODE_MSG or
                    self._mode == rosaction.MODE_ACTION):
                    browsetext = rosmsg.get_msg_text(selected_type,
                                                     action == raw_action)
                elif self._mode == rosmsg.MODE_SRV:
                    browsetext = rosmsg.get_srv_text(selected_type,
                                                     action == raw_action)

                else:
                    raise
            except rosmsg.ROSMsgException, e:
                QMessageBox.warning(self, self.tr('Warning'),
                                    self.tr('The selected item component ' +
                                            'does not have text to view.'))
            if browsetext is not None:
                self._browsers.append(TextBrowseDialog(browsetext,
                                                       self._rospack))
                self._browsers[-1].show()
	def _set_pantilt_cb(self):
		'''
			Sends the setPanTilt command to the platform
		'''
		msg = PlatformCommand()	
		msg.command = 'setPanTilt'
		
		msg.variables = [self._widget.doubleSpinBox_set_pan.value(), self._widget.doubleSpinBox_set_tilt.value()]
		#msg.variables = [0.0, 0.0]
		
		#print self._widget.doubleSpinBox_set_pan.value()
		
		try:
			self._platform_command_service_client(msg)
		except rospy.ROSInterruptException,e: 
			rospy.logerr('MissionCommanderGUI:_set_pantilt_cb: %s',e)
			QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
	def _stop_vehicle_cb(self):
		'''
			Sends the stopcommand to the platform
		'''
		msg = PlatformCommand()	
		msg.command = 'cancel'
		
		ret = QMessageBox.question(self._widget, "Stop Vehicle", 'Do you want to stop the vehicle?', QMessageBox.Ok, QMessageBox.Cancel)
		
		if ret == QMessageBox.Ok:
			try:
				self._platform_command_service_client(msg)
			except rospy.ROSInterruptException,e: 
				rospy.logerr('MissionCommanderGUI:_stop_vehicle_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
			except rospy.ServiceException,e: 
				rospy.logerr('MissionCommanderGUI:_stop_vehicle_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
	def _fold_crane_cb(self):
		'''
			Sends the foldCrane command to the platform
		'''
		msg = PlatformCommand()	
		msg.command = 'foldCrane'
		
		ret = QMessageBox.question(self._widget, "Fold Crane", 'Do you want to fold the crane?', QMessageBox.Ok, QMessageBox.Cancel)
		
		if ret == QMessageBox.Ok:
			try:
				self._platform_command_service_client(msg)
			except rospy.ROSInterruptException,e: 
				rospy.logerr('MissionCommanderGUI:_fold_crane_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
			except rospy.ServiceException,e: 
				rospy.logerr('MissionCommanderGUI:_fold_crane_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
Example #26
0
    def _show_release_teleop_message(self, rtn):
        if rtn:
            QMessageBox.warning(self._widget, 'SUCCESS', "RELEASE!!!!",
                                QMessageBox.Ok | QMessageBox.Ok)
            for k in self.robot_item_list.keys():
                if self.robot_item_list[k] == self.current_captured_robot:
                    k.setBackground(0, QBrush(Qt.NoBrush))
                    k.setBackgroundColor(0, QColor(0, 0, 0, 0))
                    robot_name = k.text(0)
                    k.setText(0, robot_name[:robot_name.find(" (captured)")])
        else:
            QMessageBox.warning(self._widget, 'FAIL', "FAIURE RELEASE!!!!",
                                QMessageBox.Ok | QMessageBox.Ok)

        self._widget.setDisabled(False)
        self._widget.capture_teleop_btn.setEnabled(True)
        self._widget.release_teleop_btn.setEnabled(False)
        self.current_captured_robot = None
Example #27
0
 def deleteTrack(self, unused=None):
     trackId = self.editor.activeTrackId
     reply = QMessageBox.warning(
         self.widget, "Delete track %d" % trackId,
         "Do you really want to delete the track with ID %d? This cannot be undone."
         % trackId, QMessageBox.Yes | QMessageBox.No)
     if reply == QMessageBox.Yes:
         self.editor.deleteActiveTrack()
     self.updateTrackCount()
Example #28
0
 def shutdown_plugin(self):
     self.shutdownRequested = True
     if self.database.hasUnsavedChanges:
         reply = QMessageBox.warning(
             self.widget, "Close track annotation tool",
             "You have unsaved changes. Do you want to save these changes before closing?",
             QMessageBox.Yes | QMessageBox.No)
         if reply == QMessageBox.Yes:
             self.uiActions.saveDatabase()
	def _initialize_platform_cb(self):
		'''
			Initialize platform encoders
		'''
		msg = Empty()
		
		
		ret = QMessageBox.question(self._widget, "Init platform", 'Are you sure of initializing?', QMessageBox.Ok, QMessageBox.Cancel)
		
		if ret == QMessageBox.Ok:
			try:
				self._initialize_platform_service_client()
			except rospy.ROSInterruptException,e: 
				rospy.logerr('MissionCommanderGUI:_initialize_platform_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
			except rospy.ServiceException,e: 
				rospy.logerr('MissionCommanderGUI:_initialize_platform_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
	def _set_control_mode_cb(self):
		'''
			Sets the platform control mode
		'''
		msg = SetControlMode()	
		msg.mode = self._widget.comboBox_control_mode.currentText()
		
		ret = QMessageBox.question(self._widget, "Set Control Mode", 'Set control mode to %s?'%msg.mode, QMessageBox.Ok, QMessageBox.Cancel)
		
		if ret == QMessageBox.Ok:
		
			try:
				self._set_control_mode_service_client(msg.mode) 
			except rospy.ROSInterruptException,e: 
				rospy.logerr('MissionCommanderGUI:_set_control_mode_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
			except rospy.ServiceException,e: 
				rospy.logerr('MissionCommanderGUI:_set_control_mode_cb: %s',e)
				QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
Example #31
0
 def on_load_motion_button_clicked(self):
     motion_name = str(self.motion_name_combo.currentText())
     if len(motion_name) == 0:
         QMessageBox.warning(self, 'Error', 'No motion selected to load.')
         return
     if motion_name not in self._motion_data:
         QMessageBox.warning(
             self, 'Error', 'Motion "%s" not in motion list.' % motion_name)
         return
     self.on_clear_motion_button_clicked()
     motion = self._motion_data[motion_name]
     for group_name, poses in motion.items():
         for pose in poses:
             data = self.robot_config.groups[group_name].adapt_to_side(
                 pose['positions'])
             self._timeline_widget.scene().add_clip(group_name,
                                                    pose['name'],
                                                    pose['starttime'],
                                                    pose['duration'], data)
Example #32
0
    def _show_release_resource_message(self, rtn):
        if rtn:
            QMessageBox.warning(self, 'SUCCESS', "RELEASE!!!!", QMessageBox.Ok | QMessageBox.Ok)
        else:
            QMessageBox.warning(self, 'FAIL', "FAIURE RELEASE!!!!", QMessageBox.Ok | QMessageBox.Ok)

        self._lock.acquire()
        if rtn:
            for k in self.resource_item_list.keys():
                if self.resource_item_list[k] == self.current_captured_resource:
                    k.setBackground(0, QBrush(Qt.NoBrush))
                    k.setBackgroundColor(0, QColor(0, 0, 0, 0))
                    resource_name= k.text(0)
                    k.setText(0, resource_name[:resource_name.find(" (captured)")])
        self.setDisabled(False)
        self.capture_resource_btn.setEnabled(True)
        self.release_resource_btn.setEnabled(False)
        self.current_captured_resource= None
        self._lock.release()
Example #33
0
    def _choose_new_perspective_name(self, show_cloning=True):
        # input dialog for new perspective name
        if self._create_perspective_dialog is None:
            ui_file = os.path.join(self._qtgui_path, 'resource', 'perspective_create.ui')
            self._create_perspective_dialog = loadUi(ui_file)

            # custom validator preventing forward slashs
            class CustomValidator(QValidator):
                def __init__(self, parent=None):
                    super(CustomValidator, self).__init__(parent)

                def fixup(self, value):
                    value = value.replace('/', '')

                def validate(self, value, pos):
                    if value.find('/') != -1:
                        pos = value.find('/')
                        return (QValidator.Invalid, value, pos)
                    if value == '':
                        return (QValidator.Intermediate, value, pos)
                    return (QValidator.Acceptable, value, pos)
            self._create_perspective_dialog.perspective_name_edit.setValidator(CustomValidator())

        # set default values
        self._create_perspective_dialog.perspective_name_edit.setText('')
        self._create_perspective_dialog.clone_checkbox.setChecked(True)
        self._create_perspective_dialog.clone_checkbox.setVisible(show_cloning)

        # show dialog and wait for it's return value
        return_value = self._create_perspective_dialog.exec_()
        if return_value == self._create_perspective_dialog.Rejected:
            return

        name = str(self._create_perspective_dialog.perspective_name_edit.text()).lstrip(self.HIDDEN_PREFIX)
        if name == '':
            QMessageBox.warning(self._menu_manager.menu, self.tr('Empty perspective name'), self.tr('The name of the perspective must be non-empty.'))
            return
        if name in self.perspectives:
            QMessageBox.warning(self._menu_manager.menu, self.tr('Duplicate perspective name'), self.tr('A perspective with the same name already exists.'))
            return
        return name
Example #34
0
 def _show_capture_teleop_message(self, rtn):
     if rtn:
         QMessageBox.warning(self._widget, 'SUCCESS', "CAPTURE!!!!",
                             QMessageBox.Ok | QMessageBox.Ok)
         for k in self.robot_item_list.keys():
             if self.robot_item_list[k] == self.current_robot:
                 k.setBackground(0, QBrush(Qt.SolidPattern))
                 k.setBackgroundColor(0, QColor(0, 255, 0, 255))
                 robot_name = k.text(0)
                 k.setText(0, str(robot_name) + " (captured)")
             else:
                 k.setBackground(0, QBrush(Qt.NoBrush))
                 k.setBackgroundColor(0, QColor(0, 0, 0, 0))
                 robot_name = k.text(0)
         self._widget.capture_teleop_btn.setEnabled(False)
         self._widget.release_teleop_btn.setEnabled(True)
         self.current_captured_robot = self.current_robot
     else:
         QMessageBox.warning(self._widget, 'FAIL', "FAIURE CAPTURE!!!!",
                             QMessageBox.Ok | QMessageBox.Ok)
     self._widget.setDisabled(False)
 def on_save_button_clicked(self):
     position_name = str(self.save_name_combo.currentText())
     if len(position_name) == 0:
         QMessageBox.warning(self, 'Error',
                             'No name given to save this position.')
         return
     appendix_name = str(self.save_appendix_combo.currentText())
     group = self.robot_config.groups[appendix_name]
     current_positions = self._motion_publisher.get_current_positions(group)
     current_positions = self.robot_config.groups[
         appendix_name].adapt_to_side(current_positions)
     print '[Motion Editor] Saving %s as "%s": %s' % (
         appendix_name, position_name, current_positions)
     self._position_data[
         self.robot_config.groups[appendix_name].group_type].save(
             position_name, current_positions)
     self.position_list_updated.emit(self._position_data)
     self.on_save_appendix_combo_currentIndexChanged(appendix_name)
     if self.robot_config.groups[self.move_appendix_combo.currentText()].group_type \
        == self.robot_config.groups[appendix_name].group_type:
         self.on_move_appendix_combo_currentIndexChanged(appendix_name)
Example #36
0
 def _show_capture_resource_message(self, rtn):
     if rtn:
         QMessageBox.warning(self, 'SUCCESS', "CAPTURE!!!!", QMessageBox.Ok | QMessageBox.Ok)
     else:
         QMessageBox.warning(self, 'FAIL', "FAIURE CAPTURE!!!!", QMessageBox.Ok | QMessageBox.Ok)
     self._lock.acquire()
     if rtn:
         for k in self.resource_item_list.keys():
             if self.resource_item_list[k] == self.current_resource:
                 k.setBackground(0, QBrush(Qt.SolidPattern))
                 k.setBackgroundColor(0, QColor(0, 255, 0, 255))
                 resource_name = k.text(0)
                 k.setText(0, str(resource_name) + " (captured)")
             else:
                 k.setBackground(0, QBrush(Qt.NoBrush))
                 k.setBackgroundColor(0, QColor(0, 0, 0, 0))
                 resource_name = k.text(0)
         self.capture_resource_btn.setEnabled(False)
         self.release_resource_btn.setEnabled(True)
         self.current_captured_resource = self.current_resource
     self.setDisabled(False)
     self._lock.release()
Example #37
0
 def shutdown_plugin(self):
     modified = False
     for function in self.functions:
         if self.functions[function].isModified():
             modified = True
     if modified:
         ret = QMessageBox.warning(self.master_widget, "Save",
                     "The logical map has been modified.\n"
                     "Do you want to save your changes?",
                     QMessageBox.Save | QMessageBox.Discard)
         if ret == QMessageBox.Save:
             for function in self.functions:
                 self.functions[function].saveConfiguration()
Example #38
0
 def _stop_interaction(self):
     """
     Stop running interactions when user hits `stop` or 'all stop interactions button` button.
     If no interactions is running, buttons are disabled.
     """
     console.logdebug("Interactions Chooser : stopping interaction %s " %
                      str(self.cur_selected_interaction.name))
     (result, message) = self.interactive_client_interface.stop_interaction(
         self.cur_selected_interaction.hash)
     if result:
         if self.cur_selected_interaction.is_paired_type():
             self.refresh_interactions_list(
             )  # make sure the highlight is disabled
         self._set_stop_interactions_button()
         # self.interactions_widget.stop_interactions_button.setDisabled(True)
     else:
         QMessageBox.warning(self.interactions_widget,
                             'Stop Interaction Failed',
                             "%s." % message.capitalize(), QMessageBox.Ok)
         console.logwarn(
             "Interactions Chooser : stop interaction failed [%s]" %
             message)
Example #39
0
 def _start_interaction(self):
     """
     Start selected interactions when user hits start button and does doubleclicking interaction item.
     The interactions can be launched in duplicate.
     """
     console.logdebug("Interactions Chooser : starting interaction [%s]" %
                      str(self.cur_selected_interaction.name))
     (result,
      message) = self.interactive_client_interface.start_interaction(
          self.cur_selected_role, self.cur_selected_interaction.hash)
     if result:
         if self.cur_selected_interaction.is_paired_type():
             self.refresh_interactions_list(
             )  # make sure the highlight is working
         self.interactions_widget.stop_interactions_button.setDisabled(
             False)
     else:
         QMessageBox.warning(self.interactions_widget,
                             'Start Interaction Failed',
                             "%s." % message.capitalize(), QMessageBox.Ok)
         console.logwarn(
             "Interactions Chooser : start interaction failed [%s]" %
             message)
Example #40
0
def show_message(parent, title, message):
    QMessageBox.warning(parent, str(title), str(message),
                        QMessageBox.Ok | QMessageBox.Ok)
Example #41
0
 def _show_error_teleop_message(self, err):
     QMessageBox.warning(self._widget, 'ERROR', err,
                         QMessageBox.Ok | QMessageBox.Ok)
     self._widget.setDisabled(False)
     self._widget.capture_teleop_btn.setEnabled(True)
     self._widget.release_teleop_btn.setEnabled(True)
Example #42
0
    def __init__(self, parent, title, application, rocon_master_index="", rocon_master_name="", rocon_master_uri='localhost', host_name='localhost'):
        super(QInteractionsChooser, self).__init__(parent)

        self.rocon_master_index = rocon_master_index
        self.rocon_master_uri = rocon_master_uri
        self.rocon_master_name = rocon_master_name
        self.host_name = host_name
        self.cur_selected_interaction = None
        self.cur_selected_role = 0
        self.interactions = {}
        self.interactive_client = InteractiveClient(stop_interaction_postexec_fn=self.interactions_updated_relay)

        self.application = application
        rospack = rospkg.RosPack()
        icon_file = os.path.join(rospack.get_path('rocon_icons'), 'icons', 'rocon_logo.png')
        self.application.setWindowIcon(QIcon(icon_file))

        self.interactions_widget = QWidget()
        self.roles_widget = QWidget()
        path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../ui/interactions_list.ui")
        loadUi(path, self.interactions_widget)
        path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../ui/role_list.ui")
        loadUi(path, self.roles_widget)

        # role list widget
        self.roles_widget.role_list_widget.setIconSize(QSize(50, 50))
        self.roles_widget.role_list_widget.itemDoubleClicked.connect(self._switch_to_interactions_list)
        self.roles_widget.back_btn.pressed.connect(self._switch_to_master_chooser)
        self.roles_widget.stop_all_interactions_button.pressed.connect(self._stop_all_interactions)
        self.roles_widget.refresh_btn.pressed.connect(self._refresh_role_list)
        self.roles_widget.closeEvent = self._close_event
        # interactions list widget
        self.interactions_widget.interactions_list_widget.setIconSize(QSize(50, 50))
        self.interactions_widget.interactions_list_widget.itemDoubleClicked.connect(self._start_interaction)
        self.interactions_widget.back_btn.pressed.connect(self._switch_to_role_list)
        self.interactions_widget.interactions_list_widget.itemClicked.connect(self._display_interaction_info)  # rocon master item click event
        self.interactions_widget.stop_interactions_button.pressed.connect(self._stop_interaction)
        self.interactions_widget.stop_interactions_button.setDisabled(True)
        self.interactions_widget.closeEvent = self._close_event

        # signals
        self.signal_interactions_updated.connect(self._refresh_interactions_list, Qt.QueuedConnection)
        self.signal_interactions_updated.connect(self._set_stop_interactions_button, Qt.QueuedConnection)

        # create a few directories for caching icons and ...
        utils.setup_home_dirs()

        # connect to the ros master
        (result, message) = self.interactive_client._connect(self.rocon_master_name, self.rocon_master_uri, self.host_name)
        if not result:
            QMessageBox.warning(self, 'Connection Failed', "%s." % message.capitalize(), QMessageBox.Ok)
            self._switch_to_master_chooser()
            return
        role_list = self._refresh_role_list()
        # Ugly Hack : our window manager is not graying out the button when an interaction closes itself down and the appropriate
        # callback (_set_stop_interactions_button) is fired. It does otherwise though so it looks like the window manager
        # is getting confused when the original program doesn't have the focus.
        #
        # Taking control of it ourselves works...
        self.interactions_widget.stop_interactions_button.setStyleSheet("QPushButton:disabled { color: gray }")

        # show interactions list if there's no choice amongst roles, otherwise show the role list
        if len(role_list) == 1:
            self.cur_selected_role = role_list[0]
            self.interactive_client.select_role(self.cur_selected_role)
            self.interactions_widget.show()
            self._refresh_interactions_list()
        else:
            self.roles_widget.show()
    def __init__(self,
                 parent,
                 title,
                 application,
                 rocon_master_uri='localhost',
                 host_name='localhost',
                 with_rqt=False):
        super(InteractiveClientUI, self).__init__(parent)
        self.rocon_master_uri = rocon_master_uri
        self.host_name = host_name
        self.with_rqt = with_rqt
        self.cur_selected_interaction = None
        self.cur_selected_role = 0
        self.interactions = {}

        # desktop taskbar icon
        self.application = application
        if self.application:
            rospack = rospkg.RosPack()
            icon_file = os.path.join(rospack.get_path('rocon_icons'), 'icons',
                                     'rocon_logo.png')
            self.application.setWindowIcon(QIcon(icon_file))

        # create a few directories for caching icons and ...
        utils.setup_home_dirs()

        # connect to the ros master with init node
        self.interactive_client_interface = InteractiveClientInterface(
            stop_interaction_postexec_fn=lambda: self.
            signal_interactions_updated.emit())

        if self.with_rqt:
            (result, message) = self.interactive_client_interface._connect(
                self.rocon_master_uri, self.host_name)
        else:
            (result, message
             ) = self.interactive_client_interface._connect_with_ros_init_node(
                 self.rocon_master_uri, self.host_name)

        if not result:
            QMessageBox.warning(self, 'Connection Failed',
                                "%s." % message.capitalize(), QMessageBox.Ok)
            self._switch_to_master_chooser()
            return

        # interactive_client_ui widget setting
        self._interactive_client_ui_widget = QWidget()
        self._interactive_client_ui_layout = QVBoxLayout()

        self._role_chooser = QRoleChooser(self.interactive_client_interface,
                                          with_rqt)
        self._role_chooser.bind_function('shutdown',
                                         self._switch_to_master_chooser)
        self._role_chooser.bind_function('back',
                                         self._switch_to_master_chooser)
        self._role_chooser.bind_function('select_role',
                                         self._switch_to_interactions_list)

        self._interactions_chooser = QInteractionsChooser(
            self.interactive_client_interface)
        self._interactions_chooser.bind_function(
            'shutdown', self._switch_to_master_chooser)
        self._interactions_chooser.bind_function('back',
                                                 self._switch_to_role_list)

        self._interactive_client_ui_layout.addWidget(
            self._interactions_chooser.interactions_widget)
        self._interactive_client_ui_layout.addWidget(
            self._role_chooser.roles_widget)
        self._interactive_client_ui_widget.setLayout(
            self._interactive_client_ui_layout)

        self.signal_interactions_updated.connect(
            self.interactions_updated_relay)

        self._init()
			if len(waypoints) == 0:
				QMessageBox.warning(self._widget, 'Error', 'No waypoints to send')
				return
			
			msg.points = waypoints
		
		#srv.command = msg
		
		try:
			self._command_service_client(msg)
		except rospy.ROSInterruptException,e: 
			rospy.logerr('MissionCommanderGUI:_send_command_cb: %s',e)
			QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
		except rospy.ServiceException,e: 
			rospy.logerr('MissionCommanderGUI:_send_command_cb: %s',e)
			QMessageBox.warning(self._widget, 'Error', 'Error sending the command')
	
	def _fold_crane_cb(self):
		'''
			Sends the foldCrane command to the platform
		'''
		msg = PlatformCommand()	
		msg.command = 'foldCrane'
		
		ret = QMessageBox.question(self._widget, "Fold Crane", 'Do you want to fold the crane?', QMessageBox.Ok, QMessageBox.Cancel)
		
		if ret == QMessageBox.Ok:
			try:
				self._platform_command_service_client(msg)
			except rospy.ROSInterruptException,e: 
				rospy.logerr('MissionCommanderGUI:_fold_crane_cb: %s',e)
Example #45
0
 def _show_error_resource_message(self, error_message):
     QMessageBox.warning(self, 'ERROR', error_message, QMessageBox.Ok | QMessageBox.Ok)
     self.setDisabled(False)
     self.capture_resource_btn.setEnabled(True)
     self.release_resource_btn.setEnabled(True)