input_tool.py
Go to the documentation of this file.
00001 #import roslib; roslib.load_manifest('rcommander_core')
00002 import rospy
00003 from PyQt4.QtGui import *
00004 from PyQt4.QtCore import *
00005 import rcommander.tool_utils as tu
00006 import smach
00007 
00008 class MyInputTool(tu.ToolBase):
00009 
00010     def __init__(self, rcommander):
00011         tu.ToolBase.__init__(self, rcommander, 'node_with_input', 'My Input', InputState)
00012 
00013     def fill_property_box(self, pbox):
00014         formlayout = pbox.layout()
00015         self.source_box = QComboBox(pbox)
00016         self.source_box.addItem(' ')
00017         node_names = self.rcommander.outputs_of_type(float)
00018         for n in node_names:
00019             self.source_box.addItem(n)
00020         formlayout.addRow("&Sources", self.source_box)
00021 
00022     def new_node(self, name=None):
00023         if name == None:
00024             nname = self.name + str(self.counter)
00025         else:
00026             nname = name
00027         return InputState(nname, str(self.source_box.currentText()))
00028 
00029     def set_node_properties(self, my_node):
00030         self.source_box.setCurrentIndex(self.source_box.findText(my_node.remapping_for('myinput')))
00031 
00032     def reset(self):
00033         self.source_box.setCurrentIndex(self.source_box.findText(' '))
00034 
00035 class InputState(tu.StateBase):
00036 
00037     def __init__(self, name, source_input):
00038         tu.StateBase.__init__(self, name)
00039         self.set_remapping_for('myinput', source_input) 
00040 
00041     def get_smach_state(self):
00042         return InputSmachState()
00043 
00044 class InputSmachState(smach.State):
00045 
00046     def __init__(self):
00047         smach.State.__init__(self, outcomes=['done'], input_keys=['myinput'], output_keys=[])
00048 
00049     def execute(self, userdata):
00050         rospy.loginfo('got ' + str(userdata.myinput))
00051         return 'done'
00052 
00053 


rcommander_plain
Author(s): haidai
autogenerated on Thu Nov 28 2013 11:46:39