Example #1
0
    def __init__(self, parentfilter, item_provider):
        """
        :param parentfilter: The filter object, must implement set_list and
        contain _list ''QObject''
        :param item_provider: a function designed to provide a list or dict
        """
        super(ListFilterWidget, self).__init__()

        pkg_name = 'rqt_console'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               'filters', 'list_filter_widget.ui')

        loadUi(ui_file, self)
        self.setObjectName('ListFilterWidget')
        # When data is changed we need to store it in the parent filter
        self._parentfilter = parentfilter

        # keep color for highlighted items even when not active
        active_color = self.palette().brush(QPalette.Active,
                                            QPalette.Highlight).color().name()
        self.setStyleSheet(
            'QListWidget:item:selected:!active { background: %s; }' %
            active_color)

        self._list_populate_function = item_provider
        self.list_widget.itemSelectionChanged.connect(self.handle_item_changed)
        self._display_list = []
        self.repopulate()
Example #2
0
def save_samples_to_file(samples,
                         file_name='dataset.json',
                         pkg='handeye_dashboard'):
    """
  Saving transform samples to a disc file
  Parameters
  -------------
  samples: list
    A list of transforms.
  file_name: string
    The destination file.
  Returns
  --------
  Success: bool
    Execution status
  """
    success = False
    samples_list = []
    for sample in samples:
        samples_list += [[sample[0].tolist(), sample[1].tolist()]]

    _, path_pkg = get_resource('packages', pkg)

    import json
    # If the file name exists, write a JSON string into the file.
    if file_name != None:
        filename = '/tmp/' + file_name
        # Writing JSON data
        with open(filename, 'w') as f:
            json.dump(samples_list, f)
            success = True

    return success
    def __init__(self, node):
        super(ServiceCallerWidget, self).__init__()
        self.setObjectName('ServiceCallerWidget')
        self._node = node

        # create context for the expression eval statement
        self._eval_locals = {}
        for module in (math, random, time):
            self._eval_locals.update(module.__dict__)
        del self._eval_locals['__name__']
        del self._eval_locals['__doc__']

        pkg_name = 'rqt_service_caller'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               'ServiceCaller.ui')

        loadUi(ui_file, self, {'ExtendedComboBox': ExtendedComboBox})

        self.refresh_services_button.setIcon(QIcon.fromTheme('view-refresh'))
        self.call_service_button.setIcon(QIcon.fromTheme('call-start'))

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

        self._service_info = None
        self.on_refresh_services_button_clicked()

        self.request_tree_widget.itemChanged.connect(
            self.request_tree_widget_itemChanged)
Example #4
0
    def __init__(self,
                 mode=message_helpers.MSG_MODE,
                 pkg_name='rqt_msg',
                 ui_filename='messages.ui'):
        """
        :param ui_filename: This Qt-based .ui file must have elements that are
                            referred from this class. Otherwise unexpected
                            errors are likely to happen. Best way to avoid that
                            situation when you want to give your own .ui file
                            is to implement all Qt components in
                            rqt_msg/resource/message.ui file.
        """
        super(MessagesWidget, self).__init__()

        self._logger = logging.get_logger("MessagesWidget")

        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               ui_filename)

        loadUi(ui_file, self, {'MessagesTreeView': MessagesTreeView})
        self.setObjectName(ui_filename)
        self._mode = mode

        self._add_button.setIcon(QIcon.fromTheme('list-add'))
        self._add_button.clicked.connect(self._add_message)
        self._refresh_packages(mode)
        self._refresh_msgs(self._package_combo.itemText(0))
        self._package_combo.currentIndexChanged[str].connect(
            self._refresh_msgs)
        self._messages_tree.mousePressEvent = self._handle_mouse_press

        self._browsers = []
    def __init__(self, widget, filter_name):
        """
        :param widget: the Qwidget to wrap ''Qwidget''
        :param filter_name: the name to be placed on the label ''str''
        """
        super(FilterWrapperWidget, self).__init__()

        pkg_name = 'rqt_console'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(
            package_path, 'share', pkg_name, 'resource', 'filters', 'filter_wrapper_widget.ui')

        loadUi(ui_file, self)
        self.setObjectName('FilterWrapperWidget')
        self.delete_button.setIcon(QIcon.fromTheme('list-remove'))
        self._widget = widget

        # Replace the placeholder QWidget with the passed in object
        stretch = self.layout_frame.stretch(2)
        self.layout_frame.insertWidget(2, widget)
        self.layout_frame.setStretch(2, stretch)

        # This line sets the place holder to 0 width so it can no longer be seen
        # It is a hack since removing it causes other widgets not to function properly
        self.layout_frame.setStretch(3, 0)

        self.enabled_checkbox.clicked[bool].connect(self.enabled_callback)
        self.filter_name_label.setText(filter_name + ':')
