Ejemplo n.º 1
0
 def new_site_click(self):
     input_text, ok = QInputDialog.getText(self, "New site name",
                                           "Name of the new site: ")
     if ok:
         msg = rover_science.srv.NewSiteRequest()
         msg.site_name = input_text
         self.add_site(msg)
Ejemplo n.º 2
0
 def trigger_configuration(self):
     (text, ok) = QInputDialog.getText(
         self._widget,
         'Settings for %s' % self._widget.windowTitle(),
         'Command to edit launch files (vim, gedit, ...), can accept args:',
         text=self._widget.editor)
     if ok:
         self._widget.editor = text
Ejemplo n.º 3
0
    def mergeTracks(self, unused=None):
        (track1Id, ok) = QInputDialog.getInteger(self.widget, "Merge two tracks", "Please enter the ID of the 1st person track you want to merge.")
        if not ok:
            return

        (track2Id, ok) = QInputDialog.getInteger(self.widget, "Merge two tracks", "Please enter the ID of the 2nd person track you want to merge.")
        if not ok:
            return

        if track1Id == track2Id:
            QMessageBox.critical(self.widget, "Merge two tracks", "Track IDs cannot be identical!")
            return

        if self.verifyTrackExists(track1Id) and self.verifyTrackExists(track2Id):
            self.editor.mergeTracks(track1Id, track2Id)
            self.updateTrackCount()
            QMessageBox.information(self.widget, "Merge two tracks", "Person tracks %d and %d have been merged!" % (track1Id, track2Id))
Ejemplo n.º 4
0
 def stitch(self):
     site, ok = QInputDialog.getItem(self, "Pick a site",
                                     "Pick a site to set the panorama for",
                                     self.sites.keys())
     if not ok:
         return
     s = self.sites[site]
     self.science_mark = s
     self.panorama.send_goal(rover_panorama.msg.PanoramaGoal(), self.goal,
                             None, self.feedback)
Ejemplo n.º 5
0
 def rename_clicked(self):
     if self.listWidget.currentRow() == -1:
         return
     else:
         input_text, ok = QInputDialog.getText(self, "New site name",
                                               "New name of the site: ")
         if ok:
             msg = rover_science.srv.SiteNameChangeRequest()
             msg.site_name = input_text
             msg.site_id = self.listWidget.currentRow()
             self.change_site_name(msg)
Ejemplo n.º 6
0
 def _on_remove_perspective(self):
     # input dialog to choose perspective to be removed
     names = list(self.perspectives)
     names.remove(self._current_perspective)
     name, return_value = QInputDialog.getItem(
         self._menu_manager.menu,
         self._menu_manager.tr('Remove perspective'),
         self._menu_manager.tr('Select the perspective'), names, 0, False)
     # convert from unicode
     name = str(name)
     if return_value == QInputDialog.Rejected:
         return
     self._remove_perspective(name)
Ejemplo n.º 7
0
    def trigger_configuration(self):
        """
        Callback when the configuration button is clicked
        """
        changed = False
        map_topics = sorted(rostopic.find_by_type('nav_msgs/OccupancyGrid'))
        try:
            index = map_topics.index(self.map_topic)
        except ValueError:
            index = 0
        map_topic, ok = QInputDialog.getItem(self, "Select map topic name",
                                             "Topic name", map_topics, index)
        if ok:
            if map_topic != self.map_topic:
                changed = True
            self.map_topic = map_topic

        # Paths
        path_topics = sorted(rostopic.find_by_type('nav_msgs/Path'))
        path_topics = [(topic, topic in self.paths) for topic in path_topics]
        dialog = ListDialog("Select path topic(s)", path_topics, self)
        paths, ok = dialog.exec_()

        if ok:
            if not paths:
                changed = True
            diff = set(paths).symmetric_difference(set(self.paths))
            if diff:
                self.paths = paths
                changed = True

        # Polygons
        polygon_topics = sorted(
            rostopic.find_by_type('geometry_msgs/PolygonStamped'))
        polygon_topics = [(topic, topic in self.polygons)
                          for topic in polygon_topics]
        dialog = ListDialog("Select polygon topic(s)", polygon_topics, self)
        polygons, ok = dialog.exec_()

        if ok:
            if not polygons:
                changed = True
            diff = set(polygons).symmetric_difference(set(self.polygons))
            if diff:
                self.polygons = polygons
                changed = True

        if changed:
            rospy.logdebug(
                "New configuration is different, creating a new nav_view")
            self.new_nav_view()
Ejemplo n.º 8
0
 def _handle_generate(self, button):
     '''
     generate a new trial config
     '''
     trial_config = self.current_benchmark.generate()
     names = []
     for key in self.trial_configs.keys():
         names.append(key)
     msg = 'Select a name for this trial configuration'
     text = ''
     while True:
         text, ok = QInputDialog.getText(self, 'Trial name', msg)
         if text not in names:
             break
         QMessageBox.critical(self, "Error", "Name exists already")
     if ok:
         trial_item = QListWidgetItem(text)
         trial_item.setFlags(trial_item.flags() | Qt.ItemIsEditable)
         self.trial_list_widget.addItem(trial_item)
         self.trial_configs[text] = trial_config
         self.trial_list_widget.setCurrentItem(trial_item)
