Пример #1
0
 def __init__(self):
     super(StringLabelWidget, self).__init__()
     self.lock = Lock()
     vbox = QVBoxLayout(self)
     self.label = QLabel()
     self.label.setAlignment(Qt.AlignLeft)
     self.label.setSizePolicy(
         QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored))
     font = QFont("Helvetica", 14)
     self.label.setFont(font)
     self.label.setWordWrap(True)
     vbox.addWidget(self.label)
     self.string_sub = None
     self._string_topics = []
     self._update_topic_timer = QTimer(self)
     self._update_topic_timer.timeout.connect(self.updateTopics)
     self._update_topic_timer.start(1000)
     self._active_topic = None
     # to update label visualization
     self._dialog = LineEditDialog()
     self._rosdata = None
     self._start_time = rospy.get_time()
     self._update_label_timer = QTimer(self)
     self._update_label_timer.timeout.connect(self.updateLabel)
     self._update_label_timer.start(40)
    def __init__(self):
        super(ImageView2Widget, self).__init__()
        self.left_button_clicked = False
        self.lock = Lock()
        self.need_to_rewrite = False
        self.bridge = CvBridge()
        self.image_sub = None
        self.event_pub = None
        self.label = ScaledLabel()
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setSizePolicy(
            QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored))
        #self.label.installEventFilter(self)
        vbox = QtGui.QVBoxLayout(self)
        vbox.addWidget(self.label)
        self.setLayout(vbox)

        self._update_plot_timer = QTimer(self)
        self._update_plot_timer.timeout.connect(self.redraw)
        self._update_plot_timer.start(40)

        self._image_topics = []
        self._update_topic_timer = QTimer(self)
        self._update_topic_timer.timeout.connect(self.updateTopics)
        self._update_topic_timer.start(1)

        self._active_topic = None
        self.setMouseTracking(True)
        self.label.setMouseTracking(True)
        self._dialog = ComboBoxDialog()
        self.show()
Пример #3
0
    def __init__(self, topic="diagnostics"):
        super(RuntimeMonitorWidget, self).__init__()
        rp = rospkg.RosPack()
        ui_file = os.path.join(rp.get_path('rqt_runtime_monitor'), 'resource',
                               'runtime_monitor_widget.ui')
        loadUi(ui_file, self)
        self.setObjectName('RuntimeMonitorWidget')

        self._mutex = threading.Lock()

        self._error_icon = QIcon.fromTheme('dialog-error')
        self._warning_icon = QIcon.fromTheme('dialog-warning')
        self._ok_icon = QIcon.fromTheme('dialog-information')

        self._stale_node = QTreeWidgetItem(
            self.tree_widget.invisibleRootItem(), ['Stale (0)'])
        self._stale_node.setIcon(0, self._error_icon)
        self.tree_widget.addTopLevelItem(self._stale_node)

        self._error_node = QTreeWidgetItem(
            self.tree_widget.invisibleRootItem(), ['Errors (0)'])
        self._error_node.setIcon(0, self._error_icon)
        self.tree_widget.addTopLevelItem(self._error_node)

        self._warning_node = QTreeWidgetItem(
            self.tree_widget.invisibleRootItem(), ['Warnings (0)'])
        self._warning_node.setIcon(0, self._warning_icon)
        self.tree_widget.addTopLevelItem(self._warning_node)

        self._ok_node = QTreeWidgetItem(self.tree_widget.invisibleRootItem(),
                                        ['Ok (0)'])
        self._ok_node.setIcon(0, self._ok_icon)
        self.tree_widget.addTopLevelItem(self._ok_node)
        self.tree_widget.itemSelectionChanged.connect(self._refresh_selection)
        self.keyPressEvent = self._on_key_press

        self._name_to_item = {}
        self._new_errors_callback = None

        self._subscriber = rospy.Subscriber(topic, DiagnosticArray,
                                            self._diagnostics_callback)

        self._previous_ros_time = rospy.Time.now()
        self._timer = QTimer()
        self._timer.timeout.connect(self._on_timer)
        self._timer.start(1000)

        self._msg_timer = QTimer()
        self._msg_timer.timeout.connect(self._update_messages)
        self._msg_timer.start(100)

        self._messages = []
        self._used_items = 0
