示例#1
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)
    def __init__(self, masteruri, cfg, ns, nodes, parent=None):
        QtGui.QFrame.__init__(self, parent)
        self._masteruri = masteruri
        self._nodes = {cfg: {ns: nodes}}
        frame_layout = QtGui.QVBoxLayout(self)
        frame_layout.setContentsMargins(0, 0, 0, 0)
        # create frame for warning label
        self.warning_frame = warning_frame = QtGui.QFrame()
        warning_layout = QtGui.QHBoxLayout(warning_frame)
        warning_layout.setContentsMargins(0, 0, 0, 0)
        warning_layout.addItem(
            QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        self.warning_label = QtGui.QLabel()
        icon = QtGui.QIcon(':/icons/crystal_clear_warning.png')
        self.warning_label.setPixmap(icon.pixmap(QtCore.QSize(40, 40)))
        self.warning_label.setToolTip(
            'Multiple configuration for same node found!\nA first one will be selected for the start a node!'
        )
        warning_layout.addWidget(self.warning_label)
        warning_layout.addItem(
            QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        frame_layout.addItem(
            QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        frame_layout.addWidget(warning_frame)
        # create frame for start/stop buttons
        buttons_frame = QtGui.QFrame()
        buttons_layout = QtGui.QHBoxLayout(buttons_frame)
        buttons_layout.setContentsMargins(0, 0, 0, 0)
        buttons_layout.addItem(QtGui.QSpacerItem(20, 20))
        self.on_button = QtGui.QPushButton()
        self.on_button.setFlat(False)
        self.on_button.setText("On")
        self.on_button.clicked.connect(self.on_on_clicked)
        buttons_layout.addWidget(self.on_button)

        self.off_button = QtGui.QPushButton()
        self.off_button.setFlat(True)
        self.off_button.setText("Off")
        self.off_button.clicked.connect(self.on_off_clicked)
        buttons_layout.addWidget(self.off_button)
        buttons_layout.addItem(QtGui.QSpacerItem(20, 20))
        frame_layout.addWidget(buttons_frame)
        frame_layout.addItem(
            QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        self.warning_frame.setVisible(False)
示例#3
0
    def __init__(self, side, gui, parent=None):
        self.side = side
        self.gui = gui

        QtGui.QDialog.__init__(self, parent)
        self.setObjectName('PoseSaver')

        large_box = QtGui.QVBoxLayout()

        # Textbox to enter words for PR2 to say
        default_text = self.get_default_name()
        name_textbox = QtGui.QLineEdit(default_text)
        name_textbox.setFixedWidth(450)

        # Set a handler on the textbox to retrieve the text when button clicked
        self.name_textbox = name_textbox

        button_box = QtGui.QHBoxLayout()
        button_box.addItem(QtGui.QSpacerItem(15, 20))
        save_button = self.create_button('Save!', self.save_pose)
        save_button.setDefault(True)
        button_box.addWidget(save_button)
        button_box.addWidget(name_textbox)
        button_box.addStretch(1)
        large_box.addLayout(button_box)

        self.setLayout(large_box)
示例#4
0
    def __init__(self, plugin):
        super(ConfigDialog, self).__init__()
        self._plugin = plugin
        self._interval_spin_box = QtGui.QSpinBox()
        self._interval_spin_box.setMaximum(10000)
        self._interval_spin_box.setMinimum(1)
        self._interval_spin_box.setValue(
            publisher.TopicPublisherWithTimer.publish_interval)
        self._interval_spin_box.valueChanged.connect(self.update_interval)
        self._vertical_layout = QtGui.QVBoxLayout()
        self._horizontal_layout = QtGui.QHBoxLayout()
        spin_label = QtGui.QLabel('Publish Interval for repeat [ms]')
        self._horizontal_layout.addWidget(spin_label)
        self._horizontal_layout.addWidget(self._interval_spin_box)
        self._vertical_layout.addLayout(self._horizontal_layout)
        save_button = QtGui.QPushButton(parent=self)
        save_button.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DialogSaveButton))
        save_button.setText('Save to file')
        save_button.clicked.connect(self.save_to_file)

        load_button = QtGui.QPushButton(parent=self)
        load_button.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DialogOpenButton))
        load_button.setText('Load from file')
        load_button.clicked.connect(self.load_from_file)

        self._vertical_layout.addWidget(save_button)
        self._vertical_layout.addWidget(load_button)
        self.setLayout(self._vertical_layout)
        self.adjustSize()
示例#5
0
  def __init__(self, host, masteruri=None, parent=None):
    PackageDialog.__init__(self, parent)
    self.host = host
    self.setWindowTitle('Run')

    ns_name_label = QtGui.QLabel("NS/Name:", self.content)
    self.ns_field = QtGui.QComboBox(self.content)
    self.ns_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed))
    self.ns_field.setEditable(True)
    ns_history = nm.history().cachedParamValues('run_dialog/NS')
    ns_history.insert(0, '/')
    self.ns_field.addItems(ns_history)
    self.name_field = QtGui.QLineEdit(self.content)
    self.name_field.setEnabled(False)
    horizontalLayout = QtGui.QHBoxLayout()
    horizontalLayout.addWidget(self.ns_field)
    horizontalLayout.addWidget(self.name_field)
    self.contentLayout.addRow(ns_name_label, horizontalLayout)
    args_label = QtGui.QLabel("Args:", self.content)
    self.args_field = QtGui.QComboBox(self.content)
    self.args_field.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
    self.args_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed))
    self.args_field.setEditable(True)
    self.contentLayout.addRow(args_label, self.args_field)
    args_history = nm.history().cachedParamValues('run_dialog/Args')
    args_history.insert(0, '')
    self.args_field.addItems(args_history)

    host_label = QtGui.QLabel("Host:", self.content)
    self.host_field = QtGui.QComboBox(self.content)
#    self.host_field.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
    self.host_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed))
    self.host_field.setEditable(True)
    host_label.setBuddy(self.host_field)
    self.contentLayout.addRow(host_label, self.host_field)
    self.host_history = host_history = nm.history().cachedParamValues('/Host')
    if self.host in host_history:
      host_history.remove(self.host)
    host_history.insert(0, self.host)
    self.host_field.addItems(host_history)

    master_label = QtGui.QLabel("ROS Master URI:", self.content)
    self.master_field = QtGui.QComboBox(self.content)
    self.master_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed))
    self.master_field.setEditable(True)
    master_label.setBuddy(self.host_field)
    self.contentLayout.addRow(master_label, self.master_field)
    self.master_history = master_history = nm.history().cachedParamValues('/Optional Parameter/ROS Master URI')
    self.masteruri = "ROS_MASTER_URI" if masteruri is None else masteruri
    if self.masteruri in master_history:
      master_history.remove(self.masteruri)
    master_history.insert(0, self.masteruri)
    self.master_field.addItems(master_history)

#    self.package_field.setFocus(QtCore.Qt.TabFocusReason)
    self.package_field.textChanged.connect(self.on_package_selected)
    self.binary_field.activated[str].connect(self.on_binary_selected)
示例#6
0
 def __init__(self,
              topic_name,
              attributes,
              array_index,
              publisher,
              parent,
              label_text=None):
     super(ValueWidget, self).__init__(topic_name, publisher, parent=parent)
     self._parent = parent
     self._attributes = attributes
     self._array_index = array_index
     self._text = ez_model.make_text(topic_name, attributes, array_index)
     self._horizontal_layout = QtGui.QHBoxLayout()
     if label_text is None:
         self._topic_label = QtGui.QLabel(self._text)
     else:
         self._topic_label = QtGui.QLabel(label_text)
     self.close_button = QtGui.QPushButton()
     self.close_button.setMaximumWidth(30)
     self.close_button.setIcon(self.style().standardIcon(
         QtGui.QStyle.SP_TitleBarCloseButton))
     self.up_button = QtGui.QPushButton()
     self.up_button.setIcon(self.style().standardIcon(
         QtGui.QStyle.SP_ArrowUp))
     self.up_button.setMaximumWidth(30)
     self.down_button = QtGui.QPushButton()
     self.down_button.setMaximumWidth(30)
     self.down_button.setIcon(self.style().standardIcon(
         QtGui.QStyle.SP_ArrowDown))
     repeat_label = QtGui.QLabel('repeat')
     self._repeat_box = QtGui.QCheckBox()
     self._repeat_box.stateChanged.connect(self.repeat_changed)
     self._repeat_box.setChecked(publisher.is_repeating())
     self._horizontal_layout.addWidget(self._topic_label)
     self._horizontal_layout.addWidget(self.close_button)
     self._horizontal_layout.addWidget(self.up_button)
     self._horizontal_layout.addWidget(self.down_button)
     self._horizontal_layout.addWidget(repeat_label)
     self._horizontal_layout.addWidget(self._repeat_box)
     if self._array_index is not None:
         self.add_button = QtGui.QPushButton('+')
         self.add_button.setMaximumWidth(30)
         self._horizontal_layout.addWidget(self.add_button)
     else:
         self.add_button = None
     self.close_button.clicked.connect(
         lambda x: self._parent.close_slider(self))
     self.up_button.clicked.connect(
         lambda x: self._parent.move_up_widget(self))
     self.down_button.clicked.connect(
         lambda x: self._parent.move_down_widget(self))
     self.setup_ui(self._text)
示例#7
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        ## rviz.VisualizationFrame is the main container widget of the
        ## regular RViz application. In this example, we disable everything
        ## so that the only thing visible is the 3D render window.
        self.frame = rviz.VisualizationFrame()
        self.frame.setSplashPath("")
        self.frame.initialize()

        # Read the configuration from the config file for visualization.
        reader = rviz.YamlConfigReader()
        config = rviz.Config()

        reader.readFile(config, os.path.join(path, 'config', 'workcell.rviz'))
        self.frame.load(config)

        self.setWindowTitle(config.mapGetChild("Title").getValue())

        self.frame.setMenuBar(None)
        self.frame.setHideButtonVisibility(False)

        self.manager = self.frame.getManager()
        self.grid_display = self.manager.getRootDisplayGroup().getDisplayAt(0)

        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(9, 0, 9, 0)
        self.setLayout(layout)

        h_layout = QtGui.QHBoxLayout()
        layout.addLayout(h_layout)

        orbit_button = QtGui.QPushButton("Orbit View")
        orbit_button.clicked.connect(self.onOrbitButtonClick)
        h_layout.addWidget(orbit_button)

        front_button = QtGui.QPushButton("Front View")
        front_button.clicked.connect(self.onFrontButtonClick)
        h_layout.addWidget(front_button)

        right_button = QtGui.QPushButton("Rigth View")
        right_button.clicked.connect(self.onRightButtonClick)
        h_layout.addWidget(right_button)

        top_button = QtGui.QPushButton("Top View")
        top_button.clicked.connect(self.onTopButtonClick)
        h_layout.addWidget(top_button)

        layout.addWidget(self.frame)
示例#8
0
 def __init__(self, path, parent=None):
     QtGui.QWidget.__init__(self, parent)
     self.path = path
     self._layout = QtGui.QHBoxLayout(self)
     self._layout.setContentsMargins(0, 0, 0, 0)
     self._layout.setSpacing(0)
     self._button = QtGui.QPushButton('...')
     self._button.setMaximumSize(QtCore.QSize(24, 20))
     self._button.clicked.connect(self._on_path_select_clicked)
     self._layout.addWidget(self._button)
     self._lineedit = QtGui.QLineEdit(path)
     self._lineedit.returnPressed.connect(self._on_editing_finished)
     self._layout.addWidget(self._lineedit)
     self.setLayout(self._layout)
     self.setFocusProxy(self._button)
     self.setAutoFillBackground(True)
示例#9
0
    def create_controls(self):
        """
        Create UI controls.
        """
        vbox = QtGui.QVBoxLayout()

        form = QtGui.QFormLayout()
        self.num_sigma = QtGui.QDoubleSpinBox()
        self.num_sigma.setValue(1.0)
        self.num_sigma.setMinimum(0.0)
        self.num_sigma.setSingleStep(0.1)
        self.num_sigma.setMaximum(1e3)
        self.num_sigma.setDecimals(2)
        form.addRow(tr("Sigma:"), self.num_sigma)
        vbox.addLayout(form)

        self.chk_preview = QtGui.QCheckBox(tr("Preview"))
        self.chk_preview.setCheckable(True)
        self.chk_preview.setChecked(False)
        vbox.addWidget(self.chk_preview)

        self.chk_preview.toggled[bool].connect(self.set_preview)

        self.gbo_output = QtGui.QGroupBox(tr("Output"))
        self.opt_new = QtGui.QRadioButton(tr("New signal"))
        self.opt_replace = QtGui.QRadioButton(tr("In place"))
        self.opt_new.setChecked(True)
        gbo_vbox2 = QtGui.QVBoxLayout()
        gbo_vbox2.addWidget(self.opt_new)
        gbo_vbox2.addWidget(self.opt_replace)
        self.gbo_output.setLayout(gbo_vbox2)
        vbox.addWidget(self.gbo_output)

        self.btn_ok = QtGui.QPushButton(tr("&OK"))
        self.btn_ok.setDefault(True)
        self.btn_ok.clicked.connect(self.accept)
        self.btn_cancel = QtGui.QPushButton(tr("&Cancel"))
        self.btn_cancel.clicked.connect(self.reject)
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(self.btn_ok)
        hbox.addWidget(self.btn_cancel)
        vbox.addLayout(hbox)

        vbox.addStretch(1)
        self.setLayout(vbox)