Ejemplo n.º 9
0
    def __init__(self, context):
        """Loads up the master.ui GUI file and adds some additional widgets that cannot be added beforehand. Also sets some necessary variables."""
        super(HardwareUI, self).__init__(context)
        self._widget = QMainWindow()

        rp = rospkg.RosPack()
        ui_file = os.path.join(rp.get_path('bitbots_hardware_rqt'), 'resource',
                               'master.ui')
        loadUi(ui_file, self._widget, {})

        self.current_tab = 0
        self.current_outer_tab = 0

        self.historydict = []
        self.colorlist = [
        ]  #Holds information about the graph colors, so we can distinguish between the different motors
        self.motornames = [
            'HeadPan', 'HeadTilt', 'LAnklePitch', 'LAnkleRoll', 'LElbow',
            'LHipPitch', 'LHipRoll', 'LHipYaw', 'LKnee', 'LShoulderPitch',
            'LShoulderRoll', 'RAnklePitch', 'RAnkleRoll', 'RElbow',
            'RHipPitch', 'RHipRoll', 'RHipYaw', 'RKnee', 'RShoulderPitch',
            'RShoulderRoll'
        ]  #We need the motor names in alphabetical order for some gui elements
        for i in range(0, 20):
            self.colorlist.append(
                (random.randrange(50, 255), random.randrange(0, 255),
                 random.randrange(0, 255)))

        self.templist = [[] for i in range(20)]
        self.torquelist = [[] for i in range(20)]
        self.voltagelist = [[] for i in range(20)]

        self.crosshair = QLabel()
        self.pixmap = QtGui.QPixmap(
            os.path.join(rp.get_path('bitbots_hardware_rqt'), 'resource',
                         'cross.png'))
        self.crosshair.setPixmap(self.pixmap)
        self.crosshair.setParent(self._widget.label_4)
        self.crosshair.move(187, 187)

        self.crosshair2 = QLabel()
        self.pixmap = QtGui.QPixmap(
            os.path.join(rp.get_path('bitbots_hardware_rqt'), 'resource',
                         'cross.png'))
        self.crosshair2.setPixmap(self.pixmap)
        self.crosshair2.setParent(self._widget.label_11)
        self.crosshair2.move(87, 87)

        self.make_Graphs()

        self.votrigger.connect(lambda: self.update_graph(
            self.voltageplt, self.voltagelist, self.combobox2, 3))
        self.tetrigger.connect(lambda: self.update_graph(
            self.tempplt, self.templist, self.combobox3, 1))
        self.totrigger.connect(lambda: self.update_graph(
            self.torqueplt, self.torquelist, self.combobox, 2))

        #self._robot_ip = [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0]
        self._robot, button_pressed = QInputDialog.getText(self._widget, "Robot?", \
                "Select your Robot. Example: nuc1", QLineEdit.Normal, "")

        self.diagnostics = rospy.Subscriber(
            "/{}/diagnostics".format(self._robot), DiagnosticArray,
            self.set_motor_diagnostics)
        self.joint_states = rospy.Subscriber(
            "/{}/joint_states".format(self._robot), JointState,
            self.set_motor_joint_states)
        self.buttons = rospy.Subscriber("/{}/buttons".format(self._robot),
                                        Buttons, self.set_buttons)
        self.imu = rospy.Subscriber("/{}/imu/data".format(self._robot), Imu,
                                    self.emit_imu_trigger)
        self.state = rospy.Subscriber("/{}/robot_state".format(self._robot),
                                      RobotControlState, self.set_robot_state)

        self.imutrigger.connect(self.set_imu)

        #self.rcvthread = ReceiverThread(self._robot_ip, self._robot_port)
        #self.rcvthread.start()

        self._widget.GraphenView.currentChanged.connect(
            self.current_graph_changed)
        self._widget.tabWidget.currentChanged.connect(
            self.current_outer_tab_changed)

        #self._widget.label_14.setText("IP: "+ [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0])

        context.add_widget(self._widget)
        self._widget.show()
Ejemplo n.º 10
0
    def __init__(self, context):

        super(LiveTool, self).__init__(context)
        # Load UI and initialize all Widgets
        self.loadUI()
        self.assignWidgets()
        self._widget.show()
        context.add_widget(self._widget)

        self.udp_ip = [
            l for l in (
                [
                    ip
                    for ip in socket.gethostbyname_ex(socket.gethostname())[2]
                    if not ip.startswith("127.")
                ][:1],
                [[(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close())
                  for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]
                  ][0][1]]) if l
        ][0][0]

        self.udp_port, button_pressed = QInputDialog.getText(self._widget, "Change Port?", \
                "Please select the port you want to listen on. Leave blank for port 5006.", QLineEdit.Normal, "")
        if button_pressed and self.udp_port == "":
            self.udp_port = "5006"

        self.udpworker = UdpWorker(self.udp_ip, self.udp_port)
        self.udpworker.start()

        # Set configuration from "ip_config.yaml"
        self.receiveIPconfig()

        #TODO: for testing only!!!: This parameter should be set for every Robot individually
        rospy.set_param(Name.param_robot_id, "Robot_2")

        # a simple list containing current RobotIDs. The order indicates, which robot gets which Index for
        # tabs and the 4 fields
        self.id_list = []

        # initialize time stamps to identify "old" unuseable udp packages
        self.lastStamps = {
            LiveTool.UDP_POSITION_MSG: {
                Name.secs: 0,
                Name.nsecs: 0
            },
            LiveTool.UDP_DETECTION_MSG: {
                Name.secs: 0,
                Name.nsecs: 0
            },
            LiveTool.UDP_STATUS_MSG: {
                Name.secs: 0,
                Name.nsecs: 0
            },
            LiveTool.UDP_TRAJECTORY_MSG: {
                Name.secs: 0,
                Name.nsecs: 0
            }
        }

        self._widget.label_13.setText("IP: " + [
            l for l in ([
                ip for ip in socket.gethostbyname_ex(socket.gethostname())[2]
                if not ip.startswith("127.")
            ][:1], [[
                (s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close())
                for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]
            ][0][1]]) if l
        ][0][0])

        self.sub = rospy.Subscriber("/live_info", String, self._storeData)
        self.sig.connect(self._parseUdpPackage)