Пример #4
0
 def __init__(self):
     super(StatusLightWidget, self).__init__()
     self.lock = Lock()
     self.status_sub = None
     self.status = 0
     self._status_topics = []
     self._update_topic_timer = QTimer(self)
     self._update_topic_timer.timeout.connect(self.updateTopics)
     self._update_topic_timer.start(1)
     self._active_topic = None
     self._dialog = ComboBoxDialog()
     self._update_plot_timer = QTimer(self)
     self._update_plot_timer.timeout.connect(self.redraw)
     self._update_plot_timer.start(5)
Пример #5
0
    def __init__(self, context):
        super(Control, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('Control')

        # Create QWidget
        self._widget = QWidget()

        # Get path to UI file which should be in the "resource" folder of
        # this package
        ui_file = os.path.join(rospkg.RosPack().get_path('robosub'),
                               'src/rqt/rqt_control/resource', 'Control.ui')
        # Extend the widget with all attributes and children from UI file
        loadUi(ui_file, self._widget)

        self.control_timer = QTimer(self)
        self.control_timer.timeout.connect(self.control_missed)
        self.control_timer.start(1000)

        self.control_status_timer = QTimer(self)
        self.control_status_timer.timeout.connect(self.control_status_missed)
        self.control_status_timer.start(1000)

        # Give QObjects reasonable names
        self._widget.setObjectName('Control')

        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))

        # Add widget to the user interface
        context.add_widget(self._widget)

        self._widget.statusActive.hide()
        self._widget.controlActive.hide()

        self.con_sub = rospy.Subscriber('control', control,
                                        self.control_callback, queue_size=1)
        self.cs_sub = rospy.Subscriber('control_status', control_status,
                                       self.control_status_callback,
                                       queue_size=1)
        img_file = os.path.join(rospkg.RosPack().get_path('robosub'),
                                'src/rqt/resource/robosub_logo.png')

        self._widget.setStyleSheet(".QWidget {background-image: url(" +
                                   img_file +
                                   "); background-repeat: no-repeat;" +
                                   "background-position:bottom right}")
