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)
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
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)
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)
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()
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)