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)
Originally posted by Rstef on ROS Answers with karma: 21 on 2023-05-23
Post score: 1
Original comments
Comment by tfoote on 2023-05-23:
Does it error once or a couple of times at startup? Or does it continuously happen?
Comment by Rstef on 2023-05-24:
the error happens continuously
Comment by tfoote on 2023-05-24:
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?
Comment by Rstef on 2023-05-25:
The node is spinning right and it is receiving all the messages needed , here is what the ros node info returns :
/XPal_2/slam_localization
Subscribers:
/XPal_2/tf: tf2_msgs/msg/TFMessage
/XPal_2/tf_static: tf2_msgs/msg/TFMessage
Publishers:
/XPal_2/slam_position: ea_custom_message/msg/MsgPosition
/parameter_events: rcl_interfaces/msg/ParameterEvent
/rosout: rcl_interfaces/msg/Log
Service Servers:
/XPal_2/slam_localization/describe_parameters: rcl_interfaces/srv/DescribeParameters
/XPal_2/slam_localization/get_parameter_types: rcl_interfaces/srv/GetParameterTypes
/XPal_2/slam_localization/get_parameters: rcl_interfaces/srv/GetParameters
/XPal_2/slam_localization/list_parameters: rcl_interfaces/srv/ListParameters
/XPal_2/slam_localization/set_parameters: rcl_interfaces/srv/SetParameters
/XPal_2/slam_localization/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically
tell me if you need more informations