Esempio n. 1
0
    def __init__(self, sequence, config):
        super(ObjectSelectionControl, self).__init__(sequence, config)

        self_dir = os.path.dirname(os.path.realpath(__file__))
        self.ui_dir = os.path.join(self_dir, '../../ui')

        # info bar UI setup
        self.info_bar_widget.step_name_label.setText(self.config_dict['label'])

        # info area UI setup
        self.info_area_widget = QWidget()
        ui_file = os.path.join(self.ui_dir, 'ObjectSelectionInfoArea.ui')
        loadUi(ui_file, self.info_area_widget)

        self.init_step_info_area()

        self.connect(self, SIGNAL('objectSelection(PyQt_PyObject)'),
                     self.on_object_selection_request)

        self.feedback_subscription()

        #Setup a server to let the object_selection actionlib server ask for the object to select from a list
        srvname = 'decision_services/object_selection'
        self.object_selection_server = rospy.Service(
            srvname, ObjectSelectionFromList, self.object_selection_callback)
Esempio n. 2
0
    def __init__(self):
        super(NumSatWidget, self).__init__()
        self.setObjectName('NumSatWidget')

        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'NumSat.ui')
        loadUi(ui_file, self)
        self.sub = rospy.Subscriber('/moos/numsat', Int8, self.onUpd)
        self.palette_is_normal = True
Esempio n. 3
0
    def __init__(self, context):
        super(SrGuiManipulation, self).__init__(context)

        self.setObjectName('SrGuiManipulation')
        # Set by call to process_collision_map()
        self.collision_support_surface_name = None
        self.raw_objects = None
        self.found_objects = {}
        self.unknown_object_counter = 1  #starts at 1 as it's only used for display
        self.service_tabletop_collision_map = None
        self.service_db_get_model_description = None
        self.service_object_detector = None

        self_dir = os.path.dirname(os.path.realpath(__file__))
        self.config_dir = os.path.join(self_dir, '../config')
        self.ui_dir = os.path.join(self_dir, '../../ui')

        # UI setup
        self._widget = QWidget()
        ui_file = os.path.join(self.ui_dir, 'SrGuiManipulation.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('SrGuiManipulationUi')
        context.add_widget(self._widget)

        self.object_chooser = ObjectChooser(self._widget, self,
                                            "Objects Detected")
        self._widget.chooser_layout.addWidget(self.object_chooser)
        self.object_chooser.draw()

        # Bind button clicks
        self._widget.btn_detect_objects.pressed.connect(self.detect_objects)
        self._widget.btn_collision_map.pressed.connect(
            self.process_collision_map)
        self._widget.btn_collision_map.setEnabled(False)
        self._widget.btn_start_grab_position.pressed.connect(
            self.start_grab_position)
        #        self._widget.btn_zero_position.pressed.connect(self.zero_position)
        self._widget.btn_zero_position.pressed.connect(self.redo_place)
        self.robot_lib_eth = EtherCAT_Hand_Lib()

        # Guillaume: Currently removed because requires ethercat to be active to run, ethercat does exist in sim
        #        if not self.robot_lib_eth.activate_joint_states():
        #            logerr("The EtherCAT Hand node doesn't seem to be running")
        #        self.robot_lib_can = ShadowHand_ROS()
        #        if not self.robot_lib_can.has_arm():
        #            logerr("The CAN Arm node doesn't seem to be running")

        self.init_services()
        self.init_joint_pubs()
    def __init__(self, sequence, config):
        super(ObjectRecognitionControl, self).__init__(sequence, config)

        self_dir = os.path.dirname(os.path.realpath(__file__))
        self.ui_dir = os.path.join(self_dir, '../../ui')

        # info bar UI setup
        self.info_bar_widget.step_name_label.setText(self.config_dict['label'])

        # info area UI setup
        self.info_area_widget = QWidget()
        ui_file = os.path.join(self.ui_dir, 'ObjectRecognitionInfoArea.ui')
        loadUi(ui_file, self.info_area_widget)

        self.feedback_subscription()
Esempio n. 5
0
    def __init__(self, context):
        super(SrMoveObject, self).__init__(context)
        self.setObjectName('SrMoveObject')

        self._publisher = None
        self._widget = QWidget()

        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../uis/SrMoveObjects.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('SrMoveObjectsUi')
        context.add_widget(self._widget)

        #attaching the button press event to their actions
        self._widget.btnRefreshList.pressed.connect(self.on_refresh_list_clicked_)
        self._widget.btnZero.pressed.connect(self.on_zero_clicked_)
        self._widget.btnOpposite.pressed.connect(self.on_opposite_clicked_)
        self._widget.btn_wrench.pressed.connect(self.on_apply_wrench_clicked_)
        self._widget.btnSetToPos.pressed.connect(self.on_set_to_position_clicked_)
Esempio n. 6
0
    def __init__(self):
        super(MatPlotWidget, self).__init__()
        self.setObjectName("MatPlotWidget")

        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "MatPlot.ui")
        loadUi(ui_file, self, {"MatDataPlot": MatDataPlot})

        self.subscribe_topic_button.setEnabled(False)

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

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

        # setup drag 'n drop
        self.data_plot.dropEvent = self.dropEvent
        self.data_plot.dragEnterEvent = self.dragEnterEvent

        # init and start update timer for plot
        self._update_plot_timer = QTimer(self)
        self._update_plot_timer.timeout.connect(self.update_plot)
        self._update_plot_timer.start(40)

        # connect combobox
        self.comboBox.currentIndexChanged.connect(self.on_combo_box_changed)

        # params (colors)
        self.texts = {}
        self.data_plot._colors = {}
        self.sub_topics = {}
        n = 0
        for tag in rospy.get_param("/tags"):
            self.texts[tag] = rospy.get_param("/" + tag + "_text")
            color = [float(i) for i in list(rospy.get_param("/" + tag + "_color").split(","))]
            self.data_plot._colors[self.texts[tag]] = color
            if n != 0:  # dont have a topic for the reference
                self.sub_topics[tag] = "/error_mags/" + rospy.get_param("/tags")[0] + "_ref/" + tag + "_tgt/mag_horiz"
            else:
                n += 1

        # start with subscription to filtered
        self.add_topic("/error_mags/rtk_ref/flt_tgt/mag_horiz")
