TF2 ConnectivityException With Connected TF Tree
I'm getting the following error about missing frames, but when I view the TF tree, it shows as a single connected tree. The same error occurs no matter which two frames I use. I don't have enough karma to post a screenshot or PDF of the TF Tree.
[ERROR]: bad callback: <function dockPoseCallback at 0x7f55bacf44d0>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "/home/rwbot/dock_ws/src/docking/src/controller.py", line 31, in dockPoseCallback
dockTF = tfBuffer.lookup_transform('world', 'base_link', rospy.Time())
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_ros/buffer.py", line 87, in lookup_transform
return self.lookup_transform_core(target_frame, source_frame, time)
ConnectivityException: Could not find a connection between 'world' and 'base_link' because they are not part of the same tree.Tf has two or more unconnected trees.
When I run rosrun tf2_tools echo.py world base_link
it gives the transform which at least verifies that the frames do in fact exist.
rwbot@carowe:~/dock_ws$ rosrun tf2_tools echo.py world base_link
At time 1654.916, (current time 1654.921)
- Translation: [-0.001, -0.002, 0.077]
- Rotation: in Quaternion [-0.000, -0.003, -0.004, 1.000]
in RPY (radian) [-0.000, -0.005, -0.008]
in RPY (degree) [-0.002, -0.291, -0.430]
Here is the relevant code
#!/usr/bin/env python
import math
from visualization_msgs.msg import *
import rospy
import tf2_ros
import tf2_geometry_msgs
from geometry_msgs.msg import *
from nav_msgs.msg import *
from std_msgs.msg import *
from docking.msg import *
def dockPoseCallback(dockPose):
LOS = docking.msg.LineOfSight()
tfBuffer = tf2_ros.Buffer()
listener = tf2_ros.TransformListener(tfBuffer)
dockTF = tfBuffer.lookup_transform('world', 'base_link', rospy.Time())
def main():
rospy.init_node("controller")
dock_pose_sub = rospy.Subscriber('dock_pose', PoseStamped, dockPoseCallback)
LOS_marker_pub = rospy.Publisher('LOS', Marker, queue_size=10)
r = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
LOS_marker_pub.publish(LOS.arrow)
r.sleep()
if __name__ == '__main__':
main()