[ROS2 FOXY] : Could not transform base_link to map because "map" passed to lookupTransform argument target_frame does not exist.
Hello , i am trying to do the transform between 2 frames (base_link and map) using the tf2_ros package, but it seems there is an issue somewhere. Both of the frames (base_link and map) do exist , i can see it on the tree frames when i use tf2_tools view_frames.py , also i am able to do the transform when using tf2_ros tf2_echo between my 2 frames and even more relevant , i am able to see on rviz all of the tfs being placed right, but when i am using in my code the lookup_transfrom method to get the transform between base_link and map, it says "Could not transform XPal_2/base_link to map because "map" passed to lookupTransform argument target_frame does not exist". here is the relevant code (knowing all of this code is inside a ros node called "SlamLocalization") :
self.source_frame = config_server.ROBOT_NETWORK["namespace"] + "/" + "base_link" #namespace is XPal_2
self.target_frame = "map"
self.slam_tf_buffer = Buffer()
self.slam_tf_subscriber = TransformListener(self.slam_tf_buffer, self)
self.timer = self.create_timer(0.05, self.slam_tf_callback)
def slam_tf_callback(self):
"""
Callback function for slam tf subscriber between map and robot frames
"""
try:
slam_tf = self.slam_tf_buffer.lookup_transform(self.target_frame, self.source_frame, rclpy.time.Time(),rclpy.duration.Duration(seconds=4.0) )
logger.log("tf_transform : {}".format(slam_tf))
except TransformException as ex:
logger.log('Could not transform {} to {} because {}'.format(self.source_frame, self.target_frame, ex))
return
self.publish_slam_position(slam_tf) #method used to publish on a topic the position , not relevant for this issue
def main(args=None):
rclpy.init(args=args)
slam_localization = SlamLocalization()
executor = MultiThreadedExecutor()
rclpy.spin(slam_localization, executor=executor)
# Destroy the node explicitly
slam_localization.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
Also important to know , the frames map and odom (which is the child of map) are published by the package slam_toolbox and the rest of the frames are published by the urdf file (base_link and all of his childs)
Does it error once or a couple of times at startup? Or does it continuously happen?
the error happens continuously
That probably means that you aren't receiving any data. You should check what the SlamLocalization is doing in the spin. Is rclpy turning over and receiving any messages?
The node is spinning right and it is receiving all the messages needed , here is what the ros node info returns :
tell me if you need more informations