Example #6
0
    def __init__(self, node, initial_topics=None, start_paused=False):
        super(PlotWidget, self).__init__()
        self.setObjectName('PlotWidget')

        self._node = node
        self._initial_topics = initial_topics

        _, package_path = get_resource('packages', 'rqt_plot')
        ui_file = os.path.join(package_path, 'share', 'rqt_plot', 'resource',
                               'plot.ui')
        loadUi(ui_file, self)
        self.subscribe_topic_button.setIcon(QIcon.fromTheme('list-add'))
        self.remove_topic_button.setIcon(QIcon.fromTheme('list-remove'))
        self.pause_button.setIcon(QIcon.fromTheme('media-playback-pause'))
        self.clear_button.setIcon(QIcon.fromTheme('edit-clear'))
        self.data_plot = None

        self.subscribe_topic_button.setEnabled(False)
        if start_paused:
            self.pause_button.setChecked(True)

        self._topic_completer = TopicCompleter(self.topic_edit)
        self._topic_completer.update_topics(node)
        self.topic_edit.setCompleter(self._topic_completer)

        self._start_time = time.time()
        self._rosdata = {}
        self._remove_topic_menu = QMenu()

        # init and start update timer for plot
        self._update_plot_timer = QTimer(self)
        self._update_plot_timer.timeout.connect(self.update_plot)
    def __init__(self, node):
        super(ExamplesWidget, self).__init__()
        self.setObjectName('ExamplesWidget')

        self.node = node
        pkg_name = 'examples_rqt'
        ui_filename = 'examples_rqt.ui'
        topic_name = 'cmd_vel'
        service_name = 'led_control'

        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource', ui_filename)
        loadUi(ui_file, self)

        self.pub_velocity = Twist()
        self.pub_velocity.linear.x = 0.0
        self.pub_velocity.angular.z = 0.0
        self.sub_velocity = Twist()
        self.sub_velocity.linear.x = 0.0
        self.sub_velocity.angular.z = 0.0

        self.slider_x.setValue(0)
        self.lcd_number_x.display(0.0)
        self.lcd_number_yaw.display(0.0)

        qos_profile = 0
        qos = self.get_qos(qos_profile)
        self.publisher = self.node.create_publisher(Twist, topic_name, qos)
        self.subscriber = self.node.create_subscription(Twist, topic_name, self.cmd_callback, qos)
        self.service_server = self.node.create_service(SetBool, service_name, self.srv_callback)
        self.service_client = self.node.create_client(SetBool, service_name)

        update_timer = QTimer(self)
        update_timer.timeout.connect(self.update_data)
        update_timer.start(self.redraw_interval)

        self.push_button_w.pressed.connect(self.on_increase_x_linear_pressed)
        self.push_button_x.pressed.connect(self.on_decrease_x_linear_pressed)
        self.push_button_a.pressed.connect(self.on_increase_z_angular_pressed)
        self.push_button_d.pressed.connect(self.on_decrease_z_angular_pressed)
        self.push_button_s.pressed.connect(self.on_stop_pressed)

        self.radio_button_led_on.clicked.connect(self.call_led_service)
        self.radio_button_led_off.clicked.connect(self.call_led_service)

        self.push_button_w.setShortcut('w')
        self.push_button_x.setShortcut('x')
        self.push_button_a.setShortcut('a')
        self.push_button_d.setShortcut('d')
        self.push_button_s.setShortcut('s')

        self.shortcut_space = QShortcut(QKeySequence(Qt.Key_Space), self)
        self.shortcut_space.setContext(Qt.ApplicationShortcut)
        self.shortcut_space.activated.connect(self.push_button_s.pressed)

        self.radio_button_led_on.setShortcut('o')
        self.radio_button_led_off.setShortcut('f')