Пример #6
0
    def __init__(self, arguments=None, initial_topics=None):
        super(PlotWidget, self).__init__()
        self.setObjectName('PlotWidget')

        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                               'plot.ui')
        loadUi(ui_file, self)
        self.subscribe_topic_button.setIcon(QIcon.fromTheme('add'))
        self.remove_topic_button.setIcon(QIcon.fromTheme('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)

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

        self._start_time = rospy.get_time()
        self._rosdata = {}
        self._ordered_topics = []
        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)

        # save command line arguments
        self._arguments = arguments
        self._initial_topics = initial_topics
    def __init__(self, context, publish_clock):
        """
        :param context: plugin context hook to enable adding rqt_bag plugin widgets as ROS_GUI snapin panes, ''PluginContext''
        """
        super(DynamicTimeline, self).__init__()
        # key is topic name, value is a named tuple of type Topic. The deque
        # contains named tuples of type Message
        self._topics = {}
        # key is the data type, value is a list of topics with that type
        self._datatypes = {}
        self._topic_lock = threading.RLock()

        self.background_task = None  # Display string
        self.background_task_cancel = False

        # Playing / Recording
        self._playhead_lock = threading.RLock()
        self._max_play_speed = 1024.0  # fastest X play speed
        self._min_play_speed = 1.0 / 1024.0  # slowest X play speed
        self._play_speed = 0.0
        self._play_all = False
        self._playhead_positions_cvs = {}
        self._playhead_positions = {}  # topic -> position
        self._message_loaders = {}
        self._messages_cvs = {}
        self._messages = {}  # topic -> msg_data
        self._message_listener_threads = {
        }  # listener -> MessageListenerThread
        self._player = False
        self._publish_clock = publish_clock
        self._recorder = None
        self.last_frame = None
        self.last_playhead = None
        self.desired_playhead = None
        self.wrap = True  # should the playhead wrap when it reaches the end?
        self.stick_to_end = False  # should the playhead stick to the end?
        self._play_timer = QTimer()
        self._play_timer.timeout.connect(self.on_idle)
        self._play_timer.setInterval(3)
        self._redraw_timer = None  # timer which can be used to periodically redraw the timeline

        # Plugin popup management
        self._context = context
        self.popups = {}
        self._views = []
        self._listeners = {}

        # Initialize scene
        # the timeline renderer fixes use of black pens and fills, so ensure we fix white here for contrast.
        # otherwise a dark qt theme will default it to black and the frame render pen will be unreadable
        self.setBackgroundBrush(Qt.white)
        self._timeline_frame = DynamicTimelineFrame(self)
        self._timeline_frame.setPos(0, 0)
        self.addItem(self._timeline_frame)

        self.background_progress = 0
        self.__closed = False

        # timer to periodically redraw the timeline every so often
        self._start_redraw_timer()
Пример #8
0
    def __init__(self, parent, label_name, topic_name, topic_type, topic_field,
                 buffer_size):

        self.label_name = label_name
        self.topic_type = topic_type
        self.topic_name = topic_name
        self.topic_field = topic_field
        self.buffer_size = buffer_size

        self.timer = QTimer()
        self.timer.setInterval(100)
        self.timer.timeout.connect(self.update_figure)

        fig = Figure(figsize=(5, 4), dpi=100)
        self.axes = fig.add_subplot(111)
        # We want the axes cleared every time plot() is called
        self.axes.hold(False)

        self.compute_initial_figure()
        self.buffer = collections.deque(maxlen=self.buffer_size)

        FigureCanvas.__init__(self, fig)
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

        self.subscriber = RosHelper.create_subscriber_from_type(
            self.topic_name, self.topic_type, self.on_message)
        self.timer.start()
Пример #9
0
    def __init__(self, svo1_namespace='svo1'):

        # Init QWidget
        super(Svo1Widget, self).__init__()
        self.setObjectName('Svo1Widget')

        # load UI
        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_svo1'),
                               'resource', 'widget.ui')
        loadUi(ui_file, self)

        # init and start update timer for data, the timer calls the function update_info all 40ms
        self._update_info_timer = QTimer(self)
        self._update_info_timer.timeout.connect(self.update_info)
        self._update_info_timer.start(40)

        # set the functions that are called when a button is pressed
        self.button_start.pressed.connect(self.on_start_button_pressed)
        self.button_reset.pressed.connect(self.on_reset_button_pressed)
        self.button_quit.pressed.connect(self.on_quit_button_pressed)

        # set callback for changed topic
        self.topic_line_edit.setText(svo1_namespace)
        self.register(svo1_namespace)
        self.topic_line_edit.textChanged.connect(self._on_topic_changed)
Пример #10
0
    def __init__(self, plugin):
        super(PoseViewWidget, self).__init__()
        rp = rospkg.RosPack()
        ui_file = os.path.join(rp.get_path('rqt_pose_view'), 'resource', 'PoseViewWidget.ui')
        loadUi(ui_file, self)
        self._plugin = plugin

        self._position = (0.0, 0.0, 0.0)
        self._orientation = quaternion_about_axis(0.0, (1.0, 0.0, 0.0))
        self._topic_name = None
        self._subscriber = None

        # create GL view
        self._gl_view = GLWidget()
        self._gl_view.setAcceptDrops(True)

        # backup and replace original paint method
        self._gl_view.paintGL_original = self._gl_view.paintGL
        self._gl_view.paintGL = self._gl_view_paintGL

        # backup and replace original mouse release method
        self._gl_view.mouseReleaseEvent_original = self._gl_view.mouseReleaseEvent
        self._gl_view.mouseReleaseEvent = self._gl_view_mouseReleaseEvent

        # add GL view to widget layout
        self.layout().addWidget(self._gl_view)

        # init and start update timer with 40ms (25fps)
        self._update_timer = QTimer(self)
        self._update_timer.timeout.connect(self.update_timeout)
        self._update_timer.start(40)