示例#10
0
文件: robviz.py 项目: lan-n/proper
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.frame = rviz.VisualizationFrame()
        self.frame.setSplashPath("")
        self.frame.initialize()

        reader = rviz.YamlConfigReader()
        config = rviz.Config()

        reader.readFile(config, os.path.join(path, 'config', 'workcell.rviz'))
        self.frame.load(config)

        self.setWindowTitle(config.mapGetChild("Title").getValue())

        self.frame.setMenuBar(None)
        self.frame.setHideButtonVisibility(False)

        self.manager = self.frame.getManager()
        self.grid_display = self.manager.getRootDisplayGroup().getDisplayAt(0)

        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(9, 0, 9, 0)
        self.setLayout(layout)

        h_layout = QtGui.QHBoxLayout()
        layout.addLayout(h_layout)

        orbit_button = QtGui.QPushButton("Orbit View")
        orbit_button.clicked.connect(self.onOrbitButtonClick)
        h_layout.addWidget(orbit_button)

        front_button = QtGui.QPushButton("Front View")
        front_button.clicked.connect(self.onFrontButtonClick)
        h_layout.addWidget(front_button)

        right_button = QtGui.QPushButton("Rigth View")
        right_button.clicked.connect(self.onRightButtonClick)
        h_layout.addWidget(right_button)

        top_button = QtGui.QPushButton("Top View")
        top_button.clicked.connect(self.onTopButtonClick)
        h_layout.addWidget(top_button)

        layout.addWidget(self.frame)
示例#11
0
    def create_controls(self):
        self.lbl_nav = QtGui.QLabel(tr("Navigate"), self)
        self.lst_nav = AxesListWidget(self)
        self.btn_up = QtGui.QToolButton(self)
        self.btn_up.setArrowType(QtCore.Qt.UpArrow)
        self.btn_down = QtGui.QToolButton(self)
        self.btn_down.setArrowType(QtCore.Qt.DownArrow)
        self.lbl_sig = QtGui.QLabel(tr("Signal"), self)
        self.lst_sig = AxesListWidget(self)

        sp = self.lst_sig.sizePolicy()
        sp.setVerticalPolicy(QtGui.QSizePolicy.Fixed)
        self.lst_sig.setSizePolicy(sp)
        sp = self.lst_nav.sizePolicy()
        sp.setVerticalPolicy(QtGui.QSizePolicy.Fixed)
        self.lst_nav.setSizePolicy(sp)

        self.btn_down.clicked.connect(self._move_down)
        self.btn_up.clicked.connect(self._move_up)
        self.lst_nav.inserted.connect(self._list_insert)
        self.lst_sig.inserted.connect(self._list_insert)
        self.lst_nav.moved.connect(self._list_move)
        self.lst_sig.moved.connect(self._list_move)

        self.btn_flip = QtGui.QPushButton(tr("Reverse axes"))
        self.btn_flip.clicked.connect(self._flip_clicked)

        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.lbl_nav)
        vbox.addWidget(self.lst_nav)
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(self.btn_up)
        hbox.addWidget(self.btn_down)
        vbox.addLayout(hbox)
        vbox.addWidget(self.lbl_sig)
        vbox.addWidget(self.lst_sig)
        vbox.addWidget(self.btn_flip)

        w = QtGui.QWidget()
        w.setLayout(vbox)
        self.setWidget(w)
示例#12
0
 def __init__(self):
     super(ImageView2Widget, self).__init__()
     self.left_button_clicked = False
     self.lock = Lock()
     self.event_pub = rospy.Publisher("event", MouseEvent)
     self.bridge = CvBridge()
     self.label = ScaledLabel()
     self.label.setAlignment(Qt.AlignCenter)
     self.label.setSizePolicy(
         QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored))
     #self.label.installEventFilter(self)
     hbox = QtGui.QHBoxLayout(self)
     hbox.addWidget(self.label)
     self.setLayout(hbox)
     self.image_sub = rospy.Subscriber("image_marked", Image,
                                       self.imageCallback)
     self._update_plot_timer = QTimer(self)
     self._update_plot_timer.timeout.connect(self.redraw)
     self._update_plot_timer.start(40)
     self.setMouseTracking(True)
     self.show()
示例#13
0
  def __init__(self, name, param_type, collapsible=True, parent=None):
    QtGui.QWidget.__init__(self, parent)
    self.setObjectName(name)
    self.name = name
    self.type = param_type
    self.params = []
    self.collapsed = False
    self.parameter_description = None
    vLayout = QtGui.QVBoxLayout()
    vLayout.setSpacing(0)
    self.options_layout = QtGui.QHBoxLayout()
    self.param_widget = QtGui.QFrame()
    self.name_label = QtGui.QLabel(name)
    font = self.name_label.font()
    font.setBold(True)
    self.name_label.setFont(font)
    self.type_label = QtGui.QLabel(''.join([' (', param_type, ')']))

    if collapsible:
      self.hide_button = QtGui.QPushButton('-')
      self.hide_button.setFlat(True)
      self.hide_button.setMaximumSize(20,20)
      self.hide_button.clicked.connect(self._on_hide_clicked)
      self.options_layout.addWidget(self.hide_button)
      self.options_layout.addWidget(self.name_label)
      self.options_layout.addWidget(self.type_label)
      self.options_layout.addStretch()

      vLayout.addLayout(self.options_layout)

      self.param_widget.setFrameShape(QtGui.QFrame.Box)
      self.param_widget.setFrameShadow(QtGui.QFrame.Raised)

    boxLayout = QtGui.QFormLayout()
    boxLayout.setVerticalSpacing(0)
    self.param_widget.setLayout(boxLayout)
    vLayout.addWidget(self.param_widget)
    self.setLayout(vLayout)
    if param_type in ['std_msgs/Header']:
      self.setCollapsed(True)
示例#14
0
    def __createDistanceSlider(self, label, distance, callback):
        """Create a slider widget to control the distance from the
        selected node.

        * label -- the label for the slider
        * distance -- the default distance value
        * callback -- the function to call when the slider is changed

        """
        frame = QtGui.QFrame()
        layout = QtGui.QHBoxLayout()
        frame.setLayout(layout)

        # Create a main label for the slider
        label = QtGui.QLabel("%s:" % label)
        layout.addWidget(label)

        # Create the slider
        slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        slider.setMinimum(0)
        slider.setMaximum(self.__maxDistance)
        slider.setValue(distance)
        slider.setTickPosition(QtGui.QSlider.TicksBelow)
        slider.setTickInterval(1)  # Every 1 level
        slider.valueChanged.connect(callback)
        layout.addWidget(slider)

        # Create a label to display the value
        label = QtGui.QLabel("%s" % distance)
        layout.addWidget(label)

        # Add a button to reset the slider to its original value
        resetButton = QtGui.QPushButton("Reset")
        resetButton.clicked.connect(self.__getClickWrapper(slider, distance))
        layout.addWidget(resetButton)

        self.__layout.addWidget(frame)

        return slider, label
示例#15
0
    def setupUi(self, Dialog):
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.resize(328, 449)
        self.verticalLayout = QtGui.QVBoxLayout(Dialog)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(-1, 0, -1, -1)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.label = QtGui.QLabel(Dialog)
        self.label.setLineWidth(0)
        self.label.setObjectName(_fromUtf8("label"))
        self.horizontalLayout.addWidget(self.label)
        self.cb_guitype = QtGui.QComboBox(Dialog)
        self.cb_guitype.setObjectName(_fromUtf8("cb_guitype"))
        self.horizontalLayout.addWidget(self.cb_guitype)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.treeView = QtGui.QTreeView(Dialog)
        self.treeView.setObjectName(_fromUtf8("treeView"))
        self.verticalLayout.addWidget(self.treeView)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
 def setup_ui(self):
     horizontal_layout = QtGui.QHBoxLayout()
     reload_button = QtGui.QPushButton(parent=self)
     reload_button.setMaximumWidth(30)
     reload_button.setIcon(self.style().standardIcon(
         QtGui.QStyle.SP_BrowserReload))
     reload_button.clicked.connect(self.update_combo_items)
     topic_label = QtGui.QLabel('topic(+data member) name')
     clear_button = QtGui.QPushButton('all clear')
     clear_button.setMaximumWidth(200)
     clear_button.clicked.connect(self.clear_sliders)
     self._combo = QtGui.QComboBox()
     self._combo.setEditable(True)
     self.update_combo_items()
     self._combo.activated.connect(self.add_slider_from_combo)
     horizontal_layout.addWidget(reload_button)
     horizontal_layout.addWidget(topic_label)
     horizontal_layout.addWidget(self._combo)
     horizontal_layout.addWidget(clear_button)
     self._main_vertical_layout = QtGui.QVBoxLayout()
     self._main_vertical_layout.addLayout(horizontal_layout)
     self._main_vertical_layout.setAlignment(horizontal_layout,
                                             QtCore.Qt.AlignTop)
     self.setLayout(self._main_vertical_layout)
示例#17
0
    def __init__(self,
                 topic,
                 msg_type,
                 show_only_rate=False,
                 masteruri=None,
                 use_ssh=False,
                 parent=None):
        '''
    Creates an input dialog.
    @param topic: the name of the topic
    @type topic: C{str}
    @param msg_type: the type of the topic
    @type msg_type: C{str}
    @raise Exception: if no topic class was found for the given type
    '''
        QtGui.QDialog.__init__(self, parent=parent)
        self._masteruri = masteruri
        masteruri_str = '' if masteruri is None else '[%s]' % masteruri
        self.setObjectName(' - '.join(['EchoDialog', topic, masteruri_str]))
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
        self.setWindowFlags(QtCore.Qt.Window)
        self.setWindowTitle('%s %s %s' %
                            ('Echo --- ' if not show_only_rate else 'Hz --- ',
                             topic, masteruri_str))
        self.resize(728, 512)
        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.verticalLayout.setContentsMargins(1, 1, 1, 1)
        self.mIcon = QtGui.QIcon(":/icons/crystal_clear_prop_run_echo.png")
        self.setWindowIcon(self.mIcon)

        self.topic = topic
        self.show_only_rate = show_only_rate
        self.lock = threading.RLock()
        self.last_printed_count = 0
        self.msg_t0 = -1.
        self.msg_tn = 0
        self.times = []

        self.message_count = 0
        self._rate_message = ''
        self._scrapped_msgs = 0
        self._scrapped_msgs_sl = 0

        self._last_received_ts = 0
        self.receiving_hz = self.MESSAGE_HZ_LIMIT
        self.line_limit = self.MESSAGE_LINE_LIMIT

        self.field_filter_fn = None

        options = QtGui.QWidget(self)
        if not show_only_rate:
            hLayout = QtGui.QHBoxLayout(options)
            hLayout.setContentsMargins(1, 1, 1, 1)
            self.no_str_checkbox = no_str_checkbox = QtGui.QCheckBox(
                'Hide strings')
            no_str_checkbox.toggled.connect(self.on_no_str_checkbox_toggled)
            hLayout.addWidget(no_str_checkbox)
            self.no_arr_checkbox = no_arr_checkbox = QtGui.QCheckBox(
                'Hide arrays')
            no_arr_checkbox.toggled.connect(self.on_no_arr_checkbox_toggled)
            hLayout.addWidget(no_arr_checkbox)
            self.combobox_reduce_ch = QtGui.QComboBox(self)
            self.combobox_reduce_ch.addItems(
                [str(self.MESSAGE_LINE_LIMIT), '0', '80', '256', '1024'])
            self.combobox_reduce_ch.activated[str].connect(
                self.combobox_reduce_ch_activated)
            self.combobox_reduce_ch.setEditable(True)
            self.combobox_reduce_ch.setToolTip(
                "Set maximum line width. 0 disables the limit.")
            hLayout.addWidget(self.combobox_reduce_ch)
            #      reduce_ch_label = QtGui.QLabel('ch', self)
            #      hLayout.addWidget(reduce_ch_label)
            # add spacer
            spacerItem = QtGui.QSpacerItem(515, 20,
                                           QtGui.QSizePolicy.Expanding,
                                           QtGui.QSizePolicy.Minimum)
            hLayout.addItem(spacerItem)
            # add combobox for displaying frequency of messages
            self.combobox_displ_hz = QtGui.QComboBox(self)
            self.combobox_displ_hz.addItems([
                str(self.MESSAGE_HZ_LIMIT), '0', '0.1', '1', '50', '100',
                '1000'
            ])
            self.combobox_displ_hz.activated[str].connect(
                self.on_combobox_hz_activated)
            self.combobox_displ_hz.setEditable(True)
            hLayout.addWidget(self.combobox_displ_hz)
            displ_hz_label = QtGui.QLabel('Hz', self)
            hLayout.addWidget(displ_hz_label)
            # add combobox for count of displayed messages
            self.combobox_msgs_count = QtGui.QComboBox(self)
            self.combobox_msgs_count.addItems(
                [str(self.MAX_DISPLAY_MSGS), '0', '50', '100'])
            self.combobox_msgs_count.activated[str].connect(
                self.on_combobox_count_activated)
            self.combobox_msgs_count.setEditable(True)
            self.combobox_msgs_count.setToolTip(
                "Set maximum displayed message count. 0 disables the limit.")
            hLayout.addWidget(self.combobox_msgs_count)
            displ_count_label = QtGui.QLabel('#', self)
            hLayout.addWidget(displ_count_label)
            # add topic control button for unsubscribe and subscribe
            self.topic_control_button = QtGui.QToolButton(self)
            self.topic_control_button.setText('stop')
            self.topic_control_button.setIcon(
                QtGui.QIcon(':/icons/deleket_deviantart_stop.png'))
            self.topic_control_button.clicked.connect(
                self.on_topic_control_btn_clicked)
            hLayout.addWidget(self.topic_control_button)
            # add clear button
            clearButton = QtGui.QToolButton(self)
            clearButton.setText('clear')
            clearButton.clicked.connect(self.on_clear_btn_clicked)
            hLayout.addWidget(clearButton)
            self.verticalLayout.addWidget(options)

        self.display = QtGui.QTextBrowser(self)
        self.display.setReadOnly(True)
        self.verticalLayout.addWidget(self.display)
        self.display.document().setMaximumBlockCount(500)
        self.max_displayed_msgs = self.MAX_DISPLAY_MSGS
        self._blocks_in_msg = None
        self.display.setOpenLinks(False)
        self.display.anchorClicked.connect(self._on_display_anchorClicked)

        self.status_label = QtGui.QLabel('0 messages', self)
        self.verticalLayout.addWidget(self.status_label)

        # subscribe to the topic
        errmsg = ''
        try:
            self.__msg_class = message.get_message_class(msg_type)
            if not self.__msg_class:
                errmsg = "Cannot load message class for [%s]. Did you build messages?" % msg_type
