def __init__(self, context):
        Plugin.__init__(self, context)
        self.setObjectName('RqtGraspViewer')

        self._widget = QWidget()

        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_grasp_viewer'),
                               'ui', 'RqtGraspViewer.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('RqtGraspViewerUi')
        context.add_widget(self._widget)

        main_layout = QHBoxLayout()
        self._default_labels = [
            "obj_id", "object", "grasp_id", "grasp", "quality"
        ]
        self._filemodel = QStandardItemModel(0, 5)
        self._filemodel.setHorizontalHeaderLabels(self._default_labels)

        self._table_view = QTableView()
        self._table_view.setModel(self._filemodel)
        self._table_view.resizeColumnsToContents()

        main_layout.addWidget(self._table_view)
        self._widget.scrollarea.setLayout(main_layout)

        self.init_services()
        self.init_subscribers()

        # self._table_view.clicked.connect(self.on_table_view_clicked)
        self._table_view.selectionModel().selectionChanged.connect(
            self.on_table_view_select)
    def __init__(self, context):
        Plugin.__init__(self, context)
        self.setObjectName('RqtGraspViewer')

        self._widget = QWidget()

        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_grasp_viewer'), 'ui', 'RqtGraspViewer.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('RqtGraspViewerUi')
        context.add_widget(self._widget)

        main_layout = QHBoxLayout()
        self._default_labels = ["obj_id", "object", "grasp_id", "grasp", "quality"]
        self._filemodel = QStandardItemModel(0, 5)
        self._filemodel.setHorizontalHeaderLabels(self._default_labels)

        self._table_view = QTableView()
        self._table_view.setModel(self._filemodel)
        self._table_view.resizeColumnsToContents()

        main_layout.addWidget(self._table_view)
        self._widget.scrollarea.setLayout(main_layout)

        self.init_services()
        self.init_subscribers()

        # self._table_view.clicked.connect(self.on_table_view_clicked)
        self._table_view.selectionModel().selectionChanged.connect(self.on_table_view_select)