Example #8
0
    def __init__(self):
        super(GameViewerWidget, self).__init__()

        pkg_name = 'consai2r2_gameviewer'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               'gameviewer_widget.ui')
        loadUi(ui_file, self)

        self.setObjectName('GameViewerWidget')
Example #9
0
    def __init__(self):
        super(TsuraiWidget, self).__init__()

        # パッケージ名も書き間違えないように
        pkg_name = 'rqt_tsurai'
        _, package_path = get_resource('packages', pkg_name)
        # UIをロードするけどファイル名を間違えないように
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               'tsurai_widget.ui')
        loadUi(ui_file, self)

        # オブジェクト名は間違えても動く?未調査
        self.setObjectName('TsuraiWidget')
    def __init__(self, title='Options', description=None):
        super(SimpleSettingsDialog, self).__init__()
        self.setObjectName('SimpleSettingsDialog')

        _, package_path = get_resource('packages', 'qt_gui_py_common')
        ui_file = os.path.join(package_path, 'share', 'qt_gui_py_common',
                               'resource', 'simple_settings_dialog.ui')
        loadUi(ui_file, self)

        self.setWindowTitle(title)
        self._settings_groups = []

        if description is not None:
            self.add_label(description)
    def __init__(self, parentfilter, item_providers):
        super(CustomFilterWidget, self).__init__()

        pkg_name = 'rqt_console'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               'filters', 'custom_filter_widget.ui')

        loadUi(ui_file, self)
        self.setObjectName('CustomFilterWidget')
        self._parentfilter = parentfilter  # When data is changed it is stored in the parent filter

        # keep color for highlighted items even when not active
        for list_widget in [
                self.severity_list, self.node_list, self.topic_list
        ]:
            active_color = list_widget.palette().brush(
                QPalette.Active, QPalette.Highlight).color().name()
            list_widget.setStyleSheet(
                'QListWidget:item:selected:!active { background: %s; }' %
                active_color)

        # Text Filter Initialization
        self.text_edit.textChanged.connect(self.handle_text_changed)
        self.regex_check_box.clicked[bool].connect(self.handle_regex_clicked)
        self.handle_text_changed()

        # Severity Filter Initialization
        self.severity_list.itemSelectionChanged.connect(
            self.handle_severity_item_changed)
        new_items = item_providers[0]()
        for key in sorted(new_items.keys()):
            item = new_items[key]
            self.severity_list.addItem(item)
            self.severity_list.item(self.severity_list.count() - 1).setData(
                Qt.UserRole, key)

        # Node Filter Initialization
        self._node_list_populate_function = item_providers[1]
        self.node_list.itemSelectionChanged.connect(
            self.handle_node_item_changed)

        # Topic Filter Initialization
        self._topic_list_populate_function = item_providers[2]
        self.topic_list.itemSelectionChanged.connect(
            self.handle_topic_item_changed)

        self.repopulate()
Example #12
0
    def __init__(self, context=None):
        super(PyConsoleWidget, self).__init__()

        _, package_path = get_resource('packages', 'rqt_py_console')
        ui_file = os.path.join(package_path, 'share', 'rqt_py_console',
                               'resource', 'py_console_widget.ui')

        loadUi(ui_file, self, {'PyConsoleTextEdit': PyConsoleTextEdit})
        self.setObjectName('PyConsoleWidget')

        my_locals = {'context': context}
        self.py_console.update_interpreter_locals(my_locals)
        self.py_console.print_message(
            'The variable "context" is set to the PluginContext of this plugin.'
        )
        self.py_console.exit.connect(context.close_plugin)
