def _update_state(self, state):
     if self._stale:
         self.setPixmap(self._icons[-1].pixmap(QSize(60, 100)))
     elif self._charging:
         self.setPixmap(self._charge_icons[state].pixmap(QSize(60, 100)))
     else:
         self.setPixmap(self._icons[state].pixmap(QSize(60, 100)))
    def updateCapabilities(self, masteruri, cfg_name, description):
        '''
        Updates the capabilities view.
        @param masteruri: the ROS master URI of updated ROS master.
        @type masteruri: C{str}
        @param cfg_name: The name of the node provided the capabilities description.
        @type cfg_name: C{str}
        @param description: The capabilities description object.
        @type description: U{multimaster_msgs_fkie.srv.ListDescription<http://docs.ros.org/api/multimaster_msgs_fkie/html/srv/ListDescription.html>} Response
        '''
        # if it is a new masteruri add a new column
        robot_index = self._robotHeader.index(masteruri)
        robot_name = description.robot_name if description.robot_name else nm.nameres().mastername(masteruri)
        # append a new robot
        new_robot = False
        if robot_index == -1:
            robot_index = self._robotHeader.insertSortedItem(masteruri, robot_name)
            self.insertColumn(robot_index)
#      robot_index = self.columnCount()-1
#      self._robotHeader.insertItem(robot_index)
            self._robotHeader.setDescription(robot_index, cfg_name, masteruri, robot_name, description.robot_type, description.robot_descr.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), description.robot_images)
            item = QTableWidgetItem()
            item.setSizeHint(QSize(96, 96))
            self.setHorizontalHeaderItem(robot_index, item)
            self.horizontalHeaderItem(robot_index).setText(robot_name)
            new_robot = True
        else:
            # update
            self._robotHeader.setDescription(robot_index, cfg_name, masteruri, robot_name, description.robot_type, description.robot_descr.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), description.robot_images)

        # set the capabilities
        for c in description.capabilities:
            cap_index = self._capabilityHeader.index(c.name.decode(sys.getfilesystemencoding()))
            if cap_index == -1 or new_robot:
                if cap_index == -1:
                    # append a new capability
                    cap_index = self._capabilityHeader.insertSortedItem(c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()))
                    self.insertRow(cap_index)
                    self.setRowHeight(cap_index, 96)
                    self._capabilityHeader.setDescription(cap_index, cfg_name, c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()), c.type, c.description.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), c.images)
                    item = QTableWidgetItem()
                    item.setSizeHint(QSize(96, 96))
                    self.setVerticalHeaderItem(cap_index, item)
                    self.verticalHeaderItem(cap_index).setText(c.name.decode(sys.getfilesystemencoding()))
                else:
                    self._capabilityHeader.setDescription(cap_index, cfg_name, c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()), c.type, c.description.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), c.images)
                # add the capability control widget
                controlWidget = CapabilityControlWidget(masteruri, cfg_name, c.namespace, c.nodes)
                controlWidget.start_nodes_signal.connect(self._start_nodes)
                controlWidget.stop_nodes_signal.connect(self._stop_nodes)
                self.setCellWidget(cap_index, robot_index, controlWidget)
                self._capabilityHeader.controlWidget.insert(cap_index, controlWidget)
            else:
                self._capabilityHeader.updateDescription(cap_index, cfg_name, c.name.decode(sys.getfilesystemencoding()), c.name.decode(sys.getfilesystemencoding()), c.type, c.description.replace("\\n ", "\n").decode(sys.getfilesystemencoding()), c.images)
                try:
                    self.cellWidget(cap_index, robot_index).updateNodes(cfg_name, c.namespace, c.nodes)
                except:
                    import traceback
                    print traceback.format_exc()