#        raise Exception("Cannot load message class for [%s]. Did you build messages?"%msg_type)
        except Exception as e:
            self.__msg_class = None
            errmsg = "Cannot load message class for [%s]. Did you build messagest?\nError: %s" % (
                msg_type, e)
#      raise Exception("Cannot load message class for [%s]. Did you build messagest?\nError: %s"%(msg_type, e))
# variables for Subscriber
        self.msg_signal.connect(self._append_message)
        self.sub = None

        # vairables for SSH connection
        self.ssh_output_file = None
        self.ssh_error_file = None
        self.ssh_input_file = None
        self.text_signal.connect(self._append_text)
        self.text_hz_signal.connect(self._append_text_hz)
        self._current_msg = ''
        self._current_errmsg = ''
        self.text_error_signal.connect(self._append_error_text)

        # decide, which connection to open
        if use_ssh:
            self.__msg_class = None
            self._on_display_anchorClicked(QtCore.QUrl(self._masteruri))
        elif self.__msg_class is None:
            errtxt = '<pre style="color:red; font-family:Fixedsys,Courier,monospace; padding:10px;">\n%s</pre>' % (
                errmsg)
            self.display.setText('<a href="%s">open using SSH</a>' %
                                 (masteruri))
            self.display.append(errtxt)
        else:
            self.sub = rospy.Subscriber(self.topic, self.__msg_class,
                                        self._msg_handle)

        self.print_hz_timer = QtCore.QTimer()
        self.print_hz_timer.timeout.connect(self._on_calc_hz)
        self.print_hz_timer.start(1000)
示例#18
0
    def __init__(self,
                 items=list(),
                 buttons=QtGui.QDialogButtonBox.Cancel
                 | QtGui.QDialogButtonBox.Ok,
                 exclusive=False,
                 preselect_all=False,
                 title='',
                 description='',
                 icon='',
                 parent=None,
                 select_if_single=True):
        '''
    Creates an input dialog.
    @param items: a list with strings
    @type items: C{list()}
    '''
        QtGui.QDialog.__init__(self, parent=parent)
        self.setObjectName(' - '.join(['SelectDialog', str(items)]))

        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.verticalLayout.setContentsMargins(1, 1, 1, 1)

        # add filter row
        self.filter_frame = QtGui.QFrame(self)
        filterLayout = QtGui.QHBoxLayout(self.filter_frame)
        filterLayout.setContentsMargins(1, 1, 1, 1)
        label = QtGui.QLabel("Filter:", self.filter_frame)
        self.filter_field = QtGui.QLineEdit(self.filter_frame)
        filterLayout.addWidget(label)
        filterLayout.addWidget(self.filter_field)
        self.filter_field.textChanged.connect(self._on_filter_changed)
        self.verticalLayout.addWidget(self.filter_frame)

        if description:
            self.description_frame = QtGui.QFrame(self)
            descriptionLayout = QtGui.QHBoxLayout(self.description_frame)
            #      descriptionLayout.setContentsMargins(1, 1, 1, 1)
            if icon:
                self.icon_label = QtGui.QLabel(self.description_frame)
                self.icon_label.setSizePolicy(QtGui.QSizePolicy.Fixed,
                                              QtGui.QSizePolicy.Fixed)
                self.icon_label.setPixmap(
                    QtGui.QPixmap(icon).scaled(30, 30,
                                               QtCore.Qt.KeepAspectRatio))
                descriptionLayout.addWidget(self.icon_label)
            self.description_label = QtGui.QLabel(self.description_frame)
            self.description_label.setWordWrap(True)
            self.description_label.setText(description)
            descriptionLayout.addWidget(self.description_label)
            self.verticalLayout.addWidget(self.description_frame)

        # create area for the parameter
        self.scrollArea = scrollArea = QtGui.QScrollArea(self)
        self.scrollArea.setFocusPolicy(QtCore.Qt.NoFocus)
        scrollArea.setObjectName("scrollArea")
        scrollArea.setWidgetResizable(True)
        self.content = MainBox(self)
        scrollArea.setWidget(self.content)
        self.verticalLayout.addWidget(scrollArea)

        # add select all option
        if not exclusive:
            self._ignore_next_toggle = False
            options = QtGui.QWidget(self)
            hLayout = QtGui.QHBoxLayout(options)
            hLayout.setContentsMargins(1, 1, 1, 1)
            self.select_all_checkbox = QtGui.QCheckBox('all')
            self.select_all_checkbox.setTristate(True)
            self.select_all_checkbox.stateChanged.connect(
                self._on_select_all_checkbox_stateChanged)
            hLayout.addWidget(self.select_all_checkbox)
            self.content.toggled.connect(self._on_main_toggle)
            # add spacer
            spacerItem = QtGui.QSpacerItem(515, 20,
                                           QtGui.QSizePolicy.Expanding,
                                           QtGui.QSizePolicy.Minimum)
            hLayout.addItem(spacerItem)
            self.verticalLayout.addWidget(options)

        # create buttons
        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setObjectName("buttonBox")
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(buttons)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.verticalLayout.addWidget(self.buttonBox)

        # set the input fields
        if items:
            self.content.createFieldsFromValues(items, exclusive)
            if (select_if_single and len(items) == 1) or preselect_all:
                self.select_all_checkbox.setCheckState(QtCore.Qt.Checked)

        if not items or len(items) < 11:
            self.filter_frame.setVisible(False)
示例#19
0
  def __init__(self, params=dict(), buttons=QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok, sidebar_var='', parent=None):
    '''
    Creates an input dialog.
    @param params: a dictionary with parameter names and (type, values). 
    The C{value}, can be a primitive value, a list with values or parameter 
    dictionary to create groups. In this case the type is the name of the group.
    @type params: C{dict(str:(str, {value, [..], dict()}))}
    '''
    QtGui.QDialog.__init__(self, parent=parent)
    self.setObjectName('ParameterDialog - %s'%str(params))

    self.__current_path = nm.settings().current_dialog_path
    self.horizontalLayout = QtGui.QHBoxLayout(self)
    self.horizontalLayout.setObjectName("horizontalLayout")
    self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
    self.verticalLayout = QtGui.QVBoxLayout()
    self.verticalLayout.setObjectName("verticalLayout")
    self.verticalLayout.setContentsMargins(1, 1, 1, 1)
    # add filter row
    self.filter_frame = QtGui.QFrame(self)
    filterLayout = QtGui.QHBoxLayout(self.filter_frame)
    filterLayout.setContentsMargins(1, 1, 1, 1)
    label = QtGui.QLabel("Filter:", self.filter_frame)
    self.filter_field = QtGui.QLineEdit(self.filter_frame)
    filterLayout.addWidget(label)
    filterLayout.addWidget(self.filter_field)
    self.filter_field.textChanged.connect(self._on_filter_changed)
    self.filter_visible = True

    self.verticalLayout.addWidget(self.filter_frame)

    # create area for the parameter
    self.scrollArea = scrollArea = ScrollArea(self);
    scrollArea.setObjectName("scrollArea")
    scrollArea.setWidgetResizable(True)
    self.content = MainBox('/', 'str', False, self)
    scrollArea.setWidget(self.content)
    self.verticalLayout.addWidget(scrollArea)

    # add info text field
    self.info_field = QtGui.QTextEdit(self)
    self.info_field.setVisible(False)
    palette = QtGui.QPalette()
    brush = QtGui.QBrush(QtGui.QColor(255, 254, 242))
    brush.setStyle(QtCore.Qt.SolidPattern)
    palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
    brush = QtGui.QBrush(QtGui.QColor(255, 254, 242))
    brush.setStyle(QtCore.Qt.SolidPattern)
    palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
    brush = QtGui.QBrush(QtGui.QColor(244, 244, 244))
    brush.setStyle(QtCore.Qt.SolidPattern)
    palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
    self.info_field.setPalette(palette)
    self.info_field.setFrameShadow(QtGui.QFrame.Plain)
    self.info_field.setReadOnly(True)
    self.info_field.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
    self.info_field.setObjectName("dialog_info_field")
    self.verticalLayout.addWidget(self.info_field)

    # create buttons
    self.buttonBox = QtGui.QDialogButtonBox(self)
    self.buttonBox.setObjectName("buttonBox")
    self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
    self.buttonBox.setStandardButtons(buttons)
    self.buttonBox.accepted.connect(self.accept)
    self.buttonBox.rejected.connect(self.reject)
    self.verticalLayout.addWidget(self.buttonBox)
    self.horizontalLayout.addLayout(self.verticalLayout)

    # add side bar for checklist
    values = nm.history().cachedParamValues('/%s'%sidebar_var)
    self.sidebar_frame = QtGui.QFrame()
    self.sidebar_frame.setObjectName(sidebar_var)
    sidebarframe_verticalLayout = QtGui.QVBoxLayout(self.sidebar_frame)
    sidebarframe_verticalLayout.setObjectName("sidebarframe_verticalLayout")
    sidebarframe_verticalLayout.setContentsMargins(1, 1, 1, 1)
    self._sidebar_selected = 0
    if len(values) > 1 and sidebar_var in params:
      self.horizontalLayout.addWidget(self.sidebar_frame)
      try:
        self.sidebar_default_val = params[sidebar_var][1]
      except:
        self.sidebar_default_val = ''
      values.sort()
      for v in values:
        checkbox = QtGui.QCheckBox(v)
        checkbox.stateChanged.connect(self._on_sidebar_stateChanged)
        self.sidebar_frame.layout().addWidget(checkbox)
      self.sidebar_frame.layout().addItem(QtGui.QSpacerItem(100, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding))
    # set the input fields
    if params:
      self.content.createFieldFromValue(params)
      self.setInfoActive(False)

    if self.filter_frame.isVisible():
      self.filter_field.setFocus()
    self.setMinimumSize(350,200)
