follow_point_node.py
Go to the documentation of this file.
00001 import roslib
00002 roslib.load_manifest('pr2_laser_follow_behavior')
00003 import rospy
00004 from geometry_msgs.msg import PointStamped
00005 from geometry_msgs.msg import PoseStamped
00006 import hrl_lib.tf_utils as tfu
00007 import tf
00008 
00009 class FollowPointBehavior:
00010 
00011     def __init__(self):
00012         rospy.Subscriber('cursor3dcentered', PointStamped, follow_point_cb)
00013         self.move_pub = rospy.Publisher('move_base_simple/goal', PoseStamped)
00014        self.tflistener = tf.TransformListener()
00015 
00016     def follow_point_cb(self, point_stamped):
00017         point_head = point_stamped.point
00018 
00019         base_T_head = tfu.transform('/base_link', point_stamped.header.frame_id, self.tflistener)
00020         point_mat_head = tfu.translation_matrix([point.x, point.y, point.z])
00021         point_mat_base = base_T_head * point_mat_head
00022         t_base, o_base = tfu.matrix_as_tf(point_mat_base)
00023         x = t_base[0]
00024         y = t_base[1]
00025         angle = math.atan2(y, x)
00026 
00027         ps = PoseStamped()
00028         ps.header.frame_id = '/base_link'
00029         ps.pose.position.x = x
00030         ps.pose.position.y = y
00031         ps.pose.position.z = 0.
00032 
00033         q = tf.transformations.quaternion_from_euler(angle, 0, 0)
00034         ps.pose.orientation.x = q[0]
00035         ps.pose.orientation.y = q[1]
00036         ps.pose.orientation.z = q[2]
00037         ps.pose.orientation.w = q[3]
00038         self.move_pub.publish(ps)
00039 
00040     def run(self):
00041         r = rospy.Rate(10)
00042         while not rospy.is_shutdown():
00043             r.sleep()
00044 
00045 if __name__ == '__main__':
00046     rospy.init_node('follow_point_node', anonymous=True)
00047 
00048 
00049 #Subscribes to laser point
00050 #sends point out to move_base_simple/goal
00051 #header: 
00052 #  seq: 0
00053 #  stamp: 
00054 #    secs: 1278624411
00055 #    nsecs: 326550373
00056 #  frame_id: /map
00057 #pose: 
00058 #  position: 
00059 #    x: 1.49216187
00060 #    y: -0.0629254132509
00061 #    z: 0.0
00062 #  orientation: 
00063 #    x: 0.0
00064 #    y: 0.0
00065 #    z: 0.127143523912
00066 #    w: 0.991884330115
00067 


pr2_laser_follow_behavior
Author(s): Hai Nguyen, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 12:17:18