예제 #3
0
    def create_button(
        self,
        name: str,
        callback: Optional[Union[str, Callable]] = None,
        image_path: Optional[str] = None,
        size: Tuple[int, int] = (125, 140),
        always_enabled: bool = False,
    ):
        """Create a push button which can be pressed to execute a gait instruction.

        :param name:
            Name of the button
        :param callback:
            The callback to attach to the button when pressed
        :param image_path:
            The name of the image file
        :param size:
            Default size of the button
        :param always_enabled:
            Never disable the button if it's not in possible gaits

        :return:
            A QPushButton object which contains the passed arguments
        """
        qt_button = QToolButton()
        qt_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        qt_button.setStyleSheet(
            "QToolButton {background-color: lightgrey; "
            "font-size: 13px;"
            "font: 'Times New Roman'}"
        )
        qt_button.setIconSize(QSize(90, 90))
        qt_button.setText(check_string(name))
        if image_path is not None:
            qt_button.setIcon(QIcon(QPixmap(get_image_path(image_path))))
        elif name + ".png" in self._image_names:
            qt_button.setIcon(QIcon(QPixmap(get_image_path(name))))
        qt_button.setObjectName(name)

        if always_enabled:
            self._always_enabled_buttons.append(name)
            qt_button.setEnabled(True)

        qt_button.setMinimumSize(QSize(*size))
        qt_button.setMaximumSize(QSize(*size))

        if callback is not None:
            if callable(callback):
                qt_button.clicked.connect(callback)
            else:
                qt_button.clicked.connect(getattr(self._controller, callback))
        else:
            qt_button.clicked.connect(lambda: self._controller.publish_gait(name))

        return qt_button
    def setup(self, context):
        self.name = 'Youbot Dashboard'
        self.max_icon_size = QSize(50, 30)
        self.message = None

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0

        self._raw_byte = None
        self.digital_outs = [0, 0, 0]

        self._console = ConsoleDashWidget(self.context, minimal=False)
        self._monitor = MonitorDashWidget(self.context)
        self._base_motors = YoubotMotors("base",
                                         self.on_base_motors_on_clicked,
                                         self.on_base_motors_off_clicked)
        self._arm_1_motors = YoubotMotors("arm",
                                          self.on_arm_1_motors_on_clicked,
                                          self.on_arm_1_motors_off_clicked)

        self._ethercat = YoubotEthercat('EtherCAT', self.on_reconnect_clicked)
        self._batteries = [PR2Battery(self.context)]

        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg',
                                                   DashboardState,
                                                   self.dashboard_callback)
예제 #5
0
    def _init_widget(self):
        self._init_icon_paths()

        self.setObjectName('Remocon')
        self._widget_main = QWidget()

        rospack = rospkg.RosPack()
        path = os.path.join(rospack.get_path('rocon_remocon'), 'ui',
                            'remocon.ui')
        loadUi(path, self._widget_main)

        # main widget
        self._widget_main.list_widget.setIconSize(QSize(50, 50))
        self._widget_main.list_widget.itemDoubleClicked.connect(
            self._connect_rocon_master)  # list item double click event
        self._widget_main.list_widget.itemClicked.connect(
            self._select_rocon_master)  # list item double click event

        self._widget_main.add_concert_btn.pressed.connect(
            self._set_add_rocon_master)  # add button event
        self._widget_main.delete_btn.pressed.connect(
            self._delete_rocon_master)  # delete button event
        self._widget_main.delete_all_btn.pressed.connect(
            self._delete_all_rocon_masters)  # delete all button event
        self._widget_main.refresh_btn.pressed.connect(
            self._refresh_all_rocon_master_list)  # refresh all button event

        self._widget_main.list_info_widget.clear()
예제 #6
0
    def setup(self, context):
        self.name = 'Batteries Dashboard'
        self.max_icon_size = QSize(50, 30)

        self._last_dashboard_message_time = rospy.Time.now()
        self._widget_initialized = False

        self.rate = rospy.get_param('~rate', 1.0)

        self._batteries = dict()

        rospy.loginfo(
            'Subscribed to \'{}battery_states\' for battery status'.format(
                rospy.get_namespace()))
        self._sub = rospy.Subscriber('battery_states',
                                     BatteryState,
                                     self.dashboard_callback,
                                     queue_size=5)

        self._sig_add_battery.connect(self._add_batteries)
        self._sig_remove_battery.connect(self._remove_batteries)

        self._running = True
        Thread(target=self.check_outdated).start()

        self._widget_initialized = True
