$search
00001 #! /usr/bin/env python 00002 00003 import roslib; roslib.load_manifest('pr2_dremel_server') 00004 import rospy 00005 import actionlib 00006 import math 00007 import copy 00008 import numpy 00009 import tf.listener 00010 00011 import simple_robot_control 00012 00013 import geometry_msgs.msg 00014 00015 00016 00017 pos_def = (-0.176, 0.274, 0.174) 00018 orient_def = (0.356, 0.586, -0.365, 0.630) 00019 00020 class VacFollower: 00021 00022 def __init__(self): 00023 self.arml = simple_robot_control.Arm('l') 00024 self.listener = tf.TransformListener() 00025 00026 00027 00028 def follow(self,pos, orient): 00029 self.listener.waitForTransform('r_gripper_tool_frame', 'l_wrist_roll_link', rospy.Time(), rospy.Duration(4.0)) 00030 while rospy.is_shutdown() == False: 00031 now = rospy.Time.now() 00032 # print "wait for transform" 00033 self.listener.waitForTransform('r_gripper_tool_frame', 'l_wrist_roll_link', now, rospy.Duration(4.0)) 00034 (trans_l,rot_l) = self.listener.lookupTransform( 'r_gripper_tool_frame', 'l_wrist_roll_link', rospy.Time(0)) 00035 if numpy.linalg.norm(numpy.array(pos) - trans_l) > 0.005: 00036 self.arml.goToPose(pos, orient, 'r_gripper_tool_frame' , .555550, seed_angles = (0.884, -0.146, 1.920, -1.675, -11.036, -1.158, -2.970)) 00037 else: 00038 rospy.sleep(.30) 00039 00040 00041 00042 00043 if __name__ == '__main__': 00044 rospy.init_node('vacuum_follower') 00045 vafo = VacFollower() 00046 vafo.follow(pos_def, orient_def) 00047