Go to the documentation of this file.00001
00002 from PyQt4.QtGui import *
00003 from PyQt4.QtCore import *
00004 import rcommander.tool_utils as tu
00005
00006 import pr2_common_action_msgs.msg as ca
00007 import rospy
00008
00009 class TuckTool(tu.ToolBase):
00010
00011 def __init__(self, rcommander):
00012 tu.ToolBase.__init__(self, rcommander, 'tuck', 'Tuck', TuckState)
00013
00014 def fill_property_box(self, pbox):
00015 formlayout = pbox.layout()
00016
00017
00018 self.tuck_left = QComboBox(pbox)
00019 self.tuck_left.addItem('True')
00020 self.tuck_left.addItem('False')
00021
00022 self.tuck_right = QComboBox(pbox)
00023 self.tuck_right.addItem('True')
00024 self.tuck_right.addItem('False')
00025
00026 formlayout.addRow("&Left Arm", self.tuck_left)
00027 formlayout.addRow("&Right Arm", self.tuck_right)
00028 pbox.update()
00029
00030 def new_node(self, name=None):
00031 left = ('True' == str(self.tuck_left.currentText()))
00032 right = ('True' == str(self.tuck_right.currentText()))
00033 if name == None:
00034 nname = self.name + str(self.counter)
00035 else:
00036 nname = name
00037 return TuckState(nname, left, right)
00038
00039 def set_node_properties(self, node):
00040 self.tuck_left.setCurrentIndex(self.tuck_left.findText(str(node.tuck_left)))
00041 self.tuck_right.setCurrentIndex(self.tuck_right.findText(str(node.tuck_right)))
00042
00043 def reset(self):
00044 self.tuck_left.setCurrentIndex(self.tuck_left.findText('True'))
00045 self.tuck_right.setCurrentIndex(self.tuck_right.findText('True'))
00046
00047
00048 class TuckState(tu.SimpleStateBase):
00049
00050 def __init__(self, name, tuck_left, tuck_right):
00051 tu.SimpleStateBase.__init__(self, name, \
00052 'tuck_arms', ca.TuckArmsAction,
00053 goal_cb_str = 'ros_goal')
00054
00055 self.tuck_left = tuck_left
00056 self.tuck_right = tuck_right
00057
00058 def ros_goal(self, userdata, default_goal):
00059 goal = ca.TuckArmsGoal()
00060 goal.tuck_left = self.tuck_left
00061 goal.tuck_right = self.tuck_right
00062 rospy.loginfo('TuckState: left %s right %s'% (str(goal.tuck_left), str(goal.tuck_right)))
00063 return goal
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074