Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 import os
00015 import rospy
00016 import rospkg
00017
00018 from qt_gui.plugin import Plugin
00019 from python_qt_binding import loadUi
00020 from python_qt_binding.QtGui import QWidget
00021 from python_qt_binding import QtGui
00022 from std_msgs.msg import Int8, Empty
00023
00024 class SVHResetGui(Plugin):
00025
00026 def __init__(self, context):
00027 super(SVHResetGui, self).__init__(context)
00028
00029 self.setObjectName('TrajectoryDesigner')
00030
00031
00032 from argparse import ArgumentParser
00033 parser = ArgumentParser()
00034
00035 parser.add_argument("-q", "--quiet", action="store_true",
00036 dest="quiet",
00037 help="Put plugin in silent mode")
00038 args, unknowns = parser.parse_known_args(context.argv())
00039
00040
00041 self._widget = QWidget()
00042
00043 rp = rospkg.RosPack()
00044 ui_file = os.path.join(rp.get_path('schunk_svh_driver'), 'resource', 'SVHResetGui.ui')
00045 loadUi(ui_file, self._widget)
00046 self._widget.setObjectName('SVHResetGuiUI')
00047 if context.serial_number() > 1:
00048 self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
00049
00050 context.add_widget(self._widget)
00051
00052 self._widget.connect_button.clicked[bool].connect(self.ConnectButton)
00053 self._widget.reset_button.clicked[bool].connect(self.ResetButton)
00054 self._widget.enable_button.clicked[bool].connect(self.EnableButton)
00055
00056 self._widget.finger_select_box.addItem("All",-1)
00057 self._widget.finger_select_box.addItem("Thumb Flexion",0)
00058 self._widget.finger_select_box.addItem("Thumb Opposition",1)
00059 self._widget.finger_select_box.addItem("Index Finger Distal",2)
00060 self._widget.finger_select_box.addItem("Index Finger Proximal",3)
00061 self._widget.finger_select_box.addItem("Middle Finger Distal",4)
00062 self._widget.finger_select_box.addItem("Middle Finger Proximal",5)
00063 self._widget.finger_select_box.addItem("Ring Finger",6)
00064 self._widget.finger_select_box.addItem("Pinky Finger",7)
00065 self._widget.finger_select_box.addItem("Finger Spread",8)
00066
00067 self.reset_pub = rospy.Publisher('svh_controller/reset_channel', Int8, queue_size=1)
00068 self.enable_pub = rospy.Publisher('svh_controller/enable_channel', Int8, queue_size=1)
00069 self.connect_pub = rospy.Publisher('svh_controller/connect', Empty, queue_size=1)
00070
00071
00072 def ConnectButton(self):
00073 self.connect_pub.publish(Empty())
00074 print "ConnectButton\n"
00075
00076 def ResetButton(self):
00077 selected = self._widget.finger_select_box.itemData(self._widget.finger_select_box.currentIndex())
00078 self.reset_pub.publish(Int8(selected))
00079 print "Reset\n" + str(selected)
00080
00081
00082 def EnableButton(self):
00083 selected = self._widget.finger_select_box.itemData(self._widget.finger_select_box.currentIndex())
00084 self.enable_pub.publish(Int8(selected))
00085 print "Enabled\n" + str(selected)
00086