Пример #11
0
    def __init__(self):
        print('constructor')
        # Init QWidget
        super(CalibWidget, self).__init__()
        self.setObjectName('CalibWidget')

        # load UI
        ui_file = os.path.join(
            rospkg.RosPack().get_path('dvs_calibration_gui'), 'resource',
            'widget.ui')
        loadUi(ui_file, self)

        # init and start update timer for data, the timer calls the function update_info all 40ms
        self._update_info_timer = QTimer(self)
        self._update_info_timer.timeout.connect(self.update_info)
        self._update_info_timer.start(40)

        self.button_reset.pressed.connect(self.on_button_reset_pressed)
        self.button_start.pressed.connect(
            self.on_button_start_calibration_pressed)
        self.button_save.pressed.connect(
            self.on_button_save_calibration_pressed)

        self._sub_pattern_detections = rospy.Subscriber(
            'dvs_calibration/pattern_detections', Int32,
            self.pattern_detections_cb)
        self._sub_calibration_output = rospy.Subscriber(
            'dvs_calibration/output', String, self.calibration_output_cb)

        print('reset')

        self.on_button_reset_pressed()

        print('reset done')
Пример #12
0
    def __init__(self, initial_topics=None, start_paused=False):
        super(PlotWidget, self).__init__()
        self.setObjectName('PlotWidget')

        self._initial_topics = initial_topics

        rp = rospkg.RosPack()
        ui_file = '/home/mohammad/Documents/CMU/RED/catkin_ws/src/rqt_safeguard/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()
        self.topic_edit.setCompleter(self._topic_completer)

        self._start_time = rospy.get_time()
        self._rosdata = {}
        self._remove_topic_menu = QMenu()

        self.color_box.setStyleSheet("background-color: red;")

        # init and start update timer for plot
        self._update_timer = QTimer(self)
        self._update_timer.timeout.connect(self.update)
Пример #13
0
    def __init__(self, topic=None):
        super(PclWidget, self).__init__()
        self.setObjectName('PclWidget')

        # Create subscriber
        if topic:
            self._pclData = PclData(topic, PointCloud)

        rp = rospkg.RosPack()
        ui_file = os.path.join(rp.get_path('rqt_pcl'), 'resource', 'RosPcl.ui')
        loadUi(ui_file, self)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        self.data_layout.addWidget(self.vtkWidget)

        self.ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        self.pointcloud = PclVisualizer()
        self.ren.AddActor(self.pointcloud.vtkActor)
        self.ren.ResetCamera()

        # Init and start update timer
        self._update_timer = QTimer(self)
        self._update_timer.timeout.connect(self.update_plot)
        self._update_timer.start(100)

        self.iren.Initialize()
Пример #14
0
    def __init__(self,
                 plugin=None,
                 selected_topics=None,
                 select_topic_type=SELECT_BY_NAME):
        """
        @type selected_topics: list of tuples.
        @param selected_topics: [($NAME_TOPIC$, $TYPE_TOPIC$), ...]
        @type select_topic_type: int
        @param select_topic_type: Can specify either the name of topics or by
                                  the type of topic, to filter the topics to
                                  show. If 'select_topic_type' argument is
                                  None, this arg shouldn't be meaningful.
        """
        super(TopicWidget, self).__init__()

        self._select_topic_type = select_topic_type

        rp = rospkg.RosPack()
        ui_file = os.path.join(rp.get_path('rqt_topic'), 'resource',
                               'TopicWidget.ui')
        loadUi(ui_file, self)
        self._plugin = plugin
        self.topics_tree_widget.sortByColumn(0, Qt.AscendingOrder)
        header = self.topics_tree_widget.header()
        try:
            setSectionResizeMode = header.setSectionResizeMode  # Qt5
        except AttributeError:
            setSectionResizeMode = header.setResizeMode  # Qt4
        setSectionResizeMode(QHeaderView.ResizeToContents)
        header.customContextMenuRequested.connect(
            self.handle_header_view_customContextMenuRequested)
        header.setContextMenuPolicy(Qt.CustomContextMenu)

        # Whether to get all topics or only the topics that are set in advance.
        # Can be also set by the setter method "set_selected_topics".
        self._selected_topics = selected_topics
        self._current_topic_list = []
        self._topics = {}
        self._tree_items = {}
        self._column_index = {}
        for column_name in self._column_names:
            self._column_index[column_name] = len(self._column_index)

        # self.refresh_topics()

        # init and start update timer
        self._timer_refresh_topics = QTimer(self)
        self._timer_refresh_topics.timeout.connect(self.refresh_topics)

        # Mon code
        self._generation_code_class = Genecode(
            self
        )  #_valider_#----------------------------------------------------
        self._pub_sub = Pub_Sub(self._generation_code_class
                                )  #_valider_#-------------------------------
        self._interface_pub_sub = Interface_Pub_Sub(
            self, self._generation_code_class,
            self._pub_sub)  #_valider_#----------
        self.code_generation_button.clicked.connect(
            self._interface_pub_sub._press_button_code)  #_valider_#---------