예제 #7
0
    def __init__(self, context, icon_paths=None, minimal=True):
        ok_icon = ['bg-green.svg', 'ic-console.svg']
        warn_icon = ['bg-yellow.svg', 'ic-console.svg', 'ol-warn-badge.svg']
        err_icon = ['bg-red.svg', 'ic-console.svg', 'ol-err-badge.svg']
        stale_icon = ['bg-grey.svg', 'ic-console.svg', 'ol-stale-badge.svg']

        icons = [ok_icon, warn_icon, err_icon, stale_icon]

        super(ConsoleDashWidget, self).__init__('Console Widget', icons, icon_paths=icon_paths)

        self.minimal = minimal
        self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))

        self._datamodel = MessageDataModel()
        self._proxymodel = MessageProxyModel()
        self._proxymodel.setSourceModel(self._datamodel)

        self._mutex = QMutex()
        self._subscriber = ConsoleSubscriber(self._message_cb)

        self._console = None
        self.context = context
        self.clicked.connect(self._show_console)

        self.update_state(0)
        self._timer = QTimer()
        self._timer.timeout.connect(self._insert_messages)
        self._timer.start(100)

        if self._console is None:
            self._console = ConsoleWidget(self._proxymodel, self.minimal)
            self._console.destroyed.connect(self._console_destroyed)
        self._console_shown = False
        self.setToolTip("Rosout")
예제 #8
0
    def setup(self, context):
        self.name = 'Scitos Dashboard'
        self.max_icon_size = QSize(50, 30)
        self.message = None

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0

        self._raw_byte = None
        self.digital_outs = [0, 0, 0]

        self._console = ConsoleDashWidget(self.context, minimal=False)
        self._monitor = MonitorDashWidget(self.context)
        self._mileage = ScitosMileage()

        self._drive = ScitosDrive(self.reset_motorstop_cb, self.freerun_cb,
                                  self.enable_motorstop_cb)

        self._batteries = ScitosBattery()
        self._freerun_state = True

        self._motor_state_sub = rospy.Subscriber('/motor_status', MotorStatus,
                                                 self.motor_status_callback)
        self._battery_state_sub = rospy.Subscriber('/battery_state',
                                                   BatteryState,
                                                   self.battery_callback)
        self._mileage_sub = rospy.Subscriber('/mileage', Float32,
                                             self.mileage_callback)
        self._motor_stale_timer = Timer(0, self._drive.set_stale)
        self._motor_stale_timer.start()
        self._battery_stale_timer = Timer(0, self._batteries.set_stale)
        self._battery_stale_timer.start()
        self._mileage_stale_timer = Timer(0, self._mileage.set_stale)
        self._mileage_stale_timer.start()
예제 #9
0
	def sizeHint(self, option, index):
		item = self.parent().item(index.row())
		doc = QTextDocument()
		# highlight = syntax.PythonHighlighter(doc, is_dark = not item.has_script)

		font = QFont("Courier")
		font.setFamily("Courier");
		font.setStyleHint(QFont.Monospace);
		font.setFixedPitch(True);
		font.setPointSize(self.parent().font().pointSize());
		doc.setDefaultFont(font)

		# tab_stop = 4;  # 4 characters
		# metrics = QFontMetrics(font)

		text = index.data(Qt.EditRole)
	
		text = text.replace("\t", ''.join([' '] * 4))

		# print ":".join("{:02x}".format(ord(c)) for c in text)

		doc.setPlainText(text)

		doc.setDefaultStyleSheet("background-color: red;")

		return QSize(doc.size().width(), doc.size().height())
