def __init__(self, updater, config): super(DoubleEditor, self).__init__(updater, config) loadUi(ui_num, self) # Handle unbounded doubles nicely if config['min'] != -float('inf'): self._min = float(config['min']) self._min_val_label.setText(str(self._min)) else: self._min = -1e10000 self._min_val_label.setText('-inf') if config['max'] != float('inf'): self._max = float(config['max']) self._max_val_label.setText(str(self._max)) else: self._max = 1e10000 self._max_val_label.setText('inf') if config['min'] != -float('inf') and config['max'] != -float('inf'): self._func = lambda x: x self._ifunc = self._func else: self._func = lambda x: math.atan(x) self._ifunc = lambda x: math.tan(x) # If we have no range, disable the slider self.scale = (self._func(self._max) - self._func(self._min)) if self.scale <= 0: self.scale = 0 self.setDisabled(True) else: self.scale = 100 / self.scale # Set ranges self._slider_horizontal.setRange(self._get_value_slider(self._min), self._get_value_slider(self._max)) self._paramval_lineEdit.setValidator(QDoubleValidator( self._min, self._max, 8, self)) # Initialize to defaults self._paramval_lineEdit.setText(str(config['default'])) self._slider_horizontal.setValue( self._get_value_slider(config['default'])) # Make slider update text (locally) self._slider_horizontal.sliderMoved.connect(self._slider_moved) # Make keyboard input change slider position and update param server self._paramval_lineEdit.editingFinished.connect(self._text_changed) # Make slider update param server # Turning off tracking means this isn't called during a drag self._slider_horizontal.setTracking(False) self._slider_horizontal.valueChanged.connect(self._slider_changed) # Make the param server update selection self._update_signal.connect(self._update_gui)
def __init__(self, parent=None): super(AeropendulumWidget, self).__init__(parent) ui_file = os.path.join(rospkg.RosPack().get_path('rqt_gui_aeropendulum'), 'resource', 'MyPlugin.ui') loadUi(ui_file, self) self.figure = Figure(facecolor = 'w') self.ax = self.figure.add_subplot(111) self.canvas = FigureCanvas(self.figure) self.toolbar = NavigationToolbar(self.canvas, self) self.graphLayout.addWidget(self.toolbar) self.graphLayout.addWidget(self.canvas) self.setPointInput.setMaxLength(5) self.setPointInput.setValidator(QDoubleValidator(0.00, MAX_ANGLE, 2)) self.kpInput.setValidator(QDoubleValidator()) self.kiInput.setValidator(QDoubleValidator()) self.kdInput.setValidator(QDoubleValidator()) self.setPointSlider.setMinimum(0) self.setPointSlider.setMaximum(MAX_ANGLE) self.setPointSlider.setValue(0) # Set icons images dirName = os.path.dirname(__file__) currentFolderRelativePath = '../../resource/icons/' connectIconName = 'link.svg' connectIconPath = os.path.normpath(os.path.join(dirName, currentFolderRelativePath, connectIconName)) self.connectButton.setIcon(QIcon(connectIconPath)) self.connectButton.setToolTip("Estabelece conexao") stepResponseIconName = 'graphs.svg' stepResponseIconPath = os.path.normpath(os.path.join(dirName, currentFolderRelativePath, stepResponseIconName)) self.stepResponseButton.setIcon(QIcon(stepResponseIconPath)) self.stepResponseButton.setToolTip("Aplica um degrau ao sistema") csvIconName = 'csv.svg' csvIconPath = os.path.normpath(os.path.join(dirName, currentFolderRelativePath, csvIconName)) self.csvButton.setIcon(QIcon(csvIconPath)) self.csvButton.setToolTip("Cria arquivos CSV") calibrationIconName = 'target.svg' calibrationIconPath = os.path.normpath(os.path.join(dirName, currentFolderRelativePath, calibrationIconName)) self.calibrationButton.setIcon(QIcon(calibrationIconPath)) self.calibrationButton.setToolTip("Calibracao do ponto zero")
def __init__(self, updater, config): super(DoubleEditor, self).__init__(updater, config) loadUi(ui_num, self) # Handle unbounded doubles nicely if config['min'] != -float('inf'): self.min = float(config['min']) self._min_val_label.setText(str(self.min)) self.func = lambda x: x self.ifunc = self.func else: self.min = -1e10000 self._min_val_label.setText('-inf') self.func = lambda x: math.atan(x) self.ifunc = lambda x: math.tan(x) if config['max'] != float('inf'): self.max = float(config['max']) self._max_val_label.setText(str(self.max)) self.func = lambda x: x self.ifunc = self.func else: self.max = 1e10000 self._max_val_label.setText('inf') self.func = lambda x: math.atan(x) self.ifunc = lambda x: math.tan(x) self.scale = (self.func(self.max) - self.func(self.min)) / 100 if self.scale == 0: self.setDisabled(True) self.offset = self.func(self.min) self._slider_horizontal.setRange(self.slider_value(self.min), self.slider_value(self.max)) self._slider_horizontal.sliderReleased.connect(self.slider_released) self._slider_horizontal.sliderMoved.connect(self.update_text) self._paramval_lineEdit.setValidator( QDoubleValidator(self.min, self.max, 8, self)) self._paramval_lineEdit.editingFinished.connect(self.editing_finished) self._paramval_lineEdit.setText(str(config['default'])) self._slider_horizontal.setSliderPosition( self.slider_value(config['default']))
def __init__(self, timeline, parent, topic): super(PlotWidget, self).__init__(parent) self.setObjectName('PlotWidget') self.timeline = timeline msg_type = self.timeline.get_datatype(topic) self.msgtopic = topic self.start_stamp = self.timeline._get_start_stamp() self.end_stamp = self.timeline._get_end_stamp() # the current region-of-interest for our bag file # all resampling and plotting is done with these limits self.limits = [0, (self.end_stamp - self.start_stamp).to_sec()] rp = rospkg.RosPack() ui_file = os.path.join(rp.get_path('rqt_bag_plugins'), 'resource', 'plot.ui') loadUi(ui_file, self) self.message_tree = MessageTree(msg_type, self) self.data_tree_layout.addWidget(self.message_tree) # TODO: make this a dropdown with choices for "Auto", "Full" and # "Custom" # I continue to want a "Full" option here self.auto_res.stateChanged.connect(self.autoChanged) self.resolution.editingFinished.connect(self.settingsChanged) self.resolution.setValidator(QDoubleValidator(0.0, 1000.0, 6, self.resolution)) self.timeline.selected_region_changed.connect(self.region_changed) self.recompute_timestep() self.plot = DataPlot(self) self.plot.set_autoscale(x=False) self.plot.set_autoscale(y=DataPlot.SCALE_VISIBLE) self.plot.autoscroll(False) self.plot.set_xlim(self.limits) self.data_plot_layout.addWidget(self.plot) self._home_button = QPushButton() self._home_button.setToolTip("Reset View") self._home_button.setIcon(QIcon.fromTheme('go-home')) self._home_button.clicked.connect(self.home) self.plot_toolbar_layout.addWidget(self._home_button) self._config_button = QPushButton("Configure Plot") self._config_button.clicked.connect(self.plot.doSettingsDialog) self.plot_toolbar_layout.addWidget(self._config_button) self.set_cursor(0) self.paths_on = set() self._lines = None # get bag from timeline bag = None start_time = self.start_stamp while bag is None: bag, entry = self.timeline.get_entry(start_time, topic) if bag is None: start_time = self.timeline.get_entry_after(start_time)[1].time self.bag = bag # get first message from bag msg = bag._read_message(entry.position) self.message_tree.set_message(msg[1]) # state used by threaded resampling self.resampling_active = False self.resample_thread = None self.resample_fields = set()
def __init__(self, context): super(Camera_is1500_Widget, self).__init__(context) # Give QObjects reasonable names self.setObjectName('Camera setting') # Process standalone plugin command-line arguments from argparse import ArgumentParser parser = ArgumentParser() # Add argument(s) to the parser. parser.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="Put plugin in silent mode") args, unknowns = parser.parse_known_args(context.argv()) if not args.quiet: print 'arguments: ', args print 'unknowns: ', unknowns # Create QWidget self._widget = QWidget() # Get path to UI file which should be in the "resources" folder of this package ui_file = os.path.join(rospkg.RosPack().get_path('rqt_camera_is1500'), 'resources', 'Camera_is1500_Widget.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.setObjectName('Camera_is1500_WidgetUI') # 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) """ Start nodes """ self.target_x = 0.0 self.target_y = 0.0 self.distance_x = 0.0 """ MAP path for is1500 package """ self.map_path_name = '' self.map_file_name = '' self.destination_map_file_name = '' self.destination_map_config_file_name = '' self.cameramap = [] self.current_wp = None """ RVIZ-APPs """ self.map_forRviz_file_name = self._widget.map_to_rviz_path_edit.text() self.utm_x_value = float(self._widget.utm_x_edit.text()) self.utm_y_value = float(self._widget.utm_y_edit.text()) self.utm_phi_value = float(self._widget.utm_phi_edit.text()) self.joao_origin_utm_x_value = float( self._widget.joao_origin_utm_x_edit.text()) self.joao_origin_utm_y_value = float( self._widget.joao_origin_utm_y_edit.text()) self.fiducials_map = [ ] # contain the position of the fiducial in camera frame self.indoor = self._widget.indoor_checkBox_edit.isChecked() self.init_transf = False # True if map already drew self.origin_cam_x = 0.0 self.origin_cam_y = 0.0 self.last_robot_x_edit = 0.0 #float(self._widget.get_pos_robot_x_edit.text()) self.last_robot_y_edit = 0.0 #float(self._widget.get_pos_robot_y_edit.text()) self.last_robot_yaw_edit = 0.0 #float(self._widget.get_pos_robot_yaw_edit.text()) self.angle_btwXcam_East = 0.0 """ Connect stuff here """ # self.model = QStandardItemModel(self._widget.arc_list) # self._widget.name_edit.setValidator(QDoubleValidator()) # self._widget.path_edit.setValidator(QDoubleValidator()) # self._widget.in_case_edit.setValidator(QDoubleValidator()) # self._widget.y_edit.setValidator(QDoubleValidator()) # self._widget.map_name_edit.setValidator() """ Start nodes """ self._widget.launch_camera_start_button.released.connect( self.start_camera_is1500_launchFile) self._widget.color_launch_camera_label.setStyleSheet( "background-color:#ff0000;") self._widget.launch_supervisor_start_button.released.connect( self.start_supervisor_launchFile) self._widget.launch_supervisor_color_label.setStyleSheet( "background-color:#ff0000;") self._widget.rviz_start_button.released.connect(self.start_rviz) self._widget.color_rviz_label.setStyleSheet( "background-color:#ff0000;") self._widget.target_start_button.released.connect( self.target_waypontPy_run) self._widget.color_target_label.setStyleSheet( "background-color:#ff0000;") self._widget.distance_start_button.released.connect( self.distance_throughDeadZone_run) self._widget.color_distance_label.setStyleSheet( "background-color:#ff0000;") self._widget.test_button.released.connect(self.test_button_function) """ Set map """ self._widget.send_map_param_button.released.connect( self.set_map_rosparam) self._widget.map_param_edit.setValidator(QDoubleValidator()) """ Add/modify map """ self._widget.file_name_button.released.connect(self.get_file) self._widget.desination_file_name_button.released.connect( self.get_folder) self._widget.desination_save_file_button.released.connect( self.save_file) self._widget.config_map_file_name_button.released.connect( self.get_file_yaml) self._widget.config_map_save_file_button.released.connect( self.config_save_file) self.model = QStandardItemModel(self._widget.map_from_mapYaml_list) self.model.itemChanged.connect(self.on_change_mapList) # Screen explaination msg # self._widget.name_edit.setToolTip("Set the name of the folder which will contain the map ") # self._widget.path_edit.setToolTip("Path of th map") # self._widget.file_name_label.setToolTipe("Map file which be added to the map folder of the robot") # Doesn't work # self._widget.name_edit.description = "This is label name_edit" # self._widget.path_edit.description = "This is label path_edit" # self._widget.file_name_button.description = "This is the OK button" # # for widget in (self._widget.name_edit, self._widget.path_edit, # self._widget.file_name_button): # widget.bind("<Enter>", self.on_enter) # widget.bind("<Leave>", self.on_leave) self._widget.map_name_edit.textChanged.connect(self.map_name_change) """ Rviz part """ self._widget.utm_x_edit.setValidator(QDoubleValidator()) self._widget.utm_y_edit.setValidator(QDoubleValidator()) self._widget.utm_phi_edit.setValidator(QDoubleValidator()) self._widget.utm_x_edit.textChanged.connect(self.utm_x_change) self._widget.utm_y_edit.textChanged.connect(self.utm_y_change) self._widget.utm_phi_edit.textChanged.connect(self.utm_phi_change) self._widget.joao_origin_utm_x_edit.setValidator(QDoubleValidator()) self._widget.joao_origin_utm_y_edit.setValidator(QDoubleValidator()) self._widget.joao_origin_utm_x_edit.textChanged.connect( self.joao_origin_utm_x_change) self._widget.joao_origin_utm_y_edit.textChanged.connect( self.joao_origin_utm_y_change) self._widget.indoor_checkBox_edit.stateChanged.connect( self.indoor_isCheck) self._widget.reset_init_map_file_button.released.connect( self.reset_init_change) self._widget.get_position_button.released.connect(self.get_pos_change) self._widget.get_pos_robot_x_edit.setValidator(QDoubleValidator()) self._widget.get_pos_robot_y_edit.setValidator(QDoubleValidator()) self._widget.get_pos_robot_yaw_edit.setValidator(QDoubleValidator()) # Buttons self._widget.map_to_rviz_send_file_button.released.connect( self.visualize_fiducials) self._widget.map_to_rviz_name_button.released.connect( self.get_file_map_to_rviz) """ ROS """ self.marker_pub = rospy.Publisher( '/fiducials_position', visualization_msgs.msg.MarkerArray, queue_size=10) # publish fiducials for a chosen map self.currentMap_marker_pub = rospy.Publisher( '/fiducials_position_current', visualization_msgs.msg.MarkerArray, queue_size=10) #publish currend used fiducials self.camera_pos_sub = rospy.Subscriber("/base_link_odom_camera_is1500", Odometry, self.publish_transform_pos) # self.camera_pos_sub = rospy.Subscriber("/position_camera_is1500", Odometry, self.publish_transform_pos) self.transform_cameraPos_pub = rospy.Publisher( '/transform_cameraPos_pub', Odometry, queue_size=1) self.tf_buffer = tf2_ros.Buffer() self.tf_listner = tf2_ros.TransformListener(self.tf_buffer) self.fromMetric_sub = rospy.Subscriber('/pointsFromMetric', GetPointsFromMetric, self.publish_metric_to_rviz) self.transform_metric_pub = rospy.Publisher( '/rviz_pointsFromMetric', visualization_msgs.msg.Marker, queue_size=10)
def __init__(self, updater, config): super(DoubleEditor, self).__init__(updater, config) loadUi(ui_num, self) # Handle unbounded doubles nicely if config['min'] != -float('inf'): self._min = float(config['min']) self._min_val_label.setText(str(self._min)) else: self._min = -1e10000 self._min_val_label.setText('-inf') if config['max'] != float('inf'): self._max = float(config['max']) self._max_val_label.setText(str(self._max)) else: self._max = 1e10000 self._max_val_label.setText('inf') if config['min'] != -float('inf') and config['max'] != float('inf'): self._func = lambda x: x self._ifunc = self._func else: self._func = lambda x: math.atan(x) self._ifunc = lambda x: math.tan(x) # If we have no range, disable the slider self.scale = (self._func(self._max) - self._func(self._min)) if self.scale <= 0: self.scale = 0 self.setDisabled(True) else: self.scale = 100 / self.scale # Set ranges self._slider_horizontal.setRange(self._get_value_slider(self._min), self._get_value_slider(self._max)) validator = QDoubleValidator(self._min, self._max, 8, self) validator.setLocale(QLocale(QLocale.C)) self._paramval_lineEdit.setValidator(validator) # Initialize to defaults self._paramval_lineEdit.setText(str(config['default'])) self._slider_horizontal.setValue( self._get_value_slider(config['default'])) # Make slider update text (locally) self._slider_horizontal.sliderMoved.connect(self._slider_moved) # Make keyboard input change slider position and update param server self._paramval_lineEdit.editingFinished.connect(self._text_changed) # Make slider update param server # Turning off tracking means this isn't called during a drag self._slider_horizontal.setTracking(False) self._slider_horizontal.valueChanged.connect(self._slider_changed) # Make the param server update selection self._update_signal.connect(self._update_gui) # Add special menu items self.cmenu.addAction(self.tr('Set to Maximum')).triggered.connect( self._set_to_max) self.cmenu.addAction(self.tr('Set to Minimum')).triggered.connect( self._set_to_min) self.cmenu.addAction(self.tr('Set to NaN')).triggered.connect( self._set_to_nan) # Don't process wheel events when not focused self._slider_horizontal.installEventFilter(self)
def __init__(self, *args, **kwargs): super(DoubleEditor, self).__init__(*args, **kwargs) ui_num = os.path.join( package_path, 'share', 'rqt_reconfigure', 'resource', 'editor_number.ui' ) loadUi(ui_num, self) if(len(self.descriptor.floating_point_range) > 0): # config step self._step = float(self.descriptor.floating_point_range[0].step) self._slider_horizontal.setSingleStep(self._step) self._slider_horizontal.setTickInterval(self._step) self._slider_horizontal.setPageStep(self._step) # Handle unbounded doubles nicely self._min = float(self.descriptor.floating_point_range[0].from_value) self._min_val_label.setText(str(self._min)) self._max = float(self.descriptor.floating_point_range[0].to_value) self._max_val_label.setText(str(self._max)) self._func = lambda x: x self._ifunc = self._func # If we have no range, disable the slider self.scale = (self._func(self._max) - self._func(self._min)) self.scale = 100 / self.scale # Set ranges self._slider_horizontal.setRange(self._get_value_slider(self._min), self._get_value_slider(self._max)) validator = QDoubleValidator(self._min, self._max, 8, self) validator.setLocale(QLocale(QLocale.C)) self._paramval_lineEdit.setValidator(validator) self._slider_horizontal.setValue( self._get_value_slider(self.parameter.value) ) # Make slider update text (locally) self._slider_horizontal.sliderMoved.connect(self._slider_moved) # Make slider update param server # Turning off tracking means this isn't called during a drag self._slider_horizontal.setTracking(False) self._slider_horizontal.valueChanged.connect(self._slider_changed) else: self._paramval_lineEdit.setValidator(QDoubleValidator()) self._min_val_label.setVisible(False) self._max_val_label.setVisible(False) self._slider_horizontal.setVisible(False) self._func = lambda x: math.atan(x) self._ifunc = lambda x: math.tan(x) self.scale = 0 # Initialize to defaults self._paramval_lineEdit.setText(str(self.parameter.value)) # Make keyboard input change slider position and update param server self._paramval_lineEdit.editingFinished.connect(self._text_changed) # Make the param server update selection self._update_signal.connect(self._update_gui) # Add special menu items self.cmenu.addAction(self.tr('Set to Maximum') ).triggered.connect(self._set_to_max) self.cmenu.addAction(self.tr('Set to Minimum') ).triggered.connect(self._set_to_min) if self.descriptor.read_only: self._paramval_lineEdit.setEnabled(False) self._slider_horizontal.setEnabled(False) self.cmenu.setEnabled(False)