Пример #15
0
    def __init__(self, initial_topics=None, start_paused=False):
        super(PlotWidget, self).__init__()
        self.setObjectName('PlotWidget')
        self._initial_topics = initial_topics

        rp = rospkg.RosPack()
        ui_file = os.path.join(rp.get_path('monitoring_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(True)
        if start_paused:
            self.pause_button.setChecked(True)

        self._start_time = rospy.get_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)

        rospy.Subscriber("/monitoring/gui", Gui,
                         self.monitoring_topic_overview_list_manager)
Пример #16
0
    def __init__(self, parent):
        # Init QWidget
        super(AutopilotWidget, self).__init__(parent)
        self.setObjectName('Autopilot Widget')

        # set variables
        self._quad_namespace = None
        self._connected = False

        self._arm_bridge_pub = None
        self._start_pub = None
        self._land_pub = None
        self._off_pub = None
        self._force_hover_pub = None
        self._go_to_pose_pub = None
        self._vislam_reset_pub = None
        self._enable_stereo_pub = None

        self._autopilot_feedback_sub = None
        self._state_estimate_sub = None
        self._low_level_feedback_sub = None
        self._autopilot_feedback = quadrotor_msgs.AutopilotFeedback()
        self._autopilot_feedback_stamp = rospy.Time.now()

        # load UI
        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                               '../../resource/autopilot_widget.ui')
        loadUi(ui_file, self)

        # Timer
        self._update_info_timer = QTimer(self)
        self._update_info_timer.timeout.connect(self.update_gui)
        self._update_info_timer.start(100)

        self.disconnect()
Пример #17
0
    def __init__(self):
        super(QObject, self).__init__()
        self._enabled = True

        self._timer = QTimer(self)
        self._timer.setSingleShot(True)
        self._timer.timeout.connect(self.filter_changed_signal.emit)
Пример #18
0
    def __init__(self, initial_topics=None, start_paused=False):
        super(PlotWidget, self).__init__()
        self.setObjectName('PlotWidget')

        # Available ros topics for plotting
        # keys are i=InitSub, s=StateSub, r=RCSub, p=PathSub, w=WaypointSub,
        #          o=ObstacleSub, g=GPSDataSub, ci=ConInSub, cc=ConComSub
        self.message_dict = {
            'Course angle vs. Commanded': [('cc', 'chi_c'), ('s', 'chi')],
            'Roll angle vs. Commanded': [('ci', 'phi_c'), ('s', 'phi')],
            'Pitch angle vs. Commanded': [('s', 'theta'), ('ci', 'theta_c')],
            'Airspeed vs. Commanded': [('s', 'Va'), ('cc', 'Va_c')]
        }

        # # Available ros topics for plotting
        # self.message_dict = {
        #     'Course angle (rad)':'/state/chi',
        #     'Course angle commanded (rad)':'/controller_commands/chi_c',
        #     'Airspeed (m/s)':'/state/Va',
        #     'Angle of attack (rad)':'/state/alpha',
        #     'Slide slip angle (rad)':'/state/beta',
        #     'Roll angle (rad)':'/state/phi',
        #     'Pitch angle (rad)':'/state/theta',
        #     'Yaw angle (rad)':'/state/psi',
        #     'Body frame rollrate (rad/s)':'/state/p',
        #     'Body frame pitchrate (rad/s)':'/state/q',
        #     'Body frame yawrate (rad/s)':'/state/r',
        #     'Groundspeed (m/s)':'/state/Vg'
        #     }

        #self._initial_topics = initial_topics

        rp = rospkg.RosPack()
        ui_file = os.path.join(PWD, 'resources', 'plot.ui')
        loadUi(ui_file, self)

        self.pause_button.setIcon(QIcon.fromTheme('media-playback-pause'))
        self.clear_button.setIcon(QIcon.fromTheme('edit-clear'))
        self.data_plot = None

        if start_paused:
            self.pause_button.setChecked(True)

        self._start_time = rospy.get_time()
        self._rosdata = {}

        self._current_key = ''
        self._current_topics = []

        self._remove_topic_menu = QMenu()

        self._msgs.clear()
        self._msgs.addItems(self.message_dict.keys())

        self._msgs.currentIndexChanged[str].connect(
            self._draw_graph)  # <<<<<<< start here (also modify the dict)

        # init and start update timer for plot
        self._update_plot_timer = QTimer(self)
        self._update_plot_timer.timeout.connect(self.update_plot)