示例#20
0
    def __init__(self, grammar_filename=None):
        """ Constructor """
        super(ContinueGui, self).__init__()

        self.resize(640, 480)
        self.move(300, 300)
        self.setWindowTitle('Continue GUI')

        # Add the description box
        self.description_label = QtGui.QLabel(self)
        self.description_label.setMaximumHeight(100)

        # Add the question box
        self.spec_label = QtGui.QLabel(self)
        self.spec_label.setMaximumHeight(100)

        # Add the key box
        self.key_label = QtGui.QLabel(self)
        self.key_label.setMaximumHeight(100)

        # Add the texteditbox
        self.textbox = QtGui.QTextEdit(self)
        self.textbox.textChanged.connect(self._text_changed)

        # Add the submit button
        self.submit_button = QtGui.QPushButton(self)
        self.submit_button.setText("Submit")
        self.submit_button.setEnabled(False)

        # Add the clear button
        self.clear_button = QtGui.QPushButton(self)
        self.clear_button.setText("Clear")

        # Submit/clear button layout
        self.submit_clear_button_layout = QtGui.QVBoxLayout()
        self.submit_clear_button_layout.addWidget(self.submit_button)
        self.submit_clear_button_layout.addWidget(self.clear_button)
        self.submit_clear_button_widget = QtGui.QWidget()
        self.submit_clear_button_widget.setLayout(self.submit_clear_button_layout)

        # Add the QButtonGroup
        # self.option_buttons = QtGui.QButtonGroup(self) (ToDo: how can I do this nicely???)
        # self.button_layout = QtGui.QVBoxLayout()
        self.button_layout = QtGui.QGridLayout()
        self.button_widget = QtGui.QWidget()
        self.button_widget.setLayout(self.button_layout)
        self.button_widget.setSizePolicy(2, 2)  # Makes sure we don't get enormous buttons

        # Top layout
        self._top_layout = QtGui.QHBoxLayout(self)
        self._top_layout.addWidget(self.textbox)
        self._top_layout.addWidget(self.submit_clear_button_widget)
        self._top_widget = QtGui.QWidget()
        self._top_widget.setLayout(self._top_layout)
        self._top_widget.setMaximumHeight(100)

        # Main layout
        self._main_layout = QtGui.QVBoxLayout(self)
        self._main_layout.addWidget(self.description_label)
        self._main_layout.addWidget(self.spec_label)
        self._main_layout.addWidget(self.key_label)
        self._main_layout.addWidget(self._top_widget)
        # self._main_layout.addWidget(self.option_buttons)
        self._main_layout.addWidget(self.button_widget)
        self._main_layout.insertStretch(-1, 0)

        # List with ButtonCBs
        self._button_cbs = []

        # Setup the interface
        self.server_interface = HMIServerGUIInterface('continui', grammar_filename)

        # Update thread
        self.update_thread = UpdateThread(self, self.server_interface)
        self.update_thread.buttons.connect(self.buttons_callback)
        self.update_thread.description.connect(self.description_callback)
        self.update_thread.spec.connect(self.spec_callback)
        self.update_thread.key.connect(self.key_callback)
        self.update_thread.valid.connect(self.valid_callback)
        self.current_text.connect(self.update_thread.set_text)
        self.submit_button.clicked.connect(self.update_thread.submit)
        self.submit_button.clicked.connect(self.clear_text)
        self.clear_button.clicked.connect(self.clear_text)
        self.update_thread.start()

        self.show()
    def __init__(self, context):
        self.prompt_width = 170
        self.input_width = 250

        super(SimpleGUI, self).__init__(context)
        self.setObjectName('SimpleGUI')
        self._widget = QWidget()

        self._sound_client = SoundClient()

        #find relative path for files to load
        self.local_dir = os.path.dirname(__file__)
        self.dir = os.path.join(self.local_dir, './lib/rqt_simplegui/')
        if not os.path.isdir(self.dir):
            os.makedirs(self.dir)

        #need to add any additional subfolders as needed
        if not os.path.isdir(self.dir + 'animations/'):
            os.makedirs(self.dir + 'animations/')

        # Creates a subscriber to the ROS topic, having msg type SoundRequest
        rospy.Subscriber('robotsound', SoundRequest, self.sound_cb)

        QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
        self.sound_sig.connect(self.sound_sig_cb)

        # Code used for saving/ loading arm poses for the robot
        switch_srv_name = 'pr2_controller_manager/switch_controller'
        rospy.loginfo('Waiting for switch controller service...')
        rospy.wait_for_service(switch_srv_name)
        self.switch_service_client = rospy.ServiceProxy(
            switch_srv_name, SwitchController)

        self.r_joint_names = [
            'r_shoulder_pan_joint', 'r_shoulder_lift_joint',
            'r_upper_arm_roll_joint', 'r_elbow_flex_joint',
            'r_forearm_roll_joint', 'r_wrist_flex_joint', 'r_wrist_roll_joint'
        ]

        self.l_joint_names = [
            'l_shoulder_pan_joint', 'l_shoulder_lift_joint',
            'l_upper_arm_roll_joint', 'l_elbow_flex_joint',
            'l_forearm_roll_joint', 'l_wrist_flex_joint', 'l_wrist_roll_joint'
        ]

        self.all_joint_names = []
        self.all_joint_poses = []

        # Hash tables storing the name of the pose and the
        # associated positions for that pose, initially empty
        self.saved_l_poses = {}
        self.saved_r_poses = {}

        # Hash tables for storing name of animations and the associated pose list
        self.saved_animations = {}

        self.lock = threading.Lock()
        rospy.Subscriber('joint_states', JointState, self.joint_states_cb)

        #parsing for animations
        dir = os.path.dirname(__file__)
        qWarning(dir)
        filename = os.path.join(self.dir, 'animations/')

        ani_path = filename
        ani_listing = os.listdir(ani_path)
        for infile in ani_listing:
            pose_left = []
            pose_right = []
            left_gripper_states = []
            right_gripper_states = []
            line_num = 1
            for line in fileinput.input(ani_path + infile):
                if (line_num % 2 == 1):
                    pose = [float(x) for x in line.split()]
                    pose_left.append(pose[:len(pose) / 2])
                    pose_right.append(pose[len(pose) / 2:])
                else:
                    states = line.split()
                    left_gripper_states.append(states[0])
                    right_gripper_states.append(states[1])
                line_num += 1
            self.saved_animations[os.path.splitext(infile)[0]] = Quad(
                pose_left, pose_right, left_gripper_states,
                right_gripper_states)

        # Create a trajectory action client
        r_traj_controller_name = '/r_arm_controller/joint_trajectory_action'
        self.r_traj_action_client = SimpleActionClient(r_traj_controller_name,
                                                       JointTrajectoryAction)
        rospy.loginfo(
            'Waiting for a response from the trajectory action server for RIGHT arm...'
        )
        self.r_traj_action_client.wait_for_server()

        l_traj_controller_name = '/l_arm_controller/joint_trajectory_action'
        self.l_traj_action_client = SimpleActionClient(l_traj_controller_name,
                                                       JointTrajectoryAction)
        rospy.loginfo(
            'Waiting for a response from the trajectory action server for LEFT arm...'
        )
        self.l_traj_action_client.wait_for_server()

        # Navigation functionality initialization
        self.roomNav = RoomNavigator()

        self._tf_listener = TransformListener()
        self.animPlay = AnimationPlayer(None, None, None, None)

        # Detection and pickup functionality
        self.pap = PickAndPlaceManager(self._tf_listener, self.roomNav,
                                       self.animPlay)

        QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
        self.joint_sig.connect(self.joint_sig_cb)

        # Create a large vertical box that is top aligned
        large_box = QtGui.QVBoxLayout()
        large_box.setAlignment(QtCore.Qt.AlignTop)
        large_box.setMargin(0)
        large_box.addItem(QtGui.QSpacerItem(10, 0))

        # Buttons for controlling the head of the robot
        head_box = QtGui.QHBoxLayout()
        head_box.addItem(QtGui.QSpacerItem(230, 0))
        head_box.addWidget(self.create_pressed_button('Head Up'))
        head_box.addStretch(1)
        large_box.addLayout(head_box)

        button_box = QtGui.QHBoxLayout()
        button_box.addItem(QtGui.QSpacerItem(80, 0))
        button_box.addWidget(self.create_pressed_button('Head Turn Left'))
        button_box.addWidget(self.create_pressed_button('Head Down'))
        button_box.addWidget(self.create_pressed_button('Head Turn Right'))
        button_box.addStretch(1)
        button_box.setMargin(0)
        button_box.setSpacing(0)
        large_box.addLayout(button_box)

        # Shows what the robot says
        speech_box = QtGui.QHBoxLayout()

        self.speech_label = QtGui.QLabel('Robot has not spoken yet')
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.blue)
        self.speech_label.setPalette(palette)  #
        speech_box.addItem(QtGui.QSpacerItem(100, 0))
        #speech_box.addWidget(self.speech_label) #

        large_box.addLayout(speech_box)

        # Speak button
        speak_button_box = QtGui.QHBoxLayout()
        speech_prompt = QtGui.QLabel('Enter Speech Text:')
        speech_prompt.setFixedWidth(self.prompt_width)
        speak_button_box.addWidget(speech_prompt)
        robot_says = QtGui.QLineEdit(self._widget)
        robot_says.setFixedWidth(self.input_width)
        robot_says.textChanged[str].connect(self.onChanged)  #
        speak_button_box.addWidget(robot_says)
        speak_button_box.addWidget(self.create_button('Speak'))
        speak_button_box.addStretch(1)
        large_box.addLayout(speak_button_box)

        large_box.addItem(QtGui.QSpacerItem(0, 50))

        # Buttons for arm poses
        pose_button_box1 = QtGui.QHBoxLayout()
        pose_button_box1.addItem(QtGui.QSpacerItem(150, 0))
        pose_button_box1.addWidget(self.create_button('Relax Left Arm'))
        pose_button_box1.addWidget(self.create_button('Relax Right Arm'))
        pose_button_box1.addStretch(1)
        large_box.addLayout(pose_button_box1)

        # Buttons for grippers
        gripper_button_box = QtGui.QHBoxLayout()
        gripper_button_box.addItem(QtGui.QSpacerItem(150, 0))
        gripper_button_box.addWidget(self.create_button('Open Left Gripper'))
        gripper_button_box.addWidget(self.create_button('Open Right Gripper'))
        gripper_button_box.addStretch(1)
        large_box.addLayout(gripper_button_box)

        large_box.addItem(QtGui.QSpacerItem(0, 25))

        # Buttons for animation
        animation_box = QtGui.QHBoxLayout()
        play_anim_label = QtGui.QLabel('Select Animation:')
        play_anim_label.setFixedWidth(self.prompt_width)
        animation_box.addWidget(play_anim_label)
        self.saved_animations_list = QtGui.QComboBox(self._widget)
        animation_box.addWidget(self.saved_animations_list)

        pose_time_label = QtGui.QLabel('Duration(sec):')
        pose_time_label.setFixedWidth(100)
        animation_box.addWidget(pose_time_label)
        self.pose_time = QtGui.QLineEdit(self._widget)
        self.pose_time.setFixedWidth(50)
        self.pose_time.setText('2.0')
        animation_box.addWidget(self.pose_time)

        animation_box.addWidget(self.create_button('Play Animation'))
        animation_box.addStretch(1)
        large_box.addLayout(animation_box)

        animation_box2 = QtGui.QHBoxLayout()
        animation_name_label = QtGui.QLabel('Enter Animation Name:')
        animation_name_label.setFixedWidth(self.prompt_width)
        animation_box2.addWidget(animation_name_label)
        self.animation_name = QtGui.QLineEdit(self._widget)
        self.animation_name.setFixedWidth(self.input_width)
        animation_box2.addWidget(self.animation_name)
        animation_box2.addWidget(self.create_button('Save Animation'))
        animation_box2.addStretch(1)
        large_box.addLayout(animation_box2)

        animation_box3 = QtGui.QHBoxLayout()
        pose_name_label = QtGui.QLabel('Enter Pose Name:')
        pose_name_label.setFixedWidth(self.prompt_width)
        animation_box3.addWidget(pose_name_label)
        self.pose_name_temp = QtGui.QLineEdit(self._widget)
        self.pose_name_temp.setFixedWidth(self.input_width)
        animation_box3.addWidget(self.pose_name_temp)
        animation_box3.addWidget(self.create_button('Add Current Pose'))
        animation_box3.addStretch(1)
        large_box.addLayout(animation_box3)

        # Playing around with UI stuff
        play_box = QtGui.QHBoxLayout()
        pose_sequence_label = QtGui.QLabel('Current Pose Sequence:')
        pose_sequence_label.setFixedWidth(self.prompt_width)
        pose_sequence_label.setAlignment(QtCore.Qt.AlignTop)

        self.list_widget = QListWidget()
        self.list_widget.setDragDropMode(QAbstractItemView.InternalMove)
        self.list_widget.setMaximumSize(self.input_width, 200)
        play_box.addWidget(pose_sequence_label)
        play_box.addWidget(self.list_widget)

        play_box.addStretch(1)
        large_box.addLayout(play_box)

        large_box.addItem(QtGui.QSpacerItem(0, 50))

        # Buttons for first row of base controls
        first_base_button_box = QtGui.QHBoxLayout()
        first_base_button_box.addItem(QtGui.QSpacerItem(70, 0))
        first_base_button_box.addWidget(
            self.create_pressed_button('Rotate Left'))
        first_base_button_box.addWidget(self.create_pressed_button('^'))
        first_base_button_box.addWidget(
            self.create_pressed_button('Rotate Right'))
        first_base_button_box.addStretch(1)
        large_box.addLayout(first_base_button_box)

        # Buttons for second row of base controls
        second_base_button_box = QtGui.QHBoxLayout()
        second_base_button_box.addItem(QtGui.QSpacerItem(70, 0))
        second_base_button_box.addWidget(self.create_pressed_button('<'))
        second_base_button_box.addWidget(self.create_pressed_button('v'))
        second_base_button_box.addWidget(self.create_pressed_button('>'))
        second_base_button_box.addWidget(self.create_button('Move to Bin'))
        second_base_button_box.addWidget(self.create_button('Object Detect'))
        second_base_button_box.addWidget(self.create_button('Clean Room'))
        second_base_button_box.addStretch(1)
        large_box.addLayout(second_base_button_box)

        # Animation related items to store intermediate pose co-ordinates to save
        self.animation_map = {}

        self.create_state = False

        self._widget.setObjectName('SimpleGUI')
        self._widget.setLayout(large_box)
        context.add_widget(self._widget)

        # Look straight and down when launched
        self.head_x = 1.0
        self.head_y = 0.0
        self.head_z = 0.5
        self.head_action(self.head_x, self.head_y, self.head_z)

        # Set grippers to closed on initialization
        self.left_gripper_state = ''
        self.right_gripper_state = ''
        self.gripper_action('l', 0.0)
        self.gripper_action('r', 0.0)

        # Lab 6
        self.marker_publisher = rospy.Publisher('visualization_marker', Marker)

        # Saved states for poses
        saved_pose_box = QtGui.QHBoxLayout()
        self.saved_left_poses = QtGui.QLabel('')
        self.saved_right_poses = QtGui.QLabel('')

        saved_pose_box.addWidget(self.saved_left_poses)
        saved_pose_box.addWidget(self.saved_right_poses)
        large_box.addLayout(saved_pose_box)

        # Preload the map of animations
        self.saved_animations_list.addItems(self.saved_animations.keys())

        # Move the torso all the way down
        # self.torso_down(True)

        # Autonomous navigation stuff
        '''
        self.locations = [Pose(Point(2.48293590546, 3.90075874329, 0.000), Quaternion(0.000, 0.000, -0.783917630973, 0.620864838632)),
                         Pose(Point(3.70106744766, 0.304672241211, 0.000), Quaternion(0.000, 0.000, 0.950186880196, -0.311680754463)),
                         Pose(Point(2.57326722145, 1.51304531097, 0.000), Quaternion(0.000, 0.000, 0.96127194482, -0.275601611212)),
                         Pose(Point(1.28060531616, 1.52380752563, 0.000), Quaternion(0.000, 0.000, 0.946345258806, -0.323157316388)),
                         Pose(Point(2.11048603058, 0.420155525208, 0.000), Quaternion(0.000, 0.000, 0.945222393391, -0.326427062346)),
                         Pose(Point(2.82733058929, -0.739856719971, 0.000), Quaternion(0.000, 0.000, 0.945473998362, -0.325697587373)),
                         Pose(Point(1.29184818268, -1.90485572815, 0.000), Quaternion(0.000, 0.000, 0.942275557345, -0.334838429739)),
                         Pose(Point(0.722846984863, -1.0921459198, 0.000), Quaternion(0.000, 0.000, 0.949330143731, -0.314280572424))]
        '''
        self.locations = [
            Pose(Point(2.04748392105, 2.04748010635, 0.000),
                 Quaternion(0.000, 0.000, -0.776968030817, 0.629540053601)),
            Pose(Point(2.34193611145, 1.43208932877, 0),
                 Quaternion(0, 0, -0.841674385779, 0.539985396398)),
            Pose(Point(3.43202018738, -0.258297920227, 0.000),
                 Quaternion(0.000, 0.000, 0.996656413122, -0.0817067572629)),
            Pose(Point(0.931655406952, -1.96435832977, 0.000),
                 Quaternion(0.000, 0.000, 0.691187586713, 0.722675390458)),
            Pose(Point(-0.369112968445, 0.0330476760864, 0.000),
                 Quaternion(0.000, 0.000, 0.0275340398899, 0.999620866453))
        ]

        self.index = 1

        rospy.loginfo("Completed GUI initialization")
 def setupButtons(self, yaml_file):
     """
     Parse yaml file and setup Buttons. Format of the yaml file should be:
     - name: 'button name' (required)
       image: 'path to image for icon' (optional)
       image_size: 'width and height of icon' (optional)
       service: 'service' (required)
       column: 'column index' (optional, defaults to 0)
     """
     self.buttons = []
     with open(yaml_file) as f:
         yaml_data = yaml.load(f)
         # lookup colum direction
         direction = 'vertical'
         for d in yaml_data:
             if d.has_key('direction'):
                 if d['direction'] == 'horizontal':
                     direction = 'horizontal'
                 else: # d['direction'] == 'vertical':
                     direction = 'vertical'
                 yaml_data.remove(d)
                 break
         # lookup column num
         column_indices = [d['column'] for d in yaml_data]
         max_column_index = max(*column_indices)
         if direction == 'vertical':
             self.layout = QtGui.QHBoxLayout()
             self.layout_boxes = [QtGui.QVBoxLayout()
                                  for i in range(max_column_index + 1)]
         else: # direction == 'horizontal'
             self.layout = QtGui.QVBoxLayout()
             self.layout_boxes = [QtGui.QHBoxLayout()
                                  for i in range(max_column_index + 1)]
         self.button_groups = [QtGui.QGroupBox()
                              for i in range(max_column_index + 1)]
         for button_data in yaml_data:
             # check if all the field is available
             if not button_data.has_key("name"):
                 self.showError("name field is missed in yaml")
                 raise Exception("name field is missed in yaml")
             if not button_data.has_key("service"):
                 self.showError("service field is missed in yaml")
                 raise Exception("service field is missed in yaml")
             if self.button_type == "push":
                 button = QtGui.QToolButton()
             else: # self.button_type == "Radio":
                 button = QtGui.QRadioButton()
             button.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
             if button_data.has_key("image"):
                 image_file = get_filename(button_data["image"])[len("file://"):]
                 if os.path.exists(image_file):
                     icon = QtGui.QIcon(image_file)
                     button.setIcon(icon)
                     if button_data.has_key("image_size"):
                         button.setIconSize(QSize(button_data["image_size"][0], button_data["image_size"][1]))
                     else:
                         button.setIconSize(QSize(100, 100))
             if button_data.has_key("name"):
                 name = button_data['name']
                 button.setText(name)
             button.clicked.connect(self.buttonCallback(button_data['service']))
             if self.button_type == "push":
                 button.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
             else: # self.button_type == "Radio":
                 if button_data.has_key("default_value") and button_data['default_value']:
                     button.setChecked(True)
             self.layout_boxes[button_data['column']].addWidget(button)
             self.buttons.append(button)
         for i in range(len(self.button_groups)):
             self.button_groups[i].setLayout(self.layout_boxes[i])
         for group in self.button_groups:
             self.layout.addWidget(group)
         self.setLayout(self.layout)
