tf2 ExtrapolationException Error (Python)
I have a poseStamped in Kinect frame (head_mount_kinect_rgb_optical_frame) and I am converting it to odom_combined or Base_Link frame of the PR2 robot, the robot is publishing the transformation.
Here is the code:
quat_pose_message = PoseStamped()
quat_pose_message.header.seq = 1
quat_pose_message.header.frame_id = "head_mount_kinect_rgb_optical_frame"
quat_pose_message.pose.position.x = self.base_point[0]
quat_pose_message.pose.position.y = self.base_point[1]
quat_pose_message.pose.position.z = self.base_point[2]
quat_pose_message.pose.orientation.x = self.quat_tf[0]
quat_pose_message.pose.orientation.y = self.quat_tf[1]
quat_pose_message.pose.orientation.z = self.quat_tf[2]
quat_pose_message.pose.orientation.w = self.quat_tf[3]
tf_buffer = tf2_ros.Buffer(rospy.Duration(1.0)) #tf buffer length
tf_listener = tf2_ros.TransformListener(tf_buffer)
transform = tf_buffer.lookup_transform("odom_combined",
quat_pose_message.header.frame_id, #source frame
rospy.Time(0), #get the tf at first available time
rospy.Duration(1.0))
pose_transformed = tf2_geometry_msgs.do_transform_pose(quat_pose_message, transform)
This give me the error after running the code for few seconds:
tf2.ExtrapolationException: Lookup would require extrapolation into the past. Requested time 1558658272.748801947 but the earliest data is at time 1558658274.165434361, when looking up transform from frame [head_mount_kinect_rgb_optical_frame] to frame [odom_combined]
I understand that the transformation is timing out but how to solve it?