Пример #19
0
    def __init__(self, context):
        super(Visualizer, self).__init__(context)
        self.setObjectName("Visualizer")

        self._widget = QWidget()

        ui_file = os.path.join(rospkg.RosPack().get_path("sai_visualizer"), \
                "resource", "visualizer_widget.ui")
        loadUi(ui_file, self._widget, {"PaintWidget": PaintWidget})
        self._widget.setObjectName("VisualizerUi")

        self._widget.setWindowTitle("SAI Visualizer")

        # Show _widget.windowTitle on left-top of each plugin (when
        # it's set in _widget). This is useful when you open multiple
        # plugins at once. Also if you open multiple instances of your
        # plugin at once, these lines add number to make it easy to
        # tell from pane to pane.
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))
        # Add widget to the user interface
        context.add_widget(self._widget)

        self._redraw_timer = QTimer()
        self._redraw_timer.setInterval(16)
        self._redraw_timer.timeout.connect(self._widget.update)
        self._redraw_timer.start()
Пример #20
0
    def __init__(self,
                 finished_callback=None,
                 node_name='world_mesh_worker',
                 frame_id='local_origin',
                 marker_topic='world_mesh_marker',
                 refresh_ms=None,
                 new_node=False,
                 parent=None):
        super(WorldMeshWorker, self).__init__(parent)

        if new_node:
            rospy.init_node(node_name, anonymous=True)

        if finished_callback is not None:
            self.finished.connect(finished_callback)

        #TODO([email protected]) - how to shut down?
        self.is_running = True

        self.frame_id = frame_id
        self.marker_pub = rospy.Publisher(marker_topic, Marker, queue_size=100)

        self.file_resource = None
        # if marker disappears, this will refresh it
        # Rviz is only slow to load a mesh the first time
        if refresh_ms is not None:
            self.timer = QTimer()
            self.timer.setInterval(refresh_ms)  # in milliseconds
            #self.timer.setTimerType(Qt.PreciseTimer)
            self.timer.timeout.connect(self.on_timer_callback)
            self.timer.start()
