23 from PyQt5.uic
import loadUi
25 from PyQt5.QtCore
import QEvent, QObject, Qt, QTimer, Slot
26 from PyQt5.QtGui
import QColor
27 from PyQt5.QtWidgets
import QWidget, QShortcut, QTreeWidgetItem, QFileDialog, QMessageBox
28 from PyQt5.QtCore
import QVariant
35 A rosgui plugin for calibrating the Shadow EtherCAT Hand 39 super(SrHandCalibration, self).
__init__(context)
40 self.setObjectName(
'SrHandCalibration')
45 ui_file = os.path.join(rospkg.RosPack().get_path(
46 'sr_gui_hand_calibration'),
'uis',
'SrHandCalibration.ui')
48 self._widget.setObjectName(
'SrHandCalibrationUi')
49 context.add_widget(self.
_widget)
51 self._widget.tree_calibration.setColumnCount(4)
52 self._widget.tree_calibration.setHeaderLabels(
53 [
"Finger",
"Joint",
"Raw Value",
"Calibrated Value"])
66 Create tree with calibrations 68 self._widget.tree_calibration.clear()
71 tree_widget=self._widget.tree_calibration, progress_bar=self._widget.progress, old_version=old_version)
72 if not self.hand_model.is_active:
76 self._widget.tree_calibration.expandAll()
78 for col
in range(0, self._widget.tree_calibration.columnCount()):
79 self._widget.tree_calibration.resizeColumnToContents(col)
83 Save calibration to a yaml file. 84 sr_ethercat_hand_config package must be installed 90 config_dir = rospy.get_param(
'config_dir',
'')
92 path_to_config = os.path.join(rospkg.RosPack().get_path(
93 'sr_ethercat_hand_config'),
'calibrations', config_dir)
95 rospy.logwarn(
"couldnt find the sr_ethercat_hand_config package")
97 filter_files =
"*.yaml" 98 filename, _ = QFileDialog.getOpenFileName(
99 self._widget.tree_calibration, self._widget.tr(
'Save Calibration'),
102 self._widget.tr(filter_files))
107 if not self.hand_model.is_calibration_complete():
108 btn_pressed = QMessageBox.warning(
109 self._widget.tree_calibration,
"Warning",
"Are you sure you want to save this incomplete calibration?" 110 " The uncalibrated values will be saved as a flat map (the calibrated value will always be 0)",
111 buttons=QMessageBox.Ok | QMessageBox.Cancel)
113 if btn_pressed == QMessageBox.Cancel:
115 self.hand_model.save(filename)
119 Load calibration from a yaml file. 120 sr_ethercat_hand_config package must be installed 126 config_dir = rospy.get_param(
'config_dir',
'')
128 path_to_config = os.path.join(rospkg.RosPack().get_path(
'sr_ethercat_hand_config'),
129 'calibrations', config_dir)
131 rospy.logwarn(
"couldn't find the sr_ethercat_hand_config package")
133 filter_files =
"*.yaml" 134 filename, _ = QFileDialog.getOpenFileName(self._widget.tree_calibration,
135 self._widget.tr(
'Load Calibration'),
136 self._widget.tr(path_to_config),
137 self._widget.tr(filter_files))
142 self.hand_model.load(filename)
146 calibrate the first joint of each finger 148 self.hand_model.calibrate_joint0s(self._widget.btn_joint_0s)
151 if self._widget.cb_old_version.isChecked():
158 self._publisher.unregister()
161 self.hand_model.unregister()
def _unregisterPublisher(self)
def btn_load_clicked_(self)
def save_settings(self, global_settings, perspective_settings)
def cb_state_changed_(self)
def shutdown_plugin(self)
def btn_joint_0s_clicked_(self)
def populate_tree(self, old_version=False)
def __init__(self, context)
def restore_settings(self, global_settings, perspective_settings)
def btn_save_clicked_(self)