示例#23
0
    def __init__(self, context):
        super(HalloweenGUI, self).__init__(context)
        self.setObjectName('HalloweenGUI')
        self._widget = QWidget()
        self._widget.setFixedSize(525, 300)
        self.arm_db = ArmDB()
        self._tf_listener = TransformListener()

        # Action/service/message clients or servers

        switch_srv_name = 'pr2_controller_manager/switch_controller'
        rospy.loginfo('Waiting for switch controller service...')
        rospy.wait_for_service(switch_srv_name)
        self.switch_service_client = rospy.ServiceProxy(
            switch_srv_name, SwitchController)

        self.r_joint_names = [
            'r_shoulder_pan_joint', 'r_shoulder_lift_joint',
            'r_upper_arm_roll_joint', 'r_elbow_flex_joint',
            'r_forearm_roll_joint', 'r_wrist_flex_joint', 'r_wrist_roll_joint'
        ]
        self.l_joint_names = [
            'l_shoulder_pan_joint', 'l_shoulder_lift_joint',
            'l_upper_arm_roll_joint', 'l_elbow_flex_joint',
            'l_forearm_roll_joint', 'l_wrist_flex_joint', 'l_wrist_roll_joint'
        ]

        self.all_joint_names = []
        self.all_joint_poses = []

        self.saved_r_arm_pose = None
        self.saved_l_arm_pose = None

        self.lock = threading.Lock()
        rospy.Subscriber('joint_states', JointState, self.joint_states_cb)

        # Create a trajectory action client
        r_traj_controller_name = '/r_arm_controller/joint_trajectory_action'
        self.r_traj_action_client = SimpleActionClient(r_traj_controller_name,
                                                       JointTrajectoryAction)
        rospy.loginfo(
            'Waiting for a response from the trajectory action server for RIGHT arm...'
        )
        self.r_traj_action_client.wait_for_server()

        l_traj_controller_name = '/l_arm_controller/joint_trajectory_action'
        self.l_traj_action_client = SimpleActionClient(l_traj_controller_name,
                                                       JointTrajectoryAction)
        rospy.loginfo(
            'Waiting for a response from the trajectory action server for LEFT arm...'
        )
        self.l_traj_action_client.wait_for_server()

        QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
        self.joint_sig.connect(self.joint_sig_cb)

        large_box = QtGui.QVBoxLayout()

        arm_box = QtGui.QHBoxLayout()
        right_arm_box = QtGui.QVBoxLayout()
        left_arm_box = QtGui.QVBoxLayout()

        left_arm_box.addItem(QtGui.QSpacerItem(50, 50))
        right_arm_box.addItem(QtGui.QSpacerItem(50, 50))
        right_arm_box.addWidget(self.create_button('Relax right arm'))
        right_arm_box.addWidget(self.create_button('Freeze right arm'))
        left_arm_box.addWidget(self.create_button('Relax left arm'))
        left_arm_box.addWidget(self.create_button('Freeze left arm'))
        left_arm_box.addItem(QtGui.QSpacerItem(50, 20))
        right_arm_box.addItem(QtGui.QSpacerItem(50, 20))

        left_pose_saver = PoseSaver(PoseSaver.LEFT, self)
        right_pose_saver = PoseSaver(PoseSaver.RIGHT, self)
        left_arm_box.addWidget(
            self.create_button("Create left arm pose",
                               left_pose_saver.create_closure()))
        right_arm_box.addWidget(
            self.create_button("Create right arm pose",
                               right_pose_saver.create_closure()))
        left_arm_box.addItem(QtGui.QSpacerItem(50, 20))
        right_arm_box.addItem(QtGui.QSpacerItem(50, 20))

        # Dropdown boxes for saved poses
        left_pose_loader = PoseLoader(PoseLoader.LEFT, self)
        right_pose_loader = PoseLoader(PoseLoader.RIGHT, self)
        self.combo_box_left = left_pose_loader.create_button()
        self.combo_box_right = right_pose_loader.create_button()
        left_arm_box.addWidget(self.combo_box_left)
        right_arm_box.addWidget(self.combo_box_right)

        left_pose_option_box = QtGui.QHBoxLayout()
        right_pose_option_box = QtGui.QHBoxLayout()
        right_pose_option_box.addWidget(self.create_button('Move to pose (R)'))
        left_pose_option_box.addWidget(self.create_button('Move to pose (L)'))

        # Buttons for deleting poses for left/right arms
        left_pose_option_box.addWidget(self.create_button('Delete pose (L)'))
        right_pose_option_box.addWidget(self.create_button('Delete pose (R)'))

        left_arm_box.addLayout(left_pose_option_box)
        right_arm_box.addLayout(right_pose_option_box)
        left_arm_box.addItem(QtGui.QSpacerItem(50, 50))
        right_arm_box.addItem(QtGui.QSpacerItem(50, 50))

        arm_box.addLayout(left_arm_box)
        arm_box.addItem(QtGui.QSpacerItem(20, 20))
        arm_box.addLayout(right_arm_box)
        large_box.addLayout(arm_box)

        # Initialize state of saved arm poses for selected dropdowns
        self.update_saved_l_arm_pose()
        self.update_saved_r_arm_pose()

        # Update saved arm pose data on the changing of selected pose
        self.combo_box_left.connect(
            self.combo_box_left, QtCore.SIGNAL("currentIndexChanged(QString)"),
            self.update_saved_l_arm_pose)
        self.combo_box_right.connect(
            self.combo_box_right,
            QtCore.SIGNAL("currentIndexChanged(QString)"),
            self.update_saved_r_arm_pose)

        self._widget.setObjectName('HalloweenGUI')
        self._widget.setLayout(large_box)
        context.add_widget(self._widget)
        self._widget.setStyleSheet(
            "QWidget { image: url(%s) }" %
            (str(os.path.dirname(os.path.realpath(__file__))) +
             "/../../arm_gui_bg_large.png"))
        rospy.loginfo('GUI initialization complete.')
