svh_reset_gui.py
Go to the documentation of this file.
1 # -- BEGIN LICENSE BLOCK ----------------------------------------------
2 # This file is part of the SCHUNK SVH Driver suite.
3 #
4 # This program is free software licensed under the LGPL
5 # (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
6 # You can find a copy of this license in LICENSE folder in the top
7 # directory of the source code.
8 #
9 # Copyright 2014 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
10 # Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
11 #
12 # -- END LICENSE BLOCK ------------------------------------------------
13 
14 import os
15 import rospy
16 import rospkg
17 
18 from qt_gui.plugin import Plugin
19 from python_qt_binding import loadUi
20 from python_qt_binding.QtGui import QWidget
21 from python_qt_binding import QtGui
22 from std_msgs.msg import Int8, Empty
23 
25 
26  def __init__(self, context):
27  super(SVHResetGui, self).__init__(context)
28  # Give QObjects reasonable names
29  self.setObjectName('TrajectoryDesigner')
30 
31  # Process standalone plugin command-line arguments
32  from argparse import ArgumentParser
33  parser = ArgumentParser()
34  # Add argument(s) to the parser.
35  parser.add_argument("-q", "--quiet", action="store_true",
36  dest="quiet",
37  help="Put plugin in silent mode")
38  args, unknowns = parser.parse_known_args(context.argv())
39 
40  # Create QWidget
41  self._widget = QWidget()
42 
43  rp = rospkg.RosPack()
44  ui_file = os.path.join(rp.get_path('schunk_svh_driver'), 'resource', 'SVHResetGui.ui')
45  loadUi(ui_file, self._widget)
46  self._widget.setObjectName('SVHResetGuiUI')
47  if context.serial_number() > 1:
48  self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
49  # Add widget to the user interface
50  context.add_widget(self._widget)
51 
52  self._widget.connect_button.clicked[bool].connect(self.ConnectButton)
53  self._widget.reset_button.clicked[bool].connect(self.ResetButton)
54  self._widget.enable_button.clicked[bool].connect(self.EnableButton)
55 
56  self._widget.finger_select_box.addItem("All",-1)
57  self._widget.finger_select_box.addItem("Thumb Flexion",0)
58  self._widget.finger_select_box.addItem("Thumb Opposition",1)
59  self._widget.finger_select_box.addItem("Index Finger Distal",2)
60  self._widget.finger_select_box.addItem("Index Finger Proximal",3)
61  self._widget.finger_select_box.addItem("Middle Finger Distal",4)
62  self._widget.finger_select_box.addItem("Middle Finger Proximal",5)
63  self._widget.finger_select_box.addItem("Ring Finger",6)
64  self._widget.finger_select_box.addItem("Pinky Finger",7)
65  self._widget.finger_select_box.addItem("Finger Spread",8)
66 
67  self.reset_pub = rospy.Publisher('svh_controller/reset_channel', Int8, queue_size=1)
68  self.enable_pub = rospy.Publisher('svh_controller/enable_channel', Int8, queue_size=1)
69  self.connect_pub = rospy.Publisher('svh_controller/connect', Empty, queue_size=1)
70 
71 
72  def ConnectButton(self):
73  self.connect_pub.publish(Empty())
74  print "ConnectButton\n"
75 
76  def ResetButton(self):
77  selected = self._widget.finger_select_box.itemData(self._widget.finger_select_box.currentIndex())
78  self.reset_pub.publish(Int8(selected))
79  print "Reset\n" + str(selected)
80 
81 
82  def EnableButton(self):
83  selected = self._widget.finger_select_box.itemData(self._widget.finger_select_box.currentIndex())
84  self.enable_pub.publish(Int8(selected))
85  print "Enabled\n" + str(selected)
86 


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Mon Jun 10 2019 15:04:59