Example #13
0
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description='Query the ament resource index.')
    arg = parser.add_argument('resource_type',
                              nargs='?',
                              metavar='TYPE',
                              help='The type of the resource')
    arg.completer = resource_type_completer
    arg = parser.add_argument('resource_name',
                              nargs='?',
                              metavar='NAME',
                              help='The name of the resource')
    arg.completer = resource_name_completer

    try:
        from argcomplete import autocomplete
    except ImportError:
        pass
    else:
        autocomplete(parser, exclude=['-h', '--help'])

    args = parser.parse_args(argv)

    if args.resource_type is None:
        for resource_type in sorted(get_resource_types()):
            print(resource_type)
        return

    if args.resource_name is None:
        resources = get_resources(args.resource_type)
        for resource_name in sorted(resources.keys()):
            print(resource_name + '\t' + resources[resource_name])
        return

    try:
        content, path = get_resource(args.resource_type, args.resource_name)
    except (LookupError, OSError) as e:
        return str(e)
    print(path)
    if content:
        print('<<<')
        print(content)
        print('>>>')
Example #14
0
    def __init__(self, parentfilter):
        """
        Widget for displaying interactive data related to text filtering.
        :param parentfilter: buddy filter were data is stored, ''TimeFilter''
        """
        super(TextFilterWidget, self).__init__()

        pkg_name = 'rqt_console'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(
            package_path, 'share', pkg_name, 'resource', 'filters', 'text_filter_widget.ui')

        loadUi(ui_file, self)
        self.setObjectName('TextFilterWidget')
        self._parentfilter = parentfilter  # When data is changed it is stored in the parent filter

        self.text_edit.textChanged.connect(self.handle_text_changed)
        self.regex_check_box.clicked[bool].connect(self.handle_regex_clicked)

        self.handle_text_changed()
Example #15
0
    def __init__(self, topics):
        """
        :param topics: list of topics to allow switching, ''list of string''
        :param limit: displayed in the message buffer size spin box, ''int''
        """
        super(ConsoleSettingsDialog, self).__init__()

        pkg_name = 'rqt_console'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               'console_settings_dialog.ui')

        loadUi(ui_file, self)
        for topic in topics:
            self.topic_combo.addItem(topic + ' (rcl_interfaces/msg/Log)',
                                     topic)

        # self._service_caller = LoggerLevelServiceCaller()
        # self._logger_widget = LoggerLevelWidget(self._service_caller)
        # self.levelsLayout.addWidget(self._logger_widget)
        self.adjustSize()
Example #16
0
    def __init__(self, parentfilter, time_range_provider):
        """
        Widget for displaying interactive data related to time filtering.
        :param parentfilter: buddy filter were data is stored, ''TimeFilter''
        :param display_list_args: single element list containing one tuple with
        the min and max time to be displayed, ''list of tuple''
        """
        super(TimeFilterWidget, self).__init__()
        pkg_name = 'rqt_console'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               'filters', 'time_filter_widget.ui')

        loadUi(ui_file, self)
        self.setObjectName('TimeFilterWidget')
        self._parentfilter = parentfilter  # When data is changed it is stored in the parent filter

        self.start_datetime.dateTimeChanged[QDateTime].connect(
            self.handle_start_changed)
        self.stop_datetime.dateTimeChanged[QDateTime].connect(
            self.handle_stop_changed)
        self.stop_enabled_check_box.clicked[bool].connect(
            self.handle_stop_enabled_changed)

        # Times are passed in unixtimestamp '.' decimal fraction of a second
        mintime, maxtime = time_range_provider()
        if mintime != -1:
            mintime = str(mintime).split('.')
            maxtime = str(maxtime).split('.')

            time = QDateTime()
            time.setTime_t(int(mintime[0]))
            mintime = time.addMSecs(int(str(mintime[1]).zfill(9)[:3]))
            self.start_datetime.setDateTime(mintime)
            time.setTime_t(int(maxtime[0]))
            maxtime = time.addMSecs(int(str(maxtime[1]).zfill(9)[:3]))
            self.stop_datetime.setDateTime(maxtime)
        else:
            self.start_datetime.setDateTime(datetime.now())
            self.stop_datetime.setDateTime(datetime.now())