Esempio n. 7
0
    def __init__(self, sequence, config):
        QObject.__init__(self)
        #Will contain the results of the execution of this step
        self.results = None
        #Will contain the commands given by the user. This will be considered by subsequent steps
        self.commands = None
        #Dictionary of all the steps. This allows this object to have access to the info (results, user commands) from the other steps
        self.sequence_dict = sequence
        #Dictionary containing the configuration (name, tag, etc) for this step. This info comes from the yaml file
        self.config_dict = config
        #Information bar for this step shown in the sequence list. This will be loaded by a subclass
        self.info_bar_widget = None
        #Information area for this step shown when this step is active or selected. This will be loaded by a subclass
        self.info_area_widget = None

        #Listener for the feedback topic of this step's actionlib
        self.feedback_listener = None

        self_dir = os.path.dirname(os.path.realpath(__file__))
        self.bar_ui_dir = os.path.join(self_dir, '../../ui')
        self.ui_dir = None

        # info bar UI setup
        self.info_bar_widget = QFrame()
        ui_file = os.path.join(self.bar_ui_dir, 'StepBar.ui')
        loadUi(ui_file, self.info_bar_widget)
        #Connect info bar events
        self.info_bar_widget.show_checkBox.stateChanged.connect(
            self.on_show_checkbox_state_changed)
        self.connect(self, SIGNAL('changeProgressBarValue(int)'),
                     self.on_change_progress_bar_value)

        #Run and start buttons in the bar will be initially disabled as the first time we run the sequence
        #it only makes sense to start from the beginning
        self.info_bar_widget.btn_start.setEnabled(False)
        self.info_bar_widget.btn_run.setEnabled(False)
        self.info_bar_widget.btn_start.pressed.connect(
            self.on_btn_start_pressed)
        self.info_bar_widget.btn_run.pressed.connect(self.on_btn_run_pressed)
