utils_tf.py
Go to the documentation of this file.
1 import rospy
2 
3 
4 def can_transform(tf_buffer, target_frame, source_frame, time_):
5  return tf_buffer.can_transform_core(target_frame, source_frame, time_)[0]
6 
7 
8 def wait_for_transform(tf_buffer, target_frame, source_frame, timeout):
9  request_time = rospy.Time.now()
10  r = rospy.Rate(100)
11  while rospy.Time.now() < request_time + timeout:
12  # Try to get the most recent transform
13  if can_transform(tf_buffer, target_frame, source_frame, rospy.Time(0)):
14  transform = tf_buffer.lookup_transform_core(
15  target_frame, source_frame, rospy.Time(0))
16  # Success if it is newer than the initial time
17  if transform.header.stamp > request_time:
18  break
19  r.sleep()
20  else:
21  raise RuntimeError('Transform timeout.')
def can_transform(tf_buffer, target_frame, source_frame, time_)
Definition: utils_tf.py:4
def wait_for_transform(tf_buffer, target_frame, source_frame, timeout)
Definition: utils_tf.py:8


frame_editor
Author(s): ipa-lth , ipa-frn
autogenerated on Wed Oct 21 2020 03:36:00