Example #17
0
    def __init__(self,
                 plugin_widget,
                 on_sys_msg=True,
                 on_sysprogress_bar=True):
        """
        @param plugin_widget: The main widget of an rqt plugin.
        @type plugin_widget: QWidget
        @type on_sys_msg: bool
        @param on_sys_msg: If True, a pane that accommodates str messages will
                           appear in the plugin's region.
        @param on_sysprogress_bar: If True, a progress bar will appear in the
                                   plugin's region.
        """
        super(PluginContainerWidget, self).__init__()

        self._logger = rclpy.logging.get_logger('PluginContainerWidget')
        _, package_path = get_resource('packages', 'rqt_py_common')
        ui_file = os.path.join(package_path, 'share', 'rqt_py_common',
                               'resource', 'plugin_container.ui')

        loadUi(ui_file, self)

        self._plugin_widget = plugin_widget
        self._splitter.insertWidget(0, self._plugin_widget)
        self.setWindowTitle(self._plugin_widget.windowTitle())

        # Default is on for these sys status widgets. Only if the flag for them
        # are 'False', hide them.
        if on_sys_msg:
            self._plugin_widget.sig_sysmsg.connect(self.set_sysmsg)
        else:
            self._sysmsg_widget.hide()

        if on_sysprogress_bar:
            self._plugin_widget.sig_sysprogress.connect(self.set_sysprogress)
        else:
            self._sysprogress_bar.hide()
Example #18
0
    def __init__(self, context):
        super(HandEyeCalibration, self).__init__(context)
        self.context = context
        self.node = context.node
        self.widget = QWidget()
        self.widget.setObjectName(self.PLUGIN_TITLE)
        self.widget.setWindowTitle(self.PLUGIN_TITLE)

        # Data
        self.Tsamples = []

        # Toolbar
        _, path_pkg = get_resource('packages', 'handeye_dashboard')
        print("{}".format(path_pkg))

        self.snapshot_action = QAction(QIcon.fromTheme('camera-photo'),
                                       'Take a snapshot', self.widget)
        path = path_pkg + '/share/handeye_dashboard/images/capture.png'
        self.calibrate_action = QAction(QIcon(QPixmap.fromImage(QImage(path))),
                                        'Get the camera/robot transform',
                                        self.widget)
        self.clear_action = QAction(QIcon.fromTheme('edit-clear'),
                                    'Clear the record data.', self.widget)
        path = path_pkg + '/share/handeye_dashboard/images/UR5.png'
        self.execut_action = QAction(QIcon(QPixmap.fromImage(QImage(path))),
                                     'EStart the publishing the TF.',
                                     self.widget)
        self.toolbar = QToolBar()
        self.toolbar.addAction(self.snapshot_action)
        self.toolbar.addAction(self.calibrate_action)
        self.toolbar.addAction(self.clear_action)
        self.toolbar.addAction(self.execut_action)

        # Toolbar0
        self.l0 = QLabel(self.widget)
        self.l0.setText("Camera-Mount-Type: ")
        self.l0.setFixedWidth(150)
        self.l0.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.combobox = QComboBox(self.widget)
        self.combobox.addItem('attached on robot')
        self.combobox.addItem('fixed beside robot')
        self.toolbar0 = QToolBar()
        self.toolbar0.addWidget(self.l0)
        self.toolbar0.addWidget(self.combobox)

        # Toolbar1
        self.l1 = QLabel(self.widget)
        self.l1.setText("Camera-Frame: ")
        self.l1.setFixedWidth(150)
        self.l1.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.camera_frame = QLineEdit(self.widget)
        self.camera_frame.setText("camera_link")
        self.toolbar1 = QToolBar()
        self.toolbar1.addWidget(self.l1)
        self.toolbar1.addWidget(self.camera_frame)

        # Toolbar2
        self.l2 = QLabel(self.widget)
        self.l2.setText("Object-Frame: ")
        self.l2.setFixedWidth(150)
        self.l2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.object_frame = QLineEdit(self.widget)
        self.object_frame.setText("calib_board")
        self.toolbar2 = QToolBar()
        self.toolbar2.addWidget(self.l2)
        self.toolbar2.addWidget(self.object_frame)

        # Toolbar3
        self.l3 = QLabel(self.widget)
        self.l3.setText("Robot-Base-Frame: ")
        self.l3.setFixedWidth(150)
        self.l3.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.base_frame = QLineEdit(self.widget)
        self.base_frame.setText("base")
        self.toolbar3 = QToolBar()
        self.toolbar3.addWidget(self.l3)
        self.toolbar3.addWidget(self.base_frame)

        # Toolbar4
        self.l4 = QLabel(self.widget)
        self.l4.setText("End-Effector-Frame: ")
        self.l4.setFixedWidth(150)
        self.l4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.endeffector_frame = QLineEdit(self.widget)
        self.endeffector_frame.setText("tool0")
        self.toolbar4 = QToolBar()
        self.toolbar4.addWidget(self.l4)
        self.toolbar4.addWidget(self.endeffector_frame)

        # Toolbar5
        self.l5 = QLabel(self.widget)
        self.l5.setText("Sample-Number: ")
        self.l5.setFixedWidth(150)
        self.l5.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.le5 = QLineEdit(self.widget)
        self.le5.setValidator(QIntValidator())
        self.le5.setText('10')
        self.le5.setReadOnly(True)
        self.toolbar5 = QToolBar()
        self.toolbar5.addWidget(self.l5)
        self.toolbar5.addWidget(self.le5)

        # TreeView
        self.treeview = QTreeView()
        self.treeview.setAlternatingRowColors(True)
        self.model = QStandardItemModel(self.treeview)
        self.treeview.setModel(self.model)
        self.treeview.setHeaderHidden(True)

        # TextEdit
        self.textedit = QTextEdit(self.widget)
        self.textedit.setReadOnly(True)

        # Layout
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.toolbar0)
        self.layout.addWidget(self.toolbar1)
        self.layout.addWidget(self.toolbar2)
        self.layout.addWidget(self.toolbar3)
        self.layout.addWidget(self.toolbar4)
        self.layout.addWidget(self.toolbar5)
        self.layout.addWidget(self.toolbar)
        self.layoutH = QHBoxLayout()
        self.layoutH.addWidget(self.treeview)
        self.layoutH.addWidget(self.textedit)
        self.layout.addLayout(self.layoutH)
        self.widget.setLayout(self.layout)
        # Add the widget to the user interface
        if context.serial_number() > 1:
            self.widget.setWindowTitle(self.widget.windowTitle() +
                                       (' (%d)' % context.serial_number()))
        context.add_widget(self.widget)
        # Make the connections
        self.snapshot_action.triggered.connect(self.take_snapshot)
        self.calibrate_action.triggered.connect(self.calibration)
        self.clear_action.triggered.connect(self.clear)
        self.execut_action.triggered.connect(self.execution)

        # Package path
        self.path_pkg = path_pkg

        # Set up TF
        self.cli = self.node.create_client(HandeyeTF, 'handeye_tf_service')
        while not self.cli.wait_for_service(timeout_sec=1.0):
            self.node.get_logger().info(
                'service not available, waiting again...')
        self.req = HandeyeTF.Request()