Esempio n. 8
0
    def __init__(self, context):
        super(SrGuiEventSequence, self).__init__(context)

        self.setObjectName('SrGuiEventSequence')

        self_dir = os.path.dirname(os.path.realpath(__file__))
        self.config_dir = os.path.join(self_dir, '../../config')
        self.ui_dir = os.path.join(self_dir, '../../ui')

        # UI setup
        self._widget = QWidget()
        ui_file = os.path.join(self.ui_dir, 'SrGuiEventSequence.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('SrGuiEventSequenceUi')
        context.add_widget(self._widget)

        #Step related
        self.current_step = None
        #To indicate that the step 0 hasn't been executed yet
        self.first_time = True
        #this list will be filled using the info in the yaml file
        self.step_names_list = []
        self.step_index_dict = {}

        #Dictionary containing the SequenceStep objects for every step in the sequence
        self.sequence_dict = {}
        #Dictionary containing the configuration of the steps read from the yaml file
        self.config_data = None
        #Read steps configuration from yaml file
        yaml_file = os.path.join(self.config_dir, 'sequence_config.yaml')
        try:
            self.config_data = yaml.load(open(yaml_file))
        except IOError as err:
            QMessageBox.warning(
                self._widget, "Warning",
                "Failed to load '" + yaml_file + "': " + str(err))
            raise

        #Autorun
        if self._widget.autorun_checkBox.isChecked():
            rospy.set_param('/master_controller/autorun', 1)
        else:
            rospy.set_param('/master_controller/autorun', 0)

        #Create the Master controller Client
        for (i, step) in enumerate(self.config_data['steps']):
            self.step_names_list.append(step['name'])
            self.step_index_dict[step['name']] = i

        self.master_controller_client = MasterControllerClient(
            self.step_names_list)
        #connect the signal to notify goal_done (all the steps in the sequence finished somehow)
        self.connect(self.master_controller_client,
                     SIGNAL('goalDone(PyQt_PyObject)'), self.on_MC_goal_done)
        #connect the signal to notify goal_done (all the steps in the sequence finished somehow)
        self.connect(self.master_controller_client,
                     SIGNAL('currentStepReceived(PyQt_PyObject)'),
                     self.on_MC_current_step_received)
        #connect the signal that notifies that the user should choose the next step to be run
        self.connect(self.master_controller_client,
                     SIGNAL('nextStepSelection()'),
                     self.on_MC_select_next_step)

        #Import and create an object of the class specified in the yaml for every step
        for step in self.config_data['steps']:
            roslib.load_manifest(step['package'])
            mod = __import__(step['package'] + '.' + step['module'],
                             fromlist=[step['class']])
            klass = getattr(mod, step['class'])
            self.sequence_dict[step['name']] = klass(self.sequence_dict, step)
            #Load the info bar widget for every step
            self._widget.step_list_layout.addWidget(
                self.sequence_dict[step['name']].info_bar_widget)
            #connect the signal to show the info for that step
            self.connect(self.sequence_dict[step['name']],
                         SIGNAL('showStateChanged(int, PyQt_PyObject)'),
                         self.on_show_state_changed)
            #connect the signal to start the sequence (using this step)
            self.connect(self.sequence_dict[step['name']],
                         SIGNAL('startStepPressed(PyQt_PyObject)'),
                         self.on_start_sequence_signal)
            #connect the signal to tell the MC that this step will be next
            self.connect(self.sequence_dict[step['name']],
                         SIGNAL('runStepPressed(PyQt_PyObject)'),
                         self.on_run_this_step_signal)
            #connect the signal to print a log to the general info area
            self.connect(
                self.sequence_dict[step['name']],
                SIGNAL(
                    'printGeneralInfoAreaLog(PyQt_PyObject, PyQt_PyObject)'),
                self.on_print_general_info_area_log)
            #connect the signal to tell the bar to make the run button visible
            self.connect(
                self, SIGNAL('showRunStepButtons(PyQt_PyObject)'),
                self.sequence_dict[step['name']].on_show_run_btn_signal)
            #connect the signal to tell the bar to make the run button visible
            self.connect(
                self, SIGNAL('showStartSequenceButtons(PyQt_PyObject)'),
                self.sequence_dict[step['name']].on_show_start_btn_signal)

        #Add a vertical spacer after the bars, to hold them together in the beginning of the vertical layout
        self._widget.step_list_layout.addStretch(0)

        self.general_info_area_widget = QWidget()
        ui_file = os.path.join(self.ui_dir, 'GeneralInfoArea.ui')
        loadUi(ui_file, self.general_info_area_widget)
        self._widget.general_info_area.addWidget(self.general_info_area_widget)

        #Load info area for the first step (maybe we shouldn't before it's running, but we'll show it for the time being)
        for step in self.config_data['steps']:
            if self.sequence_dict[step['name']].info_area_widget != None:
                self.current_step = step['name']
                self.shown_step_widget = self.sequence_dict[
                    self.current_step].info_area_widget
                self._widget.step_info_area.addWidget(self.shown_step_widget)
                break

        # Bind button clicks
        self._widget.btn_start.pressed.connect(self.on_btn_start_pressed)
        self._widget.btn_cancel.pressed.connect(self.on_btn_cancel_pressed)
        self._widget.btn_next.pressed.connect(self.on_btn_next_pressed)
        #Connect autorun check/uncheck events
        self._widget.autorun_checkBox.stateChanged.connect(
            self.on_autorun_checkbox_state_changed)

        #connect the signal to make the next (run) button visible
        self.connect(self, SIGNAL('showRunStepButtons(PyQt_PyObject)'),
                     self.on_show_next_btn_signal)
        #connect the signal to make the start button visible
        self.connect(self, SIGNAL('showStartSequenceButtons(PyQt_PyObject)'),
                     self.on_show_start_btn_signal)

        #We'll emit a signal to hide all the buttons to choose the next step
        self.emit(SIGNAL('showRunStepButtons(PyQt_PyObject)'), False)