Пример #21
0
    def __init__(self, context):
        """
        :param context: plugin context hook to enable adding widgets as a ROS_GUI pane, ''PluginContext''
        """
        super(Console, self).__init__(context)
        self.setObjectName('Console')

        self._rospack = rospkg.RosPack()

        self._model = MessageDataModel()
        self._proxy_model = MessageProxyModel()
        self._proxy_model.setSourceModel(self._model)

        self._widget = ConsoleWidget(self._proxy_model, self._rospack)
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))
        context.add_widget(self._widget)

        # queue to store incoming data which get flushed periodically to the model
        # required since QSortProxyModel can not handle a high insert rate
        self._message_queue = []
        self._mutex = QMutex()
        self._timer = QTimer()
        self._timer.timeout.connect(self.insert_messages)
        self._timer.start(100)

        self._subscriber = None
        self._topic = '/rosout_agg'
        self._subscribe(self._topic)
    def __init__(self):
        super(MainWidget, self).__init__()
        self.setObjectName('MainWidget')

        rospack = rospkg.RosPack()
        ui_file = rospack.get_path(
            'rqt_joint_trajectory_plot') + '/resource/JointTrajectoryPlot.ui'
        loadUi(ui_file, self)

        self.refresh_button.setIcon(QIcon.fromTheme('reload'))
        self.pause_button.setIcon(QIcon.fromTheme('media-playback-pause'))

        self.handler = None
        self.joint_names = []
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update)
        self.plot_widget = PlotWidget(self)
        self.plot_layout.addWidget(self.plot_widget)
        self.draw_curves.connect(self.plot_widget.draw_curves)

        self.time = None
        (self.dis, self.vel, self.acc, self.eff) = ({}, {}, {}, {})

        # refresh topics list in the combobox
        self.refresh_topics()
        self.change_topic()

        self.refresh_button.clicked.connect(self.refresh_topics)
        self.topic_combox.currentIndexChanged.connect(self.change_topic)
        self.select_tree.itemChanged.connect(self.update_checkbox)
Пример #23
0
    def __init__(self, context):
        """
        :param context: plugin context hook to enable adding widgets as a ROS_GUI pane, ''PluginContext''
        """
        super(Console, self).__init__(context)
        self.setObjectName('Console')

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

        self._mainwindow = ConsoleWidget(self._proxymodel)
        if context.serial_number() > 1:
            self._mainwindow.setWindowTitle(self._mainwindow.windowTitle() +
                                            (' (%d)' %
                                             context.serial_number()))
        context.add_widget(self._mainwindow)

        self._consolesubscriber = ConsoleSubscriber(self.message_callback)

        # Timer and Mutex for flushing recieved messages to datamodel.
        # Required since QSortProxyModel can not handle a high insert rate
        self._mutex = QMutex()
        self._timer = QTimer()
        self._timer.timeout.connect(self.insert_messages)
        self._timer.start(100)
Пример #24
0
    def __init__(self):
        """
        :param context: plugin context hook to enable adding widgets
                        as a ROS_GUI pane, ''PluginContext''
        """

        self._rospack = rospkg.RosPack()

        self._model = MessageDataModel()
        self._proxy_model = MessageProxyModel()
        self._proxy_model.setSourceModel(self._model)

        self._widget = ConsoleWidget(self._proxy_model, self._rospack)

        # Queue to store incoming data which get flushed periodically
        # to the model.
        # Required since QSortProxyModel can not handle a high insert rate.
        self._message_queue = []
        self._mutex = QMutex()
        self._timer = QTimer()
        self._timer.timeout.connect(self.insert_messages)
        self._timer.start(100)

        self._subscriber = None
        self._topic = '/rosout_agg'
        self._subscribe(self._topic)
Пример #25
0
    def __init__(self, plugin):
        super(TopicWidget, self).__init__()
        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                               'TopicWidget.ui')
        loadUi(ui_file, self)
        self._plugin = plugin
        self.topics_tree_widget.sortByColumn(0, Qt.AscendingOrder)
        header = self.topics_tree_widget.header()
        header.setResizeMode(QHeaderView.ResizeToContents)
        header.customContextMenuRequested.connect(
            self.handle_header_view_customContextMenuRequested)
        header.setContextMenuPolicy(Qt.CustomContextMenu)

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

        self.refresh_topics()
        # init and start update timer
        self._timer_refresh_topics = QTimer(self)
        self._timer_refresh_topics.timeout.connect(self.refresh_topics)
        self._timer_refresh_topics.start(1000)
    def __init__(self, context):
        super(ActionLauncher, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('Action Launcher')

        # Create QWidget
        self._widget = QWidget()
        # Get path to UI file which should be in the "resource" folder of this package
        ui_file = os.path.join(
            rospkg.RosPack().get_path('rqt_action_launcher'), 'resource',
            'ActionLauncher.ui')
        # Extend the widget with all attributes and children from UI file
        loadUi(ui_file, self._widget)
        # Give QObjects reasonable names
        self._widget.setObjectName('ActionLauncherUi')
        # Show _widget.windowTitle on left-top of each plugin (when
        # it's set in _widget). This is useful when you open multiple
        # plugins at once. Also if you open multiple instances of your
        # plugin at once, these lines add number to make it easy to
        # tell from pane to pane.
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() +
                                        (' (%d)' % context.serial_number()))
        # Add widget to the user interface
        context.add_widget(self._widget)

        self._actions = {}

        self._timer_refresh_actions = QTimer(self)
        self._timer_refresh_actions.timeout.connect(self.refresh_actions)
        self._timer_refresh_actions.start(1000)