Example #19
0
    def __init__(self, proxy_model, minimal=False):
        """
        :param proxymodel: the proxy model to display in the widget,''QSortFilterProxyModel''
        :param minimal: if true the load, save and column buttons will be hidden as well as the
                        filter splitter, ''bool''
        """
        super(ConsoleWidget, self).__init__()
        self._proxy_model = proxy_model
        self._model = self._proxy_model.sourceModel()
        self._paused = False

        # These are lists of Tuples = (,)
        self._exclude_filters = []
        self._highlight_filters = []

        pkg_name = 'rqt_console'
        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               'console_widget.ui')

        loadUi(ui_file, self)

        if minimal:
            self.load_button.hide()
            self.save_button.hide()
            self.column_resize_button.hide()
        self.setObjectName('ConsoleWidget')
        self.table_view.setModel(proxy_model)

        self._columnwidth = (60, 100, 70, 100, 100, 100, 100)
        for idx, width in enumerate(self._columnwidth):
            self.table_view.horizontalHeader().resizeSection(idx, width)
        try:
            setSectionResizeMode = self.table_view.horizontalHeader(
            ).setSectionResizeMode  # Qt5
        except AttributeError:
            setSectionResizeMode = self.table_view.horizontalHeader(
            ).setResizeMode  # Qt4
        setSectionResizeMode(1, QHeaderView.Stretch)

        def update_sort_indicator(logical_index, order):
            if logical_index == 0:
                self._proxy_model.sort(-1)
            self.table_view.horizontalHeader().setSortIndicatorShown(
                logical_index != 0)

        self.table_view.horizontalHeader().sortIndicatorChanged.connect(
            update_sort_indicator)

        self.add_exclude_button.setIcon(QIcon.fromTheme('list-add'))
        self.add_highlight_button.setIcon(QIcon.fromTheme('list-add'))
        self.pause_button.setIcon(QIcon.fromTheme('media-playback-pause'))
        if not self.pause_button.icon().isNull():
            self.pause_button.setText('')
        self.record_button.setIcon(QIcon.fromTheme('media-record'))
        if not self.record_button.icon().isNull():
            self.record_button.setText('')
        self.load_button.setIcon(QIcon.fromTheme('document-open'))
        if not self.load_button.icon().isNull():
            self.load_button.setText('')
        self.save_button.setIcon(QIcon.fromTheme('document-save'))
        if not self.save_button.icon().isNull():
            self.save_button.setText('')
        self.clear_button.setIcon(QIcon.fromTheme('edit-clear'))
        if not self.clear_button.icon().isNull():
            self.clear_button.setText('')
        self.highlight_exclude_button.setIcon(
            QIcon.fromTheme('format-text-strikethrough'))

        self.pause_button.clicked[bool].connect(self._handle_pause_clicked)
        self.record_button.clicked[bool].connect(self._handle_record_clicked)
        self.load_button.clicked[bool].connect(self._handle_load_clicked)
        self.save_button.clicked[bool].connect(self._handle_save_clicked)
        self.column_resize_button.clicked[bool].connect(
            self._handle_column_resize_clicked)
        self.clear_button.clicked[bool].connect(
            self._handle_clear_button_clicked)

        self.table_view.mouseDoubleClickEvent = self._handle_mouse_double_click
        self.table_view.mousePressEvent = self._handle_mouse_press
        self.table_view.keyPressEvent = self._handle_custom_keypress

        self.highlight_exclude_button.clicked[bool].connect(
            self._proxy_model.set_show_highlighted_only)

        self.add_highlight_button.clicked.connect(self._add_highlight_filter)
        self.add_exclude_button.clicked.connect(self._add_exclude_filter)

        # Filter factory dictionary:
        # index 0 is a label describing the widget, index 1 is the class that
        # provides filtering logic index 2 is the widget that sets the data in the
        # filter class, index 3 are the arguments for the widget class constructor
        self._filter_factory_order = [
            'message', 'severity', 'node', 'time', 'topic', 'location',
            'custom'
        ]
        self.filter_factory = {
            'message':
            (self.tr('...containing'), MessageFilter, TextFilterWidget),
            'severity': (self.tr('...with severities'), SeverityFilter,
                         ListFilterWidget, self._model.get_severity_dict),
            'node': (self.tr('...from node'), NodeFilter, ListFilterWidget,
                     self._model.get_unique_nodes),
            'time': (self.tr('...from time range'), TimeFilter,
                     TimeFilterWidget, self.get_time_range_from_selection),
            'topic': (self.tr('...from topic'), TopicFilter, ListFilterWidget,
                      self._model.get_unique_topics),
            'location':
            (self.tr('...from location'), LocationFilter, TextFilterWidget),
            'custom': (self.tr('Custom'), CustomFilter, CustomFilterWidget, [
                self._model.get_severity_dict, self._model.get_unique_nodes,
                self._model.get_unique_topics
            ])
        }

        self._model.rowsInserted.connect(self.update_status)
        self._model.rowsRemoved.connect(self.update_status)
        self._proxy_model.rowsInserted.connect(self.update_status)
        self._proxy_model.rowsRemoved.connect(self.update_status)

        # list of TextBrowserDialogs to close when cleaning up
        self._browsers = []

        # This defaults the filters panel to start by taking 50% of the available space
        if minimal:
            self.table_splitter.setSizes([1, 0])
        else:
            self.table_splitter.setSizes([1, 1])
        self.exclude_table.resizeColumnsToContents()
        self.highlight_table.resizeColumnsToContents()
