spine_tool.py
Go to the documentation of this file.
00001 import roslib; roslib.load_manifest('rcommander')
00002 import rospy
00003 from PyQt4.QtGui import *
00004 from PyQt4.QtCore import *
00005 import tool_utils as tu
00006 import smach
00007 import pr2_controllers_msgs.msg as pm
00008 
00009 
00010 class SpineTool(tu.ToolBase):
00011 
00012     def __init__(self, rcommander):
00013         tu.ToolBase.__init__(self, rcommander, 'move_spine', 'Spine')
00014 
00015     def fill_property_box(self, pbox):
00016         formlayout = pbox.layout()
00017         self.spine_box = tu.SliderBox(pbox, 15., 29.5, 1., .05, 'spine', units='cm')
00018         formlayout.addRow('&Height', self.spine_box.container)
00019         pbox.update()
00020 
00021     def _create_node(self, name=None):
00022         if name == None:
00023             nname = self.name + str(self.counter)
00024         else:
00025             nname = name
00026         return SpineState(nname, self.spine_box.value()/100.)
00027 
00028     def _node_selected(self, my_node):
00029         self.spine_box.set_value(my_node.position*100.)
00030 
00031     def reset(self):
00032         self.spine_box.set_value(15.)
00033 
00034     def get_smach_class(self):
00035         return SpineState
00036 
00037 class SpineState(tu.SimpleStateBase): 
00038 
00039     def __init__(self, name, position):
00040         tu.SimpleStateBase.__init__(self, name, \
00041                 'torso_controller/position_joint_action', 
00042                 pm.SingleJointPositionAction, 
00043                 goal_cb_str = 'ros_goal')
00044         self.position = position
00045 
00046     def ros_goal(self, userdata, default_goal):
00047         return pm.SingleJointPositionGoal(position = self.position)
00048 
00049     def __getstate__(self):
00050         state = tu.SimpleStateBase.__getstate__(self)
00051         my_state = [self.position]
00052         return {'simple_state': state, 'self': my_state}
00053 
00054     def __setstate__(self, state):
00055         tu.SimpleStateBase.__setstate__(self, state['simple_state'])
00056         self.position = state['self'][0]
00057 
00058 


rcommander
Author(s): Hai Nguyen (haidai@gmail.com)
autogenerated on Thu Nov 28 2013 11:46:34