controller_interface.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 
00003 import sys
00004 from PyQt4 import QtCore, QtGui, uic
00005 import roslib
00006 roslib.load_manifest("rospy")
00007 import rospy
00008 
00009 from controller_gui import Ui_Frame as QTControllerGUIFrame
00010 
00011 from subprocess import Popen
00012 
00013 class ControllerGUIFrame(QtGui.QFrame):
00014     def __init__(self):
00015         super(ControllerGUIFrame, self).__init__()
00016         self.init_ui()
00017 
00018     def init_ui(self):
00019         self.ui = QTControllerGUIFrame()
00020         self.ui.setupUi(self)
00021 
00022         self.ui.start_button.clicked.connect(self.start_button_clk)
00023         self.ui.kill_button.clicked.connect(self.kill_button_clk)
00024         self.ui.restart_button.clicked.connect(self.restart_button_clk)
00025         self.ui.controller_combo.addItem("%s_arm_controller")
00026         self.ui.controller_combo.addItem("%s_cart")
00027         self.ui.controller_combo.addItem("%s_joint_controller_low")
00028 
00029     def start_button_clk(self):
00030         controller = str(self.ui.controller_combo.currentText())
00031         arm = str(self.ui.arm_combo.currentText())
00032         ctrl_filled = controller % arm[0]
00033         Popen("rosrun pr2_controller_manager pr2_controller_manager spawn %s" % ctrl_filled, 
00034               shell=True)
00035 
00036     def kill_button_clk(self):
00037         controller = str(self.ui.controller_combo.currentText())
00038         arm = str(self.ui.arm_combo.currentText())
00039         ctrl_filled = controller % arm[0]
00040         Popen("rosrun pr2_controller_manager pr2_controller_manager kill %s" % ctrl_filled, 
00041               shell=True)
00042 
00043     def restart_button_clk(self):
00044         controller = str(self.ui.controller_combo.currentText())
00045         arm = str(self.ui.arm_combo.currentText())
00046         ctrl_filled = controller % arm[0]
00047         Popen("rosrun pr2_controller_manager pr2_controller_manager kill %s" % ctrl_filled, 
00048               shell=True)
00049         rospy.sleep(0.1)
00050         Popen("rosrun pr2_controller_manager pr2_controller_manager spawn %s" % ctrl_filled, 
00051               shell=True)
00052 
00053 def main():
00054     rospy.init_node("controller_gui")
00055     app = QtGui.QApplication(sys.argv)
00056     frame = ControllerGUIFrame()
00057     frame.show()
00058     sys.exit(app.exec_())
00059 
00060 if __name__ == "__main__":
00061     main()


kelsey_sandbox
Author(s): kelsey
autogenerated on Wed Nov 27 2013 11:52:03