transform_manager.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('iri_common_smach')
00004 import rospy
00005 import smach
00006 import smach_ros
00007 import threading
00008 import tf
00009 
00010 class TransformManager(threading.Thread):
00011     """
00012     Bridge to the ROS tf package. Constantly broadcasts
00013     all tfs, and retrieves them on demand.
00014     """
00015     def __init__(self):
00016         threading.Thread.__init__(self)
00017         self.tfs = []
00018         self.listener = tf.TransformListener()
00019 
00020     def transform_pose(self, target_frame, req_pose_st):
00021         """Attempts to retrieve a transform"""
00022         attempts = 0
00023         rate = rospy.Rate(10.0)
00024         while attempts < 50:
00025             try:
00026                 pose = self.listener.transformPose(target_frame, req_pose_st)
00027                 return pose
00028             except (tf.LookupException, tf.ConnectivityException):
00029                 attempts+=1
00030                 rate.sleep()
00031                 continue 
00032         raise Exception("Attempt to transform %s exceeded attempt limit" % target_frame)


iri_common_smach
Author(s): Jose Luis Rivero
autogenerated on Fri Dec 6 2013 21:05:20