20 from python_qt_binding
import loadUi
21 from QtCore
import QEvent, QObject, Qt, QTimer, Slot, QThread, QPoint
22 from QtGui
import QCursor, QColor
23 from QtWidgets
import QWidget, QShortcut, QMessageBox, QFrame, QHBoxLayout, QCheckBox, QLabel, QFileDialog
25 from std_srvs.srv
import Empty
26 from diagnostic_msgs.msg
import DiagnosticArray
28 from sr_robot_msgs.srv
import SimpleMotorFlasher, SimpleMotorFlasherResponse
33 def __init__(self, parent, nb_motors_to_program):
34 QThread.__init__(self,
None)
40 firmware_path = self.parent._widget.txt_path.text()
41 for motor
in self.parent.motors:
42 if motor.checkbox.checkState() == Qt.Checked:
45 'SimpleMotorFlasher', SimpleMotorFlasher)
47 firmware_path.encode(
'ascii',
'ignore'), motor.motor_index)
48 except rospy.ServiceException, e:
49 self.failed[
'QString'].emit(
"Service did not process request: %s" % str(e))
52 if resp == SimpleMotorFlasherResponse.FAIL:
53 self.failed[
'QString'].emit(
"Bootloading motor " + +
"failed")
54 bootloaded_motors += 1
55 self.motor_finished[
'QPoint'].emit(QPoint(bootloaded_motors, 0.0))
60 def __init__(self, parent, motor_name, motor_index):
61 QFrame.__init__(self, parent)
69 motor_name +
" [" + str(motor_index) +
"]", self)
73 self.revision_label.setToolTip(
"Svn Revision")
76 self.setLayout(self.
layout)
82 A GUI plugin for bootloading the muscle drivers on the etherCAT muscle shadow hand 86 super(SrGuiBootloader, self).
__init__(context)
87 self.setObjectName(
'SrGuiBootloader')
92 ui_file = os.path.join(rospkg.RosPack().get_path(
93 'sr_gui_bootloader'),
'uis',
'SrBootloader.ui')
95 self._widget.setObjectName(
'SrMotorResetterUi')
96 context.add_widget(self.
_widget)
103 self.progress_bar.hide()
110 self._widget.btn_select_bootloader.pressed.connect(
113 self._widget.btn_select_none.pressed.connect(
119 Select a hex file to bootload. Hex files must exist in the released_firmaware folder 121 path_to_bootloader =
"~" 123 path_to_bootloader = os.path.join(rospkg.RosPack().get_path(
124 'sr_external_dependencies'),
'compiled_firmware',
'released_firmware')
127 "couldn't find the sr_edc_controller_configuration package")
129 filter_files =
"*.hex" 130 filename, _ = QFileDialog.getOpenFileName(
131 self._widget.motors_frame, self._widget.tr(
132 'Select hex file to bootload'),
135 self._widget.tr(filter_files))
139 self._widget.txt_path.setText(filename)
140 self._widget.btn_bootload.setEnabled(
True)
144 Find motors according to joint_to_motor_mapping mapping that must exist on the parameter server 145 and add to the list of Motor objects etherCAT hand node must be running 149 for motor_index
in range(0, 4):
153 elif motor_index == 1:
156 elif motor_index == 2:
159 elif motor_index == 3:
163 muscle_driver_name =
"Muscle driver " + str(motor_index)
165 self.motors_frame.layout().addWidget(motor, row, col)
166 self.motors.append(motor)
169 for status
in msg.status:
171 if motor.motor_name
in status.name:
172 for key_values
in status.values:
173 if "Firmware svn revision" in key_values.key:
174 server_current_modified = key_values.value.split(
" / ")
178 server_current_modified[0].strip())
180 palette = motor.revision_label.palette()
182 motor.revision_label.foregroundRole(), Qt.green)
183 if server_current_modified[0].strip() != server_current_modified[1].strip():
185 motor.revision_label.foregroundRole(), QColor(255, 170, 23))
186 motor.revision_label.setPalette(palette)
188 if "True" in server_current_modified[2]:
190 motor.revision_label.foregroundRole(), Qt.red)
191 motor.revision_label.setText(
192 "svn: " + server_current_modified[1] +
" [M]")
193 motor.revision_label.setPalette(palette)
195 motor.revision_label.setText(
196 " svn: " + server_current_modified[1])
197 motor.revision_label.setPalette(palette)
204 motor.checkbox.setCheckState(Qt.Checked)
211 motor.checkbox.setCheckState(Qt.Unchecked)
215 Start programming motors 217 self.progress_bar.reset()
218 nb_motors_to_program = 0
220 if motor.checkbox.checkState() == Qt.Checked:
221 nb_motors_to_program += 1
222 if nb_motors_to_program == 0:
224 self.
_widget,
"Warning",
"No motors selected for resetting.")
226 self.progress_bar.setMaximum(nb_motors_to_program)
231 self._widget.motor_bootloader.motor_finished[
'QPoint'].connect(self.
one_motor_finished)
234 self._widget.setCursor(Qt.WaitCursor)
235 self.motors_frame.setEnabled(
False)
236 self._widget.btn_select_all.setEnabled(
False)
237 self._widget.btn_select_none.setEnabled(
False)
238 self.progress_bar.show()
239 self._widget.btn_bootload.hide()
241 self.motor_bootloader.start()
244 self.progress_bar.setValue(int(point.x()))
248 Programming of motors completed 250 self.motors_frame.setEnabled(
True)
251 self._widget.btn_select_all.setEnabled(
True)
252 self._widget.btn_select_none.setEnabled(
True)
253 self._widget.setCursor(Qt.ArrowCursor)
254 self.progress_bar.hide()
255 self._widget.btn_bootload.show()
258 QMessageBox.warning(self._widget.motors_frame,
"Warning", message)
262 self._publisher.unregister()
def diagnostics_callback(self, msg)
def shutdown_plugin(self)
def on_select_bootloader_pressed(self)
def on_bootload_pressed(self)
def _unregisterPublisher(self)
def on_select_all_pressed(self)
def on_select_none_pressed(self)
def finished_programming_motors(self)
def failed_programming_motors(self, message)
def __init__(self, parent, nb_motors_to_program)
def __init__(self, context)
def save_settings(self, global_settings, perspective_settings)
def restore_settings(self, global_settings, perspective_settings)
def __init__(self, parent, motor_name, motor_index)
def one_motor_finished(self, point)
def populate_motors(self)