Error with waitForTransform (triggers can_transform) tf2
I am writing some python code to read coordinates from a textfile and transform the coordinates to a PointStamped
in my odom
frame, sending the goal to move_base
for navigation. When the first set of coordinates are read, everything is fine however when it comes to the next set of coordinates I get this error:
Traceback (most recent call last):
File "/home/moshahin/catkin_ws/src/monsterborg_navigation/src/misc.py", line 184, in <module>
odom_point = PointTransformation(UTM_point)
File "/home/moshahin/catkin_ws/src/monsterborg_navigation/src/misc.py", line 89, in PointTransformation
listener.waitForTransform('odom', 'utm', rospy.Time.now(), rospy.Duration(10.0))
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf/listener.py", line 74, in waitForTransform
can_transform, error_msg = self._buffer.can_transform(strip_leading_slash(target_frame), strip_leading_slash(source_frame), time, timeout, return_debug_tuple=True)
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_ros/buffer.py", line 124, in can_transform
r.sleep()
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/timer.py", line 103, in sleep
sleep(self._remaining(curr_time))
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/timer.py", line 165, in sleep
raise rospy.exceptions.ROSInterruptException("ROS shutdown request")
rospy.exceptions.ROSInterruptException: ROS shutdown request
The function PointTransformation
has the following body:
def PointTransformation(UTMPoint_input):
""" The purpose of this function is to transform the POI from the UTM frame
to the odom frame (this can later be changed to transform to map frame instead).
The input of this function is a geometry_msg/PointStamped w.r.t UTM frame.
The OUTPUT of this function is a geometry_msg/PointStamped w.r.t odom/map frame. """
TransformedPoint = PointStamped()
listener = tf.TransformListener()
notDone = True
while notDone:
try:
UTMPoint_input.header.stamp = rospy.Time.now()
listener.waitForTransform('odom', 'utm', rospy.Time.now(), rospy.Duration(10.0))
# Transforms geometry_msgs/PointStamped message to frame target_frame=odom
TransformedPoint = listener.transformPoint('odom', UTMPoint_input)
notDone = False
except tf.Exception:
rospy.logerr("tf.Exception occured! ")
continue
return TransformedPoint
I have setup the robot_localization
package such that the utm
frame is the parent frame and its child is odom
frame. The function takes in a PointStamped
message w.r.t utm
frame and this function transforms it to a PointStamped
w.r.t to odom
frame. Just to re-iterate, the first time the function is called, nothing is wrong (and I get the point w.r.t odom
which I then use to build a move_base_goal
)but I get the error I posted above when the function is executed for the second set of GPS coordinates. So my question is why do I get this error? What is the can_transform function?