예제 #10
0
	def sizeHint(self):
		if not self.is_resizable:
			return super(QLabel, self).sizeHint()

		doc = QTextDocument()
		# highlight = syntax.PythonHighlighter(doc, is_dark = True)



		font = self.font()
		# font.setFamily("Courier");	
		font.setStyleHint(QFont.Monospace);
		font.setFixedPitch(True);
		# font.setPointSize(self.font().pointSize());
		doc.setDefaultFont(font)

		text = self.text()
		# doc.setTextWidth(self.width())

		doc.setPlainText(text)

		size = QSize(doc.size().width(), doc.size().height())

		if size != None:
			
			return size

		return super(QLabel, self).sizeHint()
예제 #11
0
    def setup(self, context):
        self.name = 'PR2 Dashboard'
        self.max_icon_size = QSize(50, 30)
        self.message = None

        parser = argparse.ArgumentParser(prog='pr2_dashboard', add_help=False)
        PR2Dashboard.add_arguments(parser)
        args = parser.parse_args(context.argv())
        self._motor_namespace = args.motor_namespace

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0

        self._raw_byte = None
        self.digital_outs = [0, 0, 0]

        self._console = ConsoleDashWidget(self.context, minimal=False)
        self._monitor = MonitorDashWidget(self.context)
        self._motors = PR2Motors(self.on_reset_motors, self.on_halt_motors)
        self._breakers = [
            PR2BreakerButton('Left Arm', 0),
            PR2BreakerButton('Base', 1),
            PR2BreakerButton('Right Arm', 2)
        ]

        self._runstop = PR2Runstops('RunStops')
        self._batteries = [PR2Battery(self.context)]

        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg',
                                                   DashboardState,
                                                   self.dashboard_callback)
예제 #12
0
    def __init__(self, reset_motorstop_cb, freerun_cb, enable_motorstop_cb):
        ok_icon = ['bg-green.svg', 'ic-motors.svg']
        free_run_icon = ['bg-yellow.svg', 'ic-motors.svg']
        free_run_icon_halted = [
            'bg-yellow.svg', 'ic-motors.svg', 'ol-warn-badge.svg'
        ]
        err_icon = ['bg-red.svg', 'ic-motors.svg', 'ol-err-badge.svg']
        stale_icon = ['bg-grey.svg', 'ic-motors.svg', 'ol-stale-badge.svg']
        hardstop_icon = ['bg-red.svg', 'ic-hardstop.svg', 'ol-stale-badge.svg']

        icons = [
            ok_icon, free_run_icon, free_run_icon_halted, err_icon, stale_icon,
            hardstop_icon
        ]
        super(ScitosDrive,
              self).__init__('Drive',
                             icons,
                             icon_paths=[['scitos_dashboard', 'images']])
        self.update_state(5)

        self.add_action('Reset Motors Stop', reset_motorstop_cb)
        self.add_action('Toggle Free Run', freerun_cb)
        self.add_action('Halt', enable_motorstop_cb)
        self.setToolTip('Drive System')

        self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))
예제 #13
0
    def __init__(self):
        self._ok_icon = [
            path.join(roslib.packages.get_pkg_dir('rqt_youbot_dashboard'),
                      "icons/arm-tuck-green.png")
        ]
        self._not_ok_icon = [
            path.join(roslib.packages.get_pkg_dir('rqt_youbot_dashboard'),
                      "icons/arm-tuck-grey.png")
        ]

        icons = [self._ok_icon, self._not_ok_icon]
        super(ArmTuckWidget, self).__init__('', icons=icons)
        self.setFixedSize(QSize(40, 40))
        self.update_state(0)

        self.setToolTip("Tuck arm")

        self.clicked.connect(self.toggle)
        self._srv_arm = None

        try:
            rospy.wait_for_service('/tuck_arm', 1)
            self._srv_arm = rospy.ServiceProxy('/tuck_arm', Empty)
            self.update_state(0)
            self._arm_ok = True
        except rospy.ROSException, e:
            rospy.logwarn("/tuck_arm service unavailable")
            self.update_state(1)
            self._arm_ok = False