Example #20
0
            if self._options.standalone_plugin:
                # use icon of standalone plugin (if available) for application
                plugin_descriptor = plugin_manager.get_plugin_descriptor(
                    plugin)
                action_attributes = plugin_descriptor.action_attributes()
                if 'icon' in action_attributes and action_attributes[
                        'icon'] is not None:
                    base_path = plugin_descriptor.attributes().get(
                        'plugin_path')
                    try:
                        icon = get_icon(
                            action_attributes['icon'],
                            action_attributes.get('icontype', None), base_path)
                    except UserWarning:
                        pass
                    else:
                        app.setWindowIcon(icon)

        if main_window is not None:
            main_window.show()
            if sys.platform == 'darwin':
                main_window.raise_()

        return app.exec_()


if __name__ == '__main__':
    _, qtgui_path = get_resource('packages', 'qt_gui')
    main = Main(qtgui_path)
    sys.exit(main.main())
Example #21
0
def get_package_path(name):
    """Determine the path of a ROS package using rospkg."""
    from ament_index_python.resources import get_resource
    _, package_path = get_resource('packages', name)
    return package_path
    def __init__(self, node):
        super(ExamplesWidget, self).__init__()
        self.setObjectName('ExamplesWidget')

        self.node = node

        self.REDRAW_INTERVAL = 30
        self.PUBLISH_INTERVAL = 100
        self.CMD_VEL_X_FACTOR = 1000.0
        self.CMD_VEL_YAW_FACTOR = -10.0

        pkg_name = 'rqt_example'
        ui_filename = 'rqt_example.ui'
        topic_name = 'cmd_vel'
        service_name = 'led_control'

        _, package_path = get_resource('packages', pkg_name)
        ui_file = os.path.join(package_path, 'share', pkg_name, 'resource',
                               ui_filename)
        loadUi(ui_file, self)

        self.pub_velocity = Twist()
        self.pub_velocity.linear.x = 0.0
        self.pub_velocity.angular.z = 0.0
        self.sub_velocity = Twist()
        self.sub_velocity.linear.x = 0.0
        self.sub_velocity.angular.z = 0.0

        self.slider_x.setValue(0)
        self.lcd_number_x.display(0.0)
        self.lcd_number_yaw.display(0.0)

        qos = QoSProfile(depth=10)
        self.publisher = self.node.create_publisher(Twist, topic_name, qos)
        self.subscriber = self.node.create_subscription(
            Twist, topic_name, self.get_velocity, qos)
        self.service_server = self.node.create_service(SetBool, service_name,
                                                       self.set_led_status)
        self.service_client = self.node.create_client(SetBool, service_name)

        self.publish_timer = QTimer(self)
        self.publish_timer.timeout.connect(self.send_velocity)
        self.publish_timer.start(self.PUBLISH_INTERVAL)

        self.update_timer = QTimer(self)
        self.update_timer.timeout.connect(self.update_indicators)
        self.update_timer.start(self.REDRAW_INTERVAL)

        self.push_button_w.pressed.connect(self.increase_linear_x)
        self.push_button_x.pressed.connect(self.decrease_linear_x)
        self.push_button_a.pressed.connect(self.increase_angular_z)
        self.push_button_d.pressed.connect(self.decrease_angular_z)
        self.push_button_s.pressed.connect(self.set_stop)

        self.push_button_w.setShortcut('w')
        self.push_button_x.setShortcut('x')
        self.push_button_a.setShortcut('a')
        self.push_button_d.setShortcut('d')
        self.push_button_s.setShortcut('s')

        self.shortcut_space = QShortcut(QKeySequence(Qt.Key_Space), self)
        self.shortcut_space.setContext(Qt.ApplicationShortcut)
        self.shortcut_space.activated.connect(self.push_button_s.pressed)

        self.radio_button_led_on.clicked.connect(self.call_led_service)
        self.radio_button_led_off.clicked.connect(self.call_led_service)

        self.radio_button_led_on.setShortcut('o')
        self.radio_button_led_off.setShortcut('f')