Пример #27
0
 def __init__(self, topics):
     super(Plot2DWidget, self).__init__()
     self.setObjectName('Plot2DWidget')
     rp = rospkg.RosPack()
     ui_file = os.path.join(rp.get_path('jsk_rqt_plugins'), 'resource',
                            'plot_histogram.ui')
     loadUi(ui_file, self)
     self.cv_bridge = CvBridge()
     self.subscribe_topic_button.setIcon(QIcon.fromTheme('add'))
     self.pause_button.setIcon(QIcon.fromTheme('media-playback-pause'))
     self.clear_button.setIcon(QIcon.fromTheme('edit-clear'))
     self.data_plot = MatPlot2D(self)
     self.data_plot_layout.addWidget(self.data_plot)
     self._topic_completer = TopicCompleter(self.topic_edit)
     self._topic_completer.update_topics()
     self.topic_edit.setCompleter(self._topic_completer)
     self.data_plot.dropEvent = self.dropEvent
     self.data_plot.dragEnterEvent = self.dragEnterEvent
     self._start_time = rospy.get_time()
     self._rosdata = None
     if len(topics) != 0:
         self.subscribe_topic(topics)
     self._update_plot_timer = QTimer(self)
     self._update_plot_timer.timeout.connect(self.update_plot)
     self._update_plot_timer.start(self._redraw_interval)
Пример #28
0
    def _add_publisher(self, publisher_info):
        publisher_info['publisher_id'] = self._id_counter
        self._id_counter += 1
        publisher_info['counter'] = 0
        publisher_info['enabled'] = publisher_info.get('enabled', False)
        publisher_info['expressions'] = publisher_info.get('expressions', {})

        publisher_info['message_instance'] = self._create_message_instance(
            publisher_info['type_name'])
        if publisher_info['message_instance'] is None:
            return

        # create publisher and timer
        try:
            publisher_info['publisher'] = rospy.Publisher(
                publisher_info['topic_name'],
                type(publisher_info['message_instance']),
                queue_size=100)
        except TypeError:
            publisher_info['publisher'] = rospy.Publisher(
                publisher_info['topic_name'],
                type(publisher_info['message_instance']))
        publisher_info['timer'] = QTimer(self)

        # add publisher info to _publishers dict and create signal mapping
        self._publishers[publisher_info['publisher_id']] = publisher_info
        self._timeout_mapper.setMapping(publisher_info['timer'],
                                        publisher_info['publisher_id'])
        publisher_info['timer'].timeout.connect(self._timeout_mapper.map)
        if publisher_info['enabled'] and publisher_info['rate'] > 0:
            publisher_info['timer'].start(int(1000.0 / publisher_info['rate']))

        self._widget.publisher_tree_widget.model().add_publisher(
            publisher_info)
Пример #29
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)
Пример #30
0
    def onCreate(self, param):

        layout = QGridLayout(self)
        layout.setContentsMargins(2, 2, 2, 2)

        self._rospack = rospkg.RosPack()

        self._model = MessageDataModel()
        self._proxy_model = MessageProxyModel()
        self._proxy_model.setSourceModel(self._model)

        self.__widget = ConsoleWidget(self._proxy_model, self._rospack)

        layout.addWidget(self.__widget, 0, 0, 0, 0)

        # queue to store incoming data which get flushed periodically to the model
        # required since QSortProxyModel can not handle a high insert rate
        self._message_queue = []
        self._mutex = QMutex()
        self._timer = QTimer()
        self._timer.timeout.connect(self.insert_messages)
        self._timer.start(100)

        self._subscriber = None
        self._topic = '/rosout_agg'
        self._subscribe(self._topic)