Пример #3
0
    def __init__(self, context):
        Plugin.__init__(self, context)
        self.setObjectName("MissionPlugin")

        self._plans = None
        self._widget = QWidget()
        loadUi(os.path.join(uipath, "missionplugin.ui"), self._widget)
        context.add_widget(self._widget)

        self._widget.findChild(QPushButton, "addButton").clicked.connect(self._on_add)
        self._widget.findChild(QPushButton, "removeButton").clicked.connect(self._on_remove)
        self._widget.findChild(QPushButton, "skipToButton").clicked.connect(self._on_skip_to)
        self._widget.findChild(QPushButton, "startButton").clicked.connect(self._on_start)
        self._widget.findChild(QPushButton, "stopButton").clicked.connect(self._on_stop)

        self.on_plans_changed.connect(self._on_plans)
        self._plans_sub = rospy.Subscriber("mission/plans", PlansStamped, lambda msg: self.on_plans_changed.emit(msg))
        self._modify_srv = rospy.ServiceProxy("mission/modify_plan", ModifyPlan)
        self._run_action = None
    def __init__(self, context):
        Plugin.__init__(self, context)
        self.setObjectName('RqtMekaPostureRecorder')

        self._widget = QWidget()
        self._group_check_box = {}
        self._group_spinbox = {}

        self._file_path = None

        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_meka_posture_recorder'), 'ui', 'RqtMekaPostureRecorder.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('RqtMekaPostureRecorderUi')
        context.add_widget(self._widget)

        self._cm_prefix = "meka_roscontrol"
        self._recorder_name = "meka_posture_recorder"
        
        # find the existing groups (running controllers)
        self._group_list = []
        self.init_group_list()
        
        nb_group = len(self._group_list)
        if nb_group == 0:
            rospy.logerr("No controllers available.")
            return
        
        self._postureCount = 0
        self._verticalHeader = []
        
        # add a column and a checkbox per group
        
        hlayout = QHBoxLayout()
        vlayout = QVBoxLayout()
        all_group_layout = QHBoxLayout()
                
        self._tree_widget = QTreeWidget()
        self._tree_widget.setColumnCount(nb_group + 1)
       
        self._tree_widget.setHeaderLabels(["    "] + self._group_list)
        

        group_item = QTreeWidgetItem(["group"])
        self._tree_widget.addTopLevelItem(group_item)
        time_item = QTreeWidgetItem(["time_from_start"])
        self._tree_widget.addTopLevelItem(time_item)
        
        for index_item, group_name in enumerate(self._group_list):
            check_box = QCheckBox("enable")
            self._tree_widget.setItemWidget(group_item, index_item + 1, check_box)
            self._group_check_box[group_name] = check_box
            spinbox = QDoubleSpinBox()
            spinbox.setValue(2.0)
            spinbox.setSingleStep(0.5)
            spinbox.setMinimum(0.0)
            self._tree_widget.setItemWidget(time_item, index_item + 1, spinbox)
            self._group_spinbox[group_name] = spinbox

        self._postures_item = QTreeWidgetItem(["postures"])
        self._tree_widget.addTopLevelItem(self._postures_item)

        vlayout.addWidget(self._tree_widget)
        hlayout.addLayout(vlayout)
        self._widget.scrollarea.setLayout(hlayout)


        self._client = {}
        self.init_services("start_record", PostureRecordStart)
        self.init_services("stop_record", PostureRecordStop)
        self.init_services("save", PostureRecordSave)
        self.init_services("add_waypoint", PostureRecordAddWaypoint)
        self.init_services("get_all_postures", PostureRecordGetAllPostures)
        
        self._widget.btn_new_posture.clicked.connect(self.on_new_posture_clicked)
        self._widget.btn_save_postures.clicked.connect(self.on_save_postures_clicked)
        self._widget.btn_add_wp.clicked.connect(self.on_add_wp_clicked)
        self._widget.btn_store_posture.clicked.connect(self.on_store_posture_clicked)
        self._widget.btn_browse.clicked.connect(self.on_btn_file_path_clicked)
        
        self._widget.chk_select_all.stateChanged.connect(self.on_check_all_changed)
        self._widget.time_from_start.valueChanged.connect(self.on_time_from_start_changed)
        
        self.init_postures()
    def __init__(self, context):
        Plugin.__init__(self, context)
        self.setObjectName('RqtMekaPostureEditor')

        self._widget = QWidget()
        self._filemodel = {}
        self._table_view = {}
        self._vh = {}
        self._file_path = None

        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_meka_posture_editor'), 'ui', 'RqtMekaPostureEditor.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('RqtMekaPostureEditorUi')
        context.add_widget(self._widget)

        self._cm_prefix = "meka_roscontrol"
        self._client = {}
        
        # find the existing groups (running controllers)
        self._group_list = []
        self.init_group_list()
        self._current_posture_dict = {}
        self._posture_unstored = {}
        self._posture_modified = {}
        self._table_initialized = {}
        self._current_posture_name = None
        
        nb_group = len(self._group_list)
        if nb_group == 0:
            rospy.logerr("No controllers available.")
            return
        
        self._postureCount = 0
        self._verticalHeader = []
        
        # add a one column table per group
        
        all_group_layout = QHBoxLayout()
        
        for group_name in self._group_list:
            self._filemodel[group_name] = QStandardItemModel(0, 1)
            self._filemodel[group_name].setHorizontalHeaderLabels([group_name])
            self._table_view[group_name] = QTableView()
	    self._table_view[group_name].setModel(self._filemodel[group_name])
            self._table_view[group_name].resizeColumnsToContents()
            self._vh[group_name] = self._table_view[group_name].verticalHeader()
	    self._vh[group_name].sectionResized.connect(partial(self.on_row_resized, group_name))
            all_group_layout.addWidget(self._table_view[group_name])
                
        self._widget.scrollarea.setLayout(all_group_layout)
        
        #temporary set a value there
        self._widget.edit_file_path.setText("/vol/meka/stable/share/meka_posture_execution/cfg/postures.yml")
        
        self._widget.btn_load_postures.clicked.connect(self.on_load_postures_clicked)
        self._widget.btn_save_postures.clicked.connect(self.on_save_postures_clicked)
        self._widget.btn_execute.clicked.connect(self.on_execute_clicked)
        self._widget.btn_stop.clicked.connect(self.on_stop_clicked)
        self._widget.btn_undo_mod.clicked.connect(self.on_undo_modification_clicked)
        self._widget.btn_browse.clicked.connect(self.on_btn_file_path_clicked)
        
        self._widget.treeWidget.itemClicked.connect(self.on_posture_clicked)
        
        
        self._mp = MekaPosture("myposture")