spine_tool.py
Go to the documentation of this file.
00001 #import roslib; roslib.load_manifest('rcommander_pr2')
00002 import rospy
00003 from PyQt4.QtGui import *
00004 from PyQt4.QtCore import *
00005 import rcommander.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', SpineState)
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 new_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 set_node_properties(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 class SpineState(tu.SimpleStateBase): 
00035 
00036     def __init__(self, name, position):
00037         tu.SimpleStateBase.__init__(self, name, \
00038                 'torso_controller/position_joint_action', 
00039                 pm.SingleJointPositionAction, 
00040                 goal_cb_str = 'ros_goal')
00041         self.position = position
00042 
00043     def ros_goal(self, userdata, default_goal):
00044         return pm.SingleJointPositionGoal(position = self.position)
00045 
00046     #def __getstate__(self):
00047     #    state = tu.SimpleStateBase.__getstate__(self)
00048     #    my_state = [self.position]
00049     #    return {'simple_state': state, 'self': my_state}
00050 
00051     #def __setstate__(self, state):
00052     #    tu.SimpleStateBase.__setstate__(self, state['simple_state'])
00053     #    self.position = state['self'][0]
00054 
00055 


rcommander_pr2_gui
Author(s): Hai Nguyen
autogenerated on Thu Dec 12 2013 12:09:58