示例#24
0
  def __init__(self, filenames, search_text='', parent=None):
    '''
    @param filenames: a list with filenames. The last one will be activated.
    @type filenames: C{[str, ...]}
    @param search_text: if not empty, searches in new document for first occurrence of the given text
    @type search_text: C{str} (Default: C{Empty String})
    '''
    QtGui.QDialog.__init__(self, parent)
    self.setObjectName(' - '.join(['xmlEditor', str(filenames)]))
    self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
    self.setWindowFlags(QtCore.Qt.Window)
    self.mIcon = QtGui.QIcon(":/icons/crystal_clear_edit_launch.png")
    self._error_icon = QtGui.QIcon(":/icons/crystal_clear_warning.png")
    self._empty_icon = QtGui.QIcon()
    self.setWindowIcon(self.mIcon)
    self.setWindowTitle("ROSLaunch Editor");
#    self.finished.connect(self.closeEvent)
    self.init_filenames = list(filenames)

    self.files = []
    '''@ivar: list with all open files '''

    # create tabs for files
    self.verticalLayout = QtGui.QVBoxLayout(self)
    self.verticalLayout.setContentsMargins(0, 0, 0, 0)
    self.verticalLayout.setObjectName("verticalLayout")
    self.tabWidget = QtGui.QTabWidget(self)
    self.tabWidget.setTabPosition(QtGui.QTabWidget.North)
    self.tabWidget.setDocumentMode(True)
    self.tabWidget.setTabsClosable(True)
    self.tabWidget.setMovable(False)
    self.tabWidget.setObjectName("tabWidget")
    self.tabWidget.tabCloseRequested.connect(self.on_close_tab)
    self.verticalLayout.addWidget(self.tabWidget)

    # create the buttons line
    self.buttons = QtGui.QWidget(self)
    self.horizontalLayout = QtGui.QHBoxLayout(self.buttons)
    self.horizontalLayout.setContentsMargins(4, 0, 4, 0)
    self.horizontalLayout.setObjectName("horizontalLayout")
    # add the search button
    self.searchButton = QtGui.QPushButton(self)
    self.searchButton.setObjectName("searchButton")
    self.searchButton.clicked.connect(self.on_shortcut_find)
    self.searchButton.setText(QtGui.QApplication.translate("XmlEditor", "Search", None, QtGui.QApplication.UnicodeUTF8))
    self.searchButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+F", None, QtGui.QApplication.UnicodeUTF8))
    self.searchButton.setToolTip('Open a search dialog (Ctrl+F)')
    self.horizontalLayout.addWidget(self.searchButton)
    # add the goto button
    self.gotoButton = QtGui.QPushButton(self)
    self.gotoButton.setObjectName("gotoButton")
    self.gotoButton.clicked.connect(self.on_shortcut_goto)
    self.gotoButton.setText(QtGui.QApplication.translate("XmlEditor", "Goto line", None, QtGui.QApplication.UnicodeUTF8))
    self.gotoButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+L", None, QtGui.QApplication.UnicodeUTF8))
    self.gotoButton.setToolTip('Open a goto dialog (Ctrl+L)')
    self.horizontalLayout.addWidget(self.gotoButton)
    # add a tag button
    self.tagButton = self._create_tag_button(self)
    self.horizontalLayout.addWidget(self.tagButton)

    # add spacer
    spacerItem = QtGui.QSpacerItem(515, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
    self.horizontalLayout.addItem(spacerItem)
    # add line number label
    self.pos_label = QtGui.QLabel()
    self.horizontalLayout.addWidget(self.pos_label)
    # add spacer
    spacerItem = QtGui.QSpacerItem(515, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
    self.horizontalLayout.addItem(spacerItem)
    # add save button
    self.saveButton = QtGui.QPushButton(self)
    self.saveButton.setObjectName("saveButton")
    self.saveButton.clicked.connect(self.on_saveButton_clicked)
    self.saveButton.setText(QtGui.QApplication.translate("XmlEditor", "Save", None, QtGui.QApplication.UnicodeUTF8))
    self.saveButton.setShortcut(QtGui.QApplication.translate("XmlEditor", "Ctrl+S", None, QtGui.QApplication.UnicodeUTF8))
    self.saveButton.setToolTip('Save the changes to the file (Ctrl+S)')
    self.horizontalLayout.addWidget(self.saveButton)
    self.verticalLayout.addWidget(self.buttons)

    #create the find dialog
    self.find_dialog = FindDialog(self)
    self.find_dialog.buttonBox.clicked.connect(self.on_find_dialog_clicked)
    self.find_dialog.found_files.itemActivated.connect(self.find_dialog_itemActivated)

#    self._shortcut_find = QtGui.QShortcut(QtGui.QKeySequence(self.tr("Ctrl+F", "find text")), self)
#    self._shortcut_find.activated.connect(self.on_shortcut_find)

    #open the files
    for f in filenames:
      if f:
        self.on_load_request(os.path.normpath(f), search_text)

    self.readSettings()
示例#25
0
    def __init__(self, context):
        super(PbDGUI, self).__init__(context)
        self.setObjectName('PbDGUI')
        self._widget = QWidget()

        self.speech_cmd_publisher = rospy.Publisher('recognized_command',
                                                    Command)
        self.gui_cmd_publisher = rospy.Publisher('gui_command', GuiCommand)

        rospy.Subscriber('experiment_state', ExperimentState,
                         self.exp_state_cb)
        rospy.Subscriber('robotsound', SoundRequest, self.robotSoundReceived)

        QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
        self.exp_state_sig.connect(self.update_state)

        self.commands = dict()
        self.commands[Command.TEST_MICROPHONE] = 'Test microphone'
        self.commands[Command.NEW_DEMONSTRATION] = 'New demonstration'
        self.commands[Command.START_RECORDING] = 'Start recording'
        self.commands[Command.STOP_RECORDING] = 'Stop recording'
        self.commands[Command.REPLAY_DEMONSTRATION] = 'Replay demonstration'
        self.commands[Command.DETECT_SURFACE] = 'Detect surface'
        self.commands[Command.TAKE_TOOL] = 'Take tool'
        self.commands[Command.RELEASE_TOOL] = 'Release tool'
        self.commands[Command.SAVE_ARM_POSE] = 'Save arm pose'

        self.currentAction = -1
        self.currentStep = -1

        allWidgetsBox = QtGui.QVBoxLayout()
        actionBox = QGroupBox('Demonstrations', self._widget)
        self.actionGrid = QtGui.QGridLayout()
        self.actionGrid.setHorizontalSpacing(0)
        for i in range(6):
            self.actionGrid.addItem(QtGui.QSpacerItem(90, 90), 0, i,
                                    QtCore.Qt.AlignCenter)
            self.actionGrid.setColumnStretch(i, 0)
        self.actionIcons = dict()
        actionBoxLayout = QtGui.QHBoxLayout()
        actionBoxLayout.addLayout(self.actionGrid)
        actionBox.setLayout(actionBoxLayout)

        actionButtonGrid = QtGui.QHBoxLayout()
        actionButtonGrid.addWidget(
            self.create_button(Command.NEW_DEMONSTRATION))
        self.stepsBox = QGroupBox('No demonstrations', self._widget)
        self.stepsGrid = QtGui.QGridLayout()

        self.l_model = QtGui.QStandardItemModel(self)
        self.l_view = self._create_table_view(self.l_model,
                                              self.l_row_clicked_cb)
        self.r_model = QtGui.QStandardItemModel(self)
        self.r_view = self._create_table_view(self.r_model,
                                              self.r_row_clicked_cb)

        self.stepsGrid.addItem(QtGui.QSpacerItem(280, 10), 0, 0, 2, 3)
        self.stepsGrid.addItem(QtGui.QSpacerItem(10, 10), 0, 1, 2, 3)
        self.stepsGrid.addItem(QtGui.QSpacerItem(280, 10), 0, 2, 2, 3)

        self.stepsGrid.addWidget(QtGui.QLabel('Left Arm'), 0, 0)
        self.stepsGrid.addWidget(QtGui.QLabel('Right Arm'), 0, 2)

        self.stepsGrid.addWidget(self.l_view, 1, 0)
        self.stepsGrid.addWidget(self.r_view, 1, 2)

        stepsBoxLayout = QtGui.QHBoxLayout()
        stepsBoxLayout.addLayout(self.stepsGrid)
        self.stepsBox.setLayout(stepsBoxLayout)

        stepsButtonGrid = QtGui.QHBoxLayout()
        stepsButtonGrid.addWidget(
            self.create_button(Command.REPLAY_DEMONSTRATION))

        motionButtonGrid = QtGui.QHBoxLayout()
        motionButtonGrid.addWidget(self.create_button(Command.START_RECORDING))
        motionButtonGrid.addWidget(self.create_button(Command.STOP_RECORDING))

        misc_grid = QtGui.QHBoxLayout()
        misc_grid.addWidget(self.create_button(Command.TEST_MICROPHONE))
        misc_grid.addWidget(self.create_button(Command.DETECT_SURFACE))
        misc_grid.addStretch(1)

        misc_grid2 = QtGui.QHBoxLayout()
        misc_grid2.addWidget(self.create_button(Command.TAKE_TOOL))
        misc_grid2.addWidget(self.create_button(Command.RELEASE_TOOL))
        misc_grid2.addStretch(1)

        misc_grid3 = QtGui.QHBoxLayout()
        misc_grid3.addWidget(self.create_button(Command.SAVE_ARM_POSE))
        misc_grid3.addStretch(1)

        speechGroupBox = QGroupBox('Robot Speech', self._widget)
        speechGroupBox.setObjectName('RobotSpeechGroup')
        speechBox = QtGui.QHBoxLayout()
        self.speechLabel = QtGui.QLabel('Robot has not spoken yet')
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.blue)
        self.speechLabel.setPalette(palette)
        speechBox.addWidget(self.speechLabel)
        speechGroupBox.setLayout(speechBox)

        allWidgetsBox.addWidget(actionBox)
        allWidgetsBox.addLayout(actionButtonGrid)

        allWidgetsBox.addWidget(self.stepsBox)
        allWidgetsBox.addLayout(motionButtonGrid)
        allWidgetsBox.addLayout(stepsButtonGrid)

        allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20))
        allWidgetsBox.addLayout(misc_grid)
        allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20))
        allWidgetsBox.addLayout(misc_grid2)
        allWidgetsBox.addItem(QtGui.QSpacerItem(100, 40))
        allWidgetsBox.addLayout(misc_grid3)
        allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20))

        allWidgetsBox.addWidget(speechGroupBox)
        allWidgetsBox.addStretch(1)

        # Fix layout and add main widget to the user interface
        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('plastique'))
        vAllBox = QtGui.QVBoxLayout()
        vAllBox.addLayout(allWidgetsBox)
        vAllBox.addStretch(1)
        hAllBox = QtGui.QHBoxLayout()
        hAllBox.addLayout(vAllBox)
        hAllBox.addStretch(1)

        self._widget.setObjectName('PbDGUI')
        self._widget.setLayout(hAllBox)
        context.add_widget(self._widget)

        rospy.loginfo('Will wait for the experiment state service...')
        rospy.wait_for_service('get_experiment_state')
        exp_state_srv = rospy.ServiceProxy('get_experiment_state',
                                           GetExperimentState)
        rospy.loginfo('Got response from the experiment state service...')

        response = exp_state_srv()
        self.update_state(response.state)
