move_head.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 # Directly stolen from Tiffany.  Thanks!  ;-)
00003 
00004 import roslib
00005 roslib.load_manifest('hrl_pr2_lib')
00006 import rospy
00007 import actionlib
00008 from actionlib_msgs.msg import *
00009 from pr2_controllers_msgs.msg import *
00010 from geometry_msgs.msg import *
00011 import numpy as np
00012 import dynamic_reconfigure.client       #to turn on/off projector
00013 
00014 try:
00015         rospy.init_node('tmp_headmove')
00016 except:
00017         pass
00018 
00019 class Head():
00020         def __init__(self ):
00021         #       rospy.init_node('move_the_head', anonymous=True)
00022                 self.client = actionlib.SimpleActionClient('/head_traj_controller/point_head_action', PointHeadAction)
00023                 self.client.wait_for_server()
00024                 self.goal = PointHeadGoal()
00025 
00026         def set_pose(self, pos):
00027                 self.goal.target.header.frame_id = 'torso_lift_link'
00028                 self.goal.target.point.x = pos[0]
00029                 self.goal.target.point.y = pos[1]
00030                 self.goal.target.point.z = pos[2]
00031                 self.goal.min_duration = rospy.Duration(1.0)
00032 
00033                 self.client.send_goal(self.goal)
00034                 self.client.wait_for_result()
00035 
00036                 if self.client.get_state() == GoalStatus.SUCCEEDED:
00037                         print "Succeeded"
00038                 else:
00039                         print "Failed"
00040         
00041         #Borrowed from Kelsey's hrl_pr2_lib/simple_grasp_learner.py
00042         def change_projector_mode(self, on):
00043                 client = dynamic_reconfigure.client.Client("camera_synchronizer_node")
00044                 node_config = client.get_configuration()
00045                 node_config["projector_mode"] = 2
00046                 if on:
00047                         node_config["narrow_stereo_trig_mode"] = 3
00048                 else:
00049                         node_config["narrow_stereo_trig_mode"] = 4
00050                 client.update_configuration(node_config)
00051 
00052 
00053 if __name__ == '__main__':
00054         head = Head()
00055         pos = np.matrix([.54, 0.0, 0.9]).T
00056         head.set_pose(pos)
00057         #rospy.sleep(5.0)
00058         #rospy.logout('Moved the head, done pausing.')
00059         head.change_projector_mode(False)


rfid_people_following
Author(s): Travis Deyle (Healthcare Robotics Lab, Georgia Tech)
autogenerated on Wed Nov 27 2013 11:38:30