예제 #14
0
    def __init__(self):
        self._ok_icon = [
            path.join(roslib.packages.get_pkg_dir('rqt_youbot_dashboard'),
                      "icons/costmap-green.png")
        ]
        self._not_ok_icon = [
            path.join(roslib.packages.get_pkg_dir('rqt_youbot_dashboard'),
                      "icons/costmap-grey.png")
        ]

        icons = [self._ok_icon, self._not_ok_icon]
        super(ClearCostmapWidget, self).__init__('', icons=icons)
        self.setFixedSize(QSize(40, 40))

        self.setToolTip("Clear costmap")

        self.clicked.connect(self.toggle)

        try:
            rospy.wait_for_service('/move_base_node/clear_costmaps', 1)
            self._srv_costmap = rospy.ServiceProxy(
                '/move_base_node/clear_costmaps', Empty)
            self.update_state(0)
            self._costmap_ok = True
        except rospy.ROSException, e:
            rospy.logwarn("move base not running yet, can't clear costmap")
            self.update_state(1)
            self._costmap_ok = False
예제 #15
0
파일: dashboard.py 프로젝트: daju1-ros/rqt
    def __init__(self, context):
        super(Dashboard, self).__init__(context)
        self.context = context
        self.setup(context)

        if not hasattr(self, 'name'):
            self.name = 'Dashboard'
        if not hasattr(self, 'max_icon_size'):
            self.max_icon_size = QSize(50, 30)
        self._main_widget = QToolBar()
        self._main_widget.setIconSize(self.max_icon_size)
        self._main_widget.setObjectName(self.name)
        self._main_widget.setWindowTitle(self.name)
        if context.serial_number() > 1:
            self._main_widget.setWindowTitle(self._main_widget.windowTitle() +
                                             (' (%d)' %
                                              context.serial_number()))
        widgets = self.get_widgets()

        self._widgets = []
        for v in widgets:
            for i in v:
                try:
                    self._main_widget.addWidget(i)
                    self._widgets.append(i)
                except:
                    raise Exception(
                        "All widgets must be a subclass of QWidget!")

            self._main_widget.addSeparator()

        # Display the dashboard
        context.add_toolbar(self._main_widget)
예제 #16
0
    def __init__(self, updater, config, nodename):
        """
        :param config:
        :type config: Dictionary? defined in dynamic_reconfigure.client.Client
        :type nodename: str
        """
        super(GroupWidget, self).__init__()
        self.state = config['state']
        self.param_name = config['name']
        self._toplevel_treenode_name = nodename

        # TODO: .ui file needs to be back into usage in later phase.
        #        ui_file = os.path.join(rp.get_path('rqt_reconfigure'),
        #                               'resource', 'singlenode_parameditor.ui')
        #        loadUi(ui_file, self)

        verticalLayout = QVBoxLayout(self)
        verticalLayout.setContentsMargins(QMargins(0, 0, 0, 0))

        _widget_nodeheader = QWidget()
        _h_layout_nodeheader = QHBoxLayout(_widget_nodeheader)
        _h_layout_nodeheader.setContentsMargins(QMargins(0, 0, 0, 0))

        self.nodename_qlabel = QLabel(self)
        font = QFont('Trebuchet MS, Bold')
        font.setUnderline(True)
        font.setBold(True)

        # Button to close a node.
        _icon_disable_node = QIcon.fromTheme('window-close')
        _bt_disable_node = QPushButton(_icon_disable_node, '', self)
        _bt_disable_node.setToolTip('Hide this node')
        _bt_disable_node_size = QSize(36, 24)
        _bt_disable_node.setFixedSize(_bt_disable_node_size)
        _bt_disable_node.pressed.connect(self._node_disable_bt_clicked)

        _h_layout_nodeheader.addWidget(self.nodename_qlabel)
        _h_layout_nodeheader.addWidget(_bt_disable_node)

        self.nodename_qlabel.setAlignment(Qt.AlignCenter)
        font.setPointSize(10)
        self.nodename_qlabel.setFont(font)
        grid_widget = QWidget(self)
        self.grid = QFormLayout(grid_widget)
        verticalLayout.addWidget(_widget_nodeheader)
        verticalLayout.addWidget(grid_widget, 1)
        # Again, these UI operation above needs to happen in .ui file.

        self.tab_bar = None  # Every group can have one tab bar
        self.tab_bar_shown = False

        self.updater = updater

        self.editor_widgets = []
        self._param_names = []

        self._create_node_widgets(config)

        logging.debug('Groups node name={}'.format(nodename))
        self.nodename_qlabel.setText(nodename)
예제 #17
0
    def __init__(self):
        icons_path = path.join(
            roslib.packages.get_pkg_dir('rqt_youbot_dashboard'), "icons/")

        self._ok_icon = [icons_path + 'nav-green.png']
        self._not_ok_icon = [icons_path + 'nav-grey.png']

        icons = [self._ok_icon, self._not_ok_icon]
        super(LocationWidget, self).__init__('', icons=icons)
        self.setFixedSize(QSize(40, 40))

        self.add_action('Save current location',
                        partial(self.save_current_location))
        self.add_action('Delete location', partial(self.delete_location))
        self.add_action('Show locations', partial(self.show_locations))

        self.setToolTip("Locations")
        self._srv_store_location = None
        self._srv_delete_location = None
        self._srv_get_location = None
        try:
            rospy.wait_for_service('location_service/store_location', 1)
            self._srv_store_location = rospy.ServiceProxy(
                'location_service/store_location', StoreLocation)
            self._srv_delete_location = rospy.ServiceProxy(
                'location_service/delete_location', DeleteLocation)
            self._srv_get_location = rospy.ServiceProxy(
                'location_service/get_location', GetLocation)
            self.update_state(0)
            self._location_ok = True
        except rospy.ROSException, e:
            rospy.logwarn("location service unavailable")
            self.update_state(1)
            self._location_ok = False
    def __init__(self, parent=None, logger=Logger()):
        QWidgetWithLogger.__init__(self, parent, logger)

        # start widget
        hbox = QHBoxLayout()
        hbox.setMargin(0)
        hbox.setContentsMargins(0, 0, 0, 0)

        # get system icon
        icon = QIcon.fromTheme("view-refresh")
        size = icon.actualSize(QSize(32, 32))

        # add combo box
        self.parameter_set_names_combo_box = QComboBox()
        self.parameter_set_names_combo_box.currentIndexChanged[str].connect(
            self.param_changed)
        hbox.addWidget(self.parameter_set_names_combo_box)

        # add refresh button
        self.get_all_parameter_set_names_button = QPushButton()
        self.get_all_parameter_set_names_button.clicked.connect(
            self._get_all_parameter_set_names)

        self.get_all_parameter_set_names_button.setIcon(icon)
        self.get_all_parameter_set_names_button.setFixedSize(
            size.width() + 2,
            size.height() + 2)

        hbox.addWidget(self.get_all_parameter_set_names_button)

        # end widget
        self.setLayout(hbox)

        # init widget
        self.reset_parameter_set_selection()
예제 #19
0
    def __init__(self, location_file, map, widget, subfunction_layout,
                 configuration_layout, image):

        self.edit_area_button = None
        self.edit_area_selection_color = Qt.black

        # Dictionary of polygons
        self.locations = {}
        # Dictionary that maps location names to their colors
        self.location_colors = {}
        self.draw_location = {}
        self.unique_loc_counter = 1

        self.editing_area = False
        self.edit_existing_location = None

        self.editing_properties = False
        self.edit_properties_location = None

        # Use this to initialize variables.
        self.clearAreaSelection()

        self.is_modified = False

        self.widget = widget
        self.subfunction_layout = subfunction_layout
        self.image = image
        self.image_size = image.overlay_image.size()
        self.configuration_layout = configuration_layout

        self.location_file = location_file
        self.map_size = QSize(map.map.info.width, map.map.info.height)
        self.readLocationsFromFile()

        self.edit_area_button = {}
예제 #20
0
    def setup(self, context):
        self.name = 'PR2 Dashboard'
        self.max_icon_size = QSize(50, 30)
        self.message = None

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0

        self._raw_byte = None
        self.digital_outs = [0, 0, 0]

        self._console = ConsoleDashWidget(self.context, minimal=False)
        self._monitor = MonitorDashWidget(self.context)
        self._motors = PR2Motors(self.on_reset_motors, self.on_halt_motors)
        self._breakers = [
            PR2BreakerButton('Left Arm', 0),
            PR2BreakerButton('Base', 1),
            PR2BreakerButton('Right Arm', 2)
        ]

        self._runstop = PR2Runstops('RunStops')
        self._batteries = [PR2Battery(self.context)]

        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg',
                                                   DashboardState,
                                                   self.dashboard_callback)
    def __init__(self):
        self._ok_icon = [
            path.join(roslib.packages.get_pkg_dir('rqt_youbot_dashboard'),
                      "icons/cancel-goal-green.png")
        ]
        self._not_ok_icon = [
            path.join(roslib.packages.get_pkg_dir('rqt_youbot_dashboard'),
                      "icons/cancel-goal-grey.png")
        ]

        icons = [self._ok_icon, self._not_ok_icon]
        super(CancelGoalsWidget, self).__init__('', icons=icons)
        self.setFixedSize(QSize(40, 40))

        self.setToolTip("Cancel goals")

        self.clicked.connect(self.toggle)

        self._goal_client = actionlib.SimpleActionClient(
            'move_base', MoveBaseAction)

        if self._goal_client.wait_for_server(rospy.Duration(1)):
            self.update_state(0)
            self._goal_ok = True
        else:
            rospy.logwarn("move base not running yet, can't cancel goal")
            self.update_state(1)
            self._goal_ok = False
예제 #22
0
    def __init__(self, interactive_client_interface=None):
        self.binded_function = {}
        self.cur_selected_role = ''
        self.cur_selected_interaction = None
        self.interactions = {}
        self.interactive_client_interface = interactive_client_interface
        self.interactions_widget = QWidget()
        # load ui
        rospack = rospkg.RosPack()
        path = os.path.join(rospack.get_path('rocon_remocon'), 'ui',
                            'interactions_list.ui')
        loadUi(path, self.interactions_widget)

        # interactions list widget
        self.interactions_widget.interactions_list_widget.setIconSize(
            QSize(50, 50))
        self.interactions_widget.interactions_list_widget.itemDoubleClicked.connect(
            self._start_interaction)
        self.interactions_widget.back_btn.pressed.connect(self._back)
        self.interactions_widget.interactions_list_widget.itemClicked.connect(
            self._display_interaction_info)  # rocon master item click event
        self.interactions_widget.stop_interactions_button.pressed.connect(
            self._stop_interaction)
        self.interactions_widget.stop_interactions_button.setDisabled(True)
        self.interactions_widget.closeEvent = self._close_event

        console.logdebug('init QInteractionsChooser')
    def __init__(self, component_name, switch_on_callback,
                 switch_off_callback):

        ok_icon = ['bg-green.svg', 'ic-' + component_name + '.svg']
        warn_icon = [
            'bg-yellow.svg', 'ic-' + component_name + '.svg',
            'ol-warn-badge.svg'
        ]
        err_icon = [
            'bg-red.svg', 'ic-' + component_name + '.svg', 'ol-err-badge.svg'
        ]
        stale_icon = [
            'bg-grey.svg', 'ic-' + component_name + '.svg',
            'ol-stale-badge.svg'
        ]

        icons = [ok_icon, warn_icon, err_icon, stale_icon]
        super(YoubotMotors,
              self).__init__(name=component_name + ' motors',
                             icons=icons,
                             icon_paths=[['youbot_dashboard', 'images']])

        self.update_state(3)

        self.add_action('Switch ' + component_name + ' motors ON',
                        switch_on_callback)
        self.add_action('Switch ' + component_name + ' motors OFF',
                        switch_off_callback)
        self.setToolTip(component_name + ' motors')

        self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))
예제 #24
0
 def sizeHint(self, option, index):
     '''
     Determines and returns the size of the text after the format.
     @see: U{http://www.pyside.org/docs/pyside/PySide/QtGui/QAbstractItemDelegate.html#PySide.QtGui.QAbstractItemDelegate}
     '''
     options = QStyleOptionViewItem(option)
     self.initStyleOption(options, index)
     return QSize(options.rect.width(), 25)
예제 #25
0
 def __init__(self):
     super(QTextEdit, self).__init__()
     self.setObjectName("robot_mode_text")
     self.setReadOnly(True)
     self.setText('STALE')
     self.setFixedSize(QSize(180, 27))
     self.text_changed.connect(self._update_state)
     self.__state = 'STALE'
예제 #26
0
def transformPointToPixelCoordinates(pt, map, image_size):
    map_point_f = ((pt - QPointF(map.map.info.origin.position.x,
                                 map.map.info.origin.position.y)) *
                   (1.0 / map.map.info.resolution))
    map_point = QPoint(int(map_point_f.x()), int(map_point_f.y()))
    map_size = QSize(map.map.info.width, map.map.info.height)
    scaled_point = scalePoint(map_point, map_size, image_size)
    return QPoint(scaled_point.x(), image_size.height() - scaled_point.y() - 1)
예제 #27
0
 def __init__(self):
     base_icon = '/usr/share/icons/Humanity/actions/32/document-new.svg'
     icons = [['bg-grey.svg', base_icon], ['bg-green.svg', base_icon],
              ['bg-red.svg', base_icon]]
     super(HrpsysLogMenu, self).__init__('hrpsys log', icons)
     self.update_state(0)
     self.add_action('download rtm log', self.on_download)
     self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))
     self.setToolTip("Download RTM log")
예제 #28
0
 def __init__(self):
     icons = [['bg-grey.svg', 'ic-runstop-off.svg'],
              ['bg-green.svg', 'ic-runstop-on.svg'],
              ['bg-red.svg', 'ic-runstop-off.svg']]
     super(StabilizerMenu, self).__init__('Stabilizer on/off', icons)
     self.update_state(0)
     self.add_action('start Stabilizer', self.on_st_on)
     self.add_action('stop Stabilizer', self.on_st_off)
     self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))
예제 #29
0
 def __init__(self):
     icons = [['bg-grey.svg', 'ic-runstop-off.svg'],
              ['bg-green.svg', 'ic-runstop-on.svg'],
              ['bg-red.svg', 'ic-runstop-off.svg']]
     super(HrpsysPowerMenu, self).__init__('power on/off', icons)
     self.update_state(0)
     self.add_action('Power On', self.on_power_on)
     self.add_action('Power Off', self.on_power_off)
     self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))
 def __init__(self):
     icons = [['bg-grey.svg', 'ic-runstop-off.svg'],
              ['bg-green.svg', 'ic-runstop-on.svg'],
              ['bg-red.svg', 'ic-runstop-off.svg']]
     super(ImpedanceControllerMenu, self).__init__('ImpedanceController on/off', icons)
     self.update_state(0)
     self.add_action('start ImpedanceController', self.on_imp_on)
     self.add_action('stop ImpedanceController', self.on_imp_off)
     self.setFixedSize(self._icons[0].actualSize(QSize(50, 30)))