示例#26
0
    def __init__(self, context):
        super(PbDGUI, self).__init__(context)
        self.setObjectName('PbDGUI')
        self._widget = QWidget()

        self.speech_cmd_publisher = rospy.Publisher('recognized_command',
                                                    Command)
        self.gui_cmd_publisher = rospy.Publisher('gui_command', GuiCommand)

        rospy.Subscriber('experiment_state', ExperimentState,
                         self.exp_state_cb)
        rospy.Subscriber('robotsound', SoundRequest, self.robotSoundReceived)

        QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
        self.exp_state_sig.connect(self.update_state)

        self.commands = dict()
        self.commands[Command.CREATE_NEW_ACTION] = 'New action'
        self.commands[Command.TEST_MICROPHONE] = 'Test microphone'
        self.commands[Command.NEXT_ACTION] = 'Next action'
        self.commands[Command.PREV_ACTION] = 'Previous action'
        self.commands[Command.SAVE_POSE] = 'Save pose'
        self.commands[Command.RELAX_RIGHT_ARM] = 'Relax right arm'
        self.commands[Command.RELAX_LEFT_ARM] = 'Relax left arm'
        self.commands[Command.FREEZE_RIGHT_ARM] = 'Freeze right arm'
        self.commands[Command.FREEZE_LEFT_ARM] = 'Freeze left arm'
        self.commands[Command.OPEN_RIGHT_HAND] = 'Open right hand'
        self.commands[Command.OPEN_LEFT_HAND] = 'Open left hand'
        self.commands[Command.CLOSE_RIGHT_HAND] = 'Close right hand'
        self.commands[Command.CLOSE_LEFT_HAND] = 'Close left hand'
        self.commands[Command.CLOSE_LEFT_HAND] = 'Close left hand'
        self.commands[Command.EXECUTE_ACTION] = 'Execute action'
        self.commands[Command.STOP_EXECUTION] = 'Stop execution'
        self.commands[Command.DELETE_ALL_STEPS] = 'Delete all'
        self.commands[Command.DELETE_LAST_STEP] = 'Delete last'
        self.commands[Command.RECORD_OBJECT_POSE] = 'Record object poses'

        self.currentAction = -1
        self.currentStep = -1

        allWidgetsBox = QtGui.QVBoxLayout()
        actionBox = QGroupBox('Actions', self._widget)
        self.actionGrid = QtGui.QGridLayout()
        self.actionGrid.setHorizontalSpacing(0)
        for i in range(6):
            self.actionGrid.addItem(QtGui.QSpacerItem(90, 90), 0, i,
                                    QtCore.Qt.AlignCenter)
            self.actionGrid.setColumnStretch(i, 0)
        self.actionIcons = dict()
        actionBoxLayout = QtGui.QHBoxLayout()
        actionBoxLayout.addLayout(self.actionGrid)
        actionBox.setLayout(actionBoxLayout)

        actionButtonGrid = QtGui.QHBoxLayout()
        actionButtonGrid.addWidget(
            self.create_button(Command.CREATE_NEW_ACTION))
        self.stepsBox = QGroupBox('No actions created yet', self._widget)
        self.stepsGrid = QtGui.QGridLayout()

        self.l_model = QtGui.QStandardItemModel(self)
        self.l_view = self._create_table_view(self.l_model,
                                              self.l_row_clicked_cb)
        self.r_model = QtGui.QStandardItemModel(self)
        self.r_view = self._create_table_view(self.r_model,
                                              self.r_row_clicked_cb)

        self.stepsGrid.addItem(QtGui.QSpacerItem(280, 10), 0, 0, 2, 3)
        self.stepsGrid.addItem(QtGui.QSpacerItem(10, 10), 0, 1, 2, 3)
        self.stepsGrid.addItem(QtGui.QSpacerItem(280, 10), 0, 2, 2, 3)

        self.stepsGrid.addWidget(QtGui.QLabel('Left Arm'), 0, 0)
        self.stepsGrid.addWidget(QtGui.QLabel('Right Arm'), 0, 2)

        self.stepsGrid.addWidget(self.l_view, 1, 0)
        self.stepsGrid.addWidget(self.r_view, 1, 2)

        stepsBoxLayout = QtGui.QHBoxLayout()
        stepsBoxLayout.addLayout(self.stepsGrid)
        self.stepsBox.setLayout(stepsBoxLayout)

        stepsButtonGrid = QtGui.QHBoxLayout()
        stepsButtonGrid.addWidget(self.create_button(Command.SAVE_POSE))
        stepsButtonGrid.addWidget(self.create_button(Command.EXECUTE_ACTION))
        stepsButtonGrid.addWidget(self.create_button(Command.STOP_EXECUTION))
        stepsButtonGrid.addWidget(self.create_button(Command.DELETE_ALL_STEPS))
        stepsButtonGrid.addWidget(self.create_button(Command.DELETE_LAST_STEP))

        misc_grid = QtGui.QHBoxLayout()
        misc_grid.addWidget(self.create_button(Command.TEST_MICROPHONE))
        misc_grid.addWidget(self.create_button(Command.RECORD_OBJECT_POSE))
        misc_grid.addStretch(1)

        misc_grid2 = QtGui.QHBoxLayout()
        misc_grid2.addWidget(self.create_button(Command.RELAX_RIGHT_ARM))
        misc_grid2.addWidget(self.create_button(Command.RELAX_LEFT_ARM))
        misc_grid2.addWidget(self.create_button(Command.FREEZE_RIGHT_ARM))
        misc_grid2.addWidget(self.create_button(Command.FREEZE_LEFT_ARM))
        misc_grid2.addStretch(1)

        misc_grid3 = QtGui.QHBoxLayout()
        misc_grid3.addWidget(self.create_button(Command.OPEN_RIGHT_HAND))
        misc_grid3.addWidget(self.create_button(Command.OPEN_LEFT_HAND))
        misc_grid3.addWidget(self.create_button(Command.CLOSE_RIGHT_HAND))
        misc_grid3.addWidget(self.create_button(Command.CLOSE_LEFT_HAND))
        misc_grid3.addStretch(1)

        misc_grid4 = QtGui.QHBoxLayout()
        misc_grid4.addWidget(self.create_button(Command.PREV_ACTION))
        misc_grid4.addWidget(self.create_button(Command.NEXT_ACTION))
        misc_grid4.addStretch(1)

        speechGroupBox = QGroupBox('Robot Speech', self._widget)
        speechGroupBox.setObjectName('RobotSpeechGroup')
        speechBox = QtGui.QHBoxLayout()
        self.speechLabel = QtGui.QLabel('Robot has not spoken yet')
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.blue)
        self.speechLabel.setPalette(palette)
        speechBox.addWidget(self.speechLabel)
        speechGroupBox.setLayout(speechBox)

        allWidgetsBox.addWidget(actionBox)
        allWidgetsBox.addLayout(actionButtonGrid)

        allWidgetsBox.addWidget(self.stepsBox)
        allWidgetsBox.addLayout(stepsButtonGrid)

        allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20))
        allWidgetsBox.addLayout(misc_grid)
        allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20))
        allWidgetsBox.addLayout(misc_grid2)
        allWidgetsBox.addLayout(misc_grid3)
        allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20))
        allWidgetsBox.addLayout(misc_grid4)
        allWidgetsBox.addItem(QtGui.QSpacerItem(100, 20))

        allWidgetsBox.addWidget(speechGroupBox)
        allWidgetsBox.addStretch(1)

        # Fix layout and add main widget to the user interface
        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('plastique'))
        vAllBox = QtGui.QVBoxLayout()
        vAllBox.addLayout(allWidgetsBox)
        vAllBox.addStretch(1)
        hAllBox = QtGui.QHBoxLayout()
        hAllBox.addLayout(vAllBox)
        hAllBox.addStretch(1)

        self._widget.setObjectName('PbDGUI')
        self._widget.setLayout(hAllBox)
        context.add_widget(self._widget)

        rospy.loginfo('Will wait for the experiment state service...')
        rospy.wait_for_service('get_experiment_state')
        exp_state_srv = rospy.ServiceProxy('get_experiment_state',
                                           GetExperimentState)
        rospy.loginfo('Got response from the experiment state service...')

        response = exp_state_srv()
        self.update_state(response.state)
示例#27
0
    def make_Graphs(self):
        """Method to initialize the different plots.

        Creates a plot with grid and legend, then adds it to the coresponding layout.
        """
        self.tempplt = pg.plot()
        self.tempplt.setYRange(-1, 100)
        self.tempplt.showGrid(x=True, y=True)
        self.tempplt.addLegend()
        for i in range(0, 10):
            self.tempplt.plot(np.zeros(10),
                              np.zeros(10),
                              pen=self.colorlist[i],
                              name=self.motornames[i])
        self.tempplt.addLegend(offset=79)
        #creates a legend by plotting a single point for each motor, just so they show up in the legend.
        #Apparently you are supposed to do it that way...
        for i in range(10, 20):
            self.tempplt.plot(np.zeros(10),
                              np.zeros(10),
                              pen=self.colorlist[i],
                              name=self.motornames[i])
        self.layout_temp = QtGui.QHBoxLayout()
        self.combobox3 = QComboBox()
        self.combobox3.addItem('All')
        for i in self.motornames:
            self.combobox3.addItem(i)
        self._widget.Temperatur.setLayout(self.layout_temp)
        self.layout_temp.addWidget(self.tempplt)
        self.layout_temp.addWidget(self.combobox3)
        self.tempplt.win.hide()

        self.torqueplt = pg.plot()
        self.torqueplt.setYRange(-1, 2)
        self.torqueplt.showGrid(x=True, y=True)
        self.torqueplt.addLegend()
        for i in range(0, 10):
            self.torqueplt.plot(np.zeros(10),
                                np.zeros(10),
                                pen=self.colorlist[i],
                                name=self.motornames[i])
        self.torqueplt.addLegend(offset=79)
        for i in range(10, 20):
            self.torqueplt.plot(np.zeros(10),
                                np.zeros(10),
                                pen=self.colorlist[i],
                                name=self.motornames[i])
        self.layout_torque = QtGui.QHBoxLayout()
        self._widget.Torque.setLayout(self.layout_torque)
        self.layout_torque.addWidget(self.torqueplt)
        self.combobox = QComboBox()
        self.combobox.addItem('All')
        for i in self.motornames:
            self.combobox.addItem(i)
        self.layout_torque.addWidget(self.combobox)
        self.torqueplt.win.hide()

        self.voltageplt = pg.plot()
        self.voltageplt.setYRange(-1, 30)
        self.voltageplt.showGrid(x=True, y=True)
        self.voltageplt.addLegend()
        for i in range(0, 10):
            self.voltageplt.plot(np.zeros(10),
                                 np.zeros(10),
                                 pen=self.colorlist[i],
                                 name=self.motornames[i])
        self.voltageplt.addLegend(offset=79)
        for i in range(10, 20):
            self.voltageplt.plot(np.zeros(10),
                                 np.zeros(10),
                                 pen=self.colorlist[i],
                                 name=self.motornames[i])
        self.layout_voltage = QtGui.QHBoxLayout()
        self.combobox2 = QComboBox()
        self.combobox2.addItem('All')
        for i in self.motornames:
            self.combobox2.addItem(i)
        self._widget.Voltage.setLayout(self.layout_voltage)
        self.layout_voltage.addWidget(self.voltageplt)
        self.layout_voltage.addWidget(self.combobox2)
        self.voltageplt.win.hide()
    def __init__(self, plugin):
        super(ControllerManagerWidget, self).__init__()

        self._plugin = plugin
        self.setWindowTitle('Controller Manager')

        # create layouts
        vlayout_outer = QtGui.QVBoxLayout(self)
        vlayout_outer.setObjectName('vert_layout_outer')
        hlayout_top = QtGui.QHBoxLayout(self)
        hlayout_top.setObjectName('hori_layout_top')
        vlayout_outer.addLayout(hlayout_top)

        # create top bar
        # controller manager namespace combo box & label
        cm_ns_label = QtGui.QLabel(self)
        cm_ns_label.setObjectName('cm_ns_label')
        cm_ns_label.setText('CM Namespace:')
        fixed_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed)
        cm_ns_label.setSizePolicy(fixed_policy)
        hlayout_top.addWidget(cm_ns_label)
        cm_namespace_combo = QtGui.QComboBox(self)
        cm_namespace_combo.setObjectName('cm_namespace_combo')
        hlayout_top.addWidget(cm_namespace_combo)
        self.cm_namespace_combo = cm_namespace_combo

        # load controller combo box & label
        load_ctrl_label = QtGui.QLabel(self)
        load_ctrl_label.setObjectName('load_ctrl_label')
        load_ctrl_label.setText('Load Controller:')
        fixed_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed)
        load_ctrl_label.setSizePolicy(fixed_policy)
        hlayout_top.addWidget(load_ctrl_label)
        load_ctrl_combo = QtGui.QComboBox(self)
        load_ctrl_combo.setObjectName('load_ctrl_combo')
        load_ctrl_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                                  QtGui.QSizePolicy.Fixed)
        load_ctrl_combo.setSizePolicy(load_ctrl_size_policy)
        hlayout_top.addWidget(load_ctrl_combo)
        self.load_ctrl_combo = load_ctrl_combo

        # load control button
        load_ctrl_button = QtGui.QPushButton(self)
        load_ctrl_button.setObjectName('load_ctrl_button')
        button_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                               QtGui.QSizePolicy.Fixed)
        button_size_policy.setHorizontalStretch(0)
        button_size_policy.setVerticalStretch(0)
        button_size_policy.setHeightForWidth(
            load_ctrl_button.sizePolicy().hasHeightForWidth())
        load_ctrl_button.setSizePolicy(button_size_policy)
        load_ctrl_button.setBaseSize(QtCore.QSize(30, 30))
        load_ctrl_button.setIcon(QIcon.fromTheme('list-add'))
        load_ctrl_button.setIconSize(QtCore.QSize(20, 20))
        load_ctrl_button.clicked.connect(self.load_cur_ctrl)
        hlayout_top.addWidget(load_ctrl_button)

        # start control button
        start_ctrl_button = QtGui.QPushButton(self)
        start_ctrl_button.setObjectName('start_ctrl_button')
        button_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                               QtGui.QSizePolicy.Fixed)
        button_size_policy.setHorizontalStretch(0)
        button_size_policy.setVerticalStretch(0)
        button_size_policy.setHeightForWidth(
            start_ctrl_button.sizePolicy().hasHeightForWidth())
        start_ctrl_button.setSizePolicy(button_size_policy)
        start_ctrl_button.setBaseSize(QtCore.QSize(30, 30))
        start_ctrl_button.setIcon(QIcon.fromTheme('media-playback-start'))
        start_ctrl_button.setIconSize(QtCore.QSize(20, 20))
        start_ctrl_button.clicked.connect(self.start_cur_ctrl)
        hlayout_top.addWidget(start_ctrl_button)

        # create tree/list widget
        ctrl_list_tree_widget = QtGui.QTreeWidget(self)
        ctrl_list_tree_widget.setObjectName('ctrl_list_tree_widget')
        self.ctrl_list_tree_widget = ctrl_list_tree_widget
        ctrl_list_tree_widget.setColumnCount(len(self._column_names))
        ctrl_list_tree_widget.setHeaderLabels(self._column_names_pretty)
        ctrl_list_tree_widget.sortByColumn(0, Qt.AscendingOrder)
        ctrl_list_tree_widget.setContextMenuPolicy(Qt.CustomContextMenu)
        ctrl_list_tree_widget.customContextMenuRequested.connect(
            self.on_ctrl_list_tree_widget_customContextMenuRequested)
        vlayout_outer.addWidget(ctrl_list_tree_widget)

        header = self.ctrl_list_tree_widget.header()
        header.setResizeMode(QHeaderView.ResizeToContents)
        header.customContextMenuRequested.connect(
            self.handle_header_view_customContextMenuRequested)
        header.setContextMenuPolicy(Qt.CustomContextMenu)

        self._ctrlers = {}
        self._column_index = {}
        for column_name in self._column_names:
            self._column_index[column_name] = len(self._column_index)

        # controller manager services
        self.list_types = {}
        self.list_ctrlers = {}
        self.load_ctrler = {}
        self.unload_ctrler = {}
        self.switch_ctrlers = {}
        self.ctrlman_ns_cur = ''
        self.loadable_params = {}

        # init and start update timer
        self._timer_refresh_ctrlers = QTimer(self)
        self._timer_refresh_ctrlers.timeout.connect(self._refresh_ctrlers_cb)
示例#29
0
    def __init__(self, context):
        super(SimpleGUI, self).__init__(context)
        self.setObjectName('SimpleGUI')
        self._widget = QWidget()
        self._widget.setFixedSize(600, 600)
        self._sound_client = SoundClient()
        rospy.Subscriber('robotsound', SoundRequest, self.sound_cb)

        QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
        self.sound_sig.connect(self.sound_sig_cb)

        large_box = QtGui.QVBoxLayout()

        #Sound textbox
        sound_textbox = QtGui.QLineEdit("Squirtle Squirtle")  #Default Text
        sound_textbox.setFixedWidth(450)
        #Set a handle on the textbox to retrieve the text when button clicked
        self.sound_textbox = sound_textbox

        button_box = QtGui.QHBoxLayout()
        button_box.addItem(QtGui.QSpacerItem(15, 20))
        button_box.addWidget(self.create_button('Speak', self.command_cb))
        button_box.addWidget(sound_textbox)
        button_box.addStretch(1)
        large_box.addLayout(button_box)

        speech_box = QtGui.QHBoxLayout()
        speech_box.addItem(QtGui.QSpacerItem(15, 20))
        self.speech_label = QtGui.QLabel('Robot has not spoken yet.')
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.blue)
        self.speech_label.setPalette(palette)
        speech_box.addWidget(self.speech_label)

        large_box.addLayout(speech_box)
        large_box.addStretch(1)

        #large_box.addItem(QtGui.QSpacerItem(50,20))

        up_head = Head(Head.UP)
        head_box = QtGui.QVBoxLayout()
        up_head_box = QtGui.QHBoxLayout()
        up_head_button = self.create_button('^', up_head.create_closure())
        #large_box.addWidget(up_head_button)
        down_head = Head(Head.DOWN)
        down_head_box = QtGui.QHBoxLayout()
        down_head_button = self.create_button('v', down_head.create_closure())
        #large_box.addWidget(down_head_button)
        right_head = Head(Head.RIGHT)
        right_head_button = self.create_button('>',
                                               right_head.create_closure())
        #large_box.addWidget(right_head_button)
        left_head = Head(Head.LEFT)
        left_head_button = self.create_button('<', left_head.create_closure())
        left_right_head_box = QtGui.QHBoxLayout()

        up_head_box.addItem(QtGui.QSpacerItem(235, 20))
        up_head_box.addWidget(up_head_button)
        up_head_box.addItem(QtGui.QSpacerItem(275, 20))
        left_right_head_box.addItem(QtGui.QSpacerItem(160, 20))
        left_right_head_box.addWidget(left_head_button)
        left_right_head_box.addItem(QtGui.QSpacerItem(60, 20))
        left_right_head_box.addWidget(right_head_button)
        left_right_head_box.addItem(QtGui.QSpacerItem(225, 20))
        down_head_box.addItem(QtGui.QSpacerItem(235, 20))
        down_head_box.addWidget(down_head_button)
        down_head_box.addItem(QtGui.QSpacerItem(275, 20))
        head_box.addLayout(up_head_box)
        head_box.addLayout(left_right_head_box)
        head_box.addLayout(down_head_box)
        large_box.addLayout(head_box)
        #large_box.addItem(QtGui.QSpacerItem(500,20))
        #large_box.addWidget(left_head_button)

        gripper = Gripper(Gripper.RIGHT, Gripper.OPEN)
        right_gripper = self.create_button('Right gripper!',
                                           gripper.create_closure())
        gripper = Gripper(Gripper.LEFT, Gripper.OPEN)
        left_gripper = self.create_button('Left gripper!',
                                          gripper.create_closure())
        large_box.addItem(QtGui.QSpacerItem(100, 250))

        gripper_box = QtGui.QHBoxLayout()
        gripper_box.addItem(QtGui.QSpacerItem(75, 20))
        gripper_box.addWidget(left_gripper)
        gripper_box.addItem(QtGui.QSpacerItem(450, 20))
        gripper_box.addWidget(right_gripper)
        gripper_box.addItem(QtGui.QSpacerItem(75, 20))
        large_box.addLayout(gripper_box)

        base_box = QtGui.QVBoxLayout()

        large_box.addItem(QtGui.QSpacerItem(100, 100))

        #forward
        forward_base_box = QtGui.QHBoxLayout()
        forward_base = Base(Base.FORWARD)
        forward_base_button = self.create_button('move forward',
                                                 forward_base.create_closure())
        forward_base_box.addItem(QtGui.QSpacerItem(400, 20))
        forward_base_box.addWidget(forward_base_button)
        forward_base_box.addItem(QtGui.QSpacerItem(400, 20))
        base_box.addLayout(forward_base_box)
        #large_box.addWidget(forward_base_button)

        #left
        left_right_base_box = QtGui.QHBoxLayout()
        left_base = Base(Base.LEFT)
        left_base_button = self.create_button('move left',
                                              left_base.create_closure())
        #large_box.addWidget(left_base_button)

        #right
        right_base = Base(Base.RIGHT)
        right_base_button = self.create_button('move right',
                                               right_base.create_closure())
        left_right_base_box.addItem(QtGui.QSpacerItem(300, 20))
        left_right_base_box.addWidget(left_base_button)
        left_right_base_box.addItem(QtGui.QSpacerItem(50, 20))
        left_right_base_box.addWidget(right_base_button)
        left_right_base_box.addItem(QtGui.QSpacerItem(300, 20))
        base_box.addLayout(left_right_base_box)
        #large_box.addWidget(right_base_button)

        #backward
        backward_base_box = QtGui.QHBoxLayout()
        backward_base = Base(Base.BACKWARD)
        backward_base_button = self.create_button(
            'move backward', backward_base.create_closure())
        backward_base_box.addItem(QtGui.QSpacerItem(400, 20))
        backward_base_box.addWidget(backward_base_button)
        backward_base_box.addItem(QtGui.QSpacerItem(400, 20))
        base_box.addLayout(backward_base_box)
        #large_box.addWidget(backward_base_button)

        large_box.addLayout(base_box)

        turn_base_box = QtGui.QHBoxLayout()

        #turn left
        turnleft_base = Base(Base.TURNLEFT)
        turnleft_base_button = self.create_button(
            '        /\n<--', turnleft_base.create_closure())
        #large_box.addWidget(turnleft_base_button)

        #turn right
        turnright_base = Base(Base.TURNRIGHT)
        turnright_base_button = self.create_button(
            '\\\n        -->', turnright_base.create_closure())
        turn_base_box.addItem(QtGui.QSpacerItem(75, 20))
        turn_base_box.addWidget(turnright_base_button)
        turn_base_box.addItem(QtGui.QSpacerItem(225, 20))
        turn_base_box.addWidget(turnleft_base_button)
        turn_base_box.addItem(QtGui.QSpacerItem(100, 20))
        large_box.addLayout(turn_base_box)
        #large_box.addWidget(turnright_base_button)
        self._widget.setObjectName('SimpleGUI')
        self._widget.setLayout(large_box)
        context.add_widget(self._widget)
        self._widget.setStyleSheet(
            "QWidget { image: url(%s) }" %
            "/home/vjampala/catkin_ws/src/cse481/hw1/rqt_simplegui/rosie_background.jpg"
        )
示例#30
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        path = rospkg.RosPack().get_path('etna_planning')

        ## rviz.VisualizationFrame is the main container widget of the
        ## regular RViz application. In this example, we disable everything
        ## so that the only thing visible is the 3D render window.
        self.frame = rviz.VisualizationFrame()
        self.frame.setSplashPath("")
        self.frame.initialize()

        ## The reader reads config file data into the config object.
        ## VisualizationFrame reads its data from the config object.
        reader = rviz.YamlConfigReader()
        config = rviz.Config()

        #        rospack = rospkg.RosPack()
        #        package_path = rospack.get_path('rviz_python_tutorial')
        #        reader.readFile( config, package_path + "config.myviz" )
        reader.readFile(config, os.path.join(path, 'config', 'workcell.rviz'))
        self.frame.load(config)

        ## You can also store any other application data you like in the
        ## config object.  Here we read the window title from the map key
        ## called "Title", which has been added by hand to the config file.
        self.setWindowTitle(config.mapGetChild("Title").getValue())

        self.frame.setMenuBar(None)
        self.frame.setHideButtonVisibility(False)

        self.manager = self.frame.getManager()

        ## Since the config file is part of the source code for this
        ## example, we know that the first display in the list is the
        ## grid we want to control.  Here we just save a reference to
        ## it for later.
        self.grid_display = self.manager.getRootDisplayGroup().getDisplayAt(0)

        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(9, 0, 9, 0)
        self.setLayout(layout)

        h_layout = QtGui.QHBoxLayout()
        layout.addLayout(h_layout)

        orbit_button = QtGui.QPushButton("Orbit View")
        orbit_button.clicked.connect(self.onOrbitButtonClick)
        h_layout.addWidget(orbit_button)

        front_button = QtGui.QPushButton("Front View")
        front_button.clicked.connect(self.onFrontButtonClick)
        h_layout.addWidget(front_button)

        right_button = QtGui.QPushButton("Rigth View")
        right_button.clicked.connect(self.onRightButtonClick)
        h_layout.addWidget(right_button)

        top_button = QtGui.QPushButton("Top View")
        top_button.clicked.connect(self.onTopButtonClick)
        h_layout.addWidget(top_button)

        layout.addWidget(self.frame)