{{{#!wiki tip Using ROS 2? Check out the [[https://docs.ros.org/en/rolling/Tutorials/Intermediate/Tf2/Tf2-Main.html|ROS 2 tf2 tutorials]]. }}} ## page was renamed from tf22/Tutorials/Time travel in tf22 (Python) #################################### ##FILL ME IN #################################### ## for a custom note with links: ## note = This tutorial assumes you have completed the tf2 and time [[tf2/Tutorials/tf2 and time (Python)|(Python)]] [[tf2/Tutorials/tf2 and time (C++)|(C++)]] tutorials ## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links ## note.0= ## descriptive title for the tutorial ## title = Time travel with tf2 (Python) ## multi-line description to be displayed in search ## description = This tutorial teaches you about advanced time travel features of tf2 ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link= ## next.1.link= ## what level user is this tutorial for ## level= AdvancedCategory ## keywords = #################################### <> <> In the [[tf2/Tutorials/tf2 and time (Python)|previous tutorial]] we discussed the basic concept of tf2 and time. This tutorial will take this one step further, and expose one of the most powerful tf2 tricks. == Time travel == So let's go back to where we ended in the [[tf2/Tutorials/tf2 and time (Python)|previous tutorial]]. Go to your package for the tutorial: {{{ $ roscd learning_tf2 }}} Now, instead of making the second turtle go to where the carrot is '''now''', make the second turtle go to where the first carrot was '''5 seconds ago'''. Edit '''`nodes/turtle_tf2_listener.py`''': {{{#!python try: past = rospy.Time.now() - rospy.Duration(5.0) trans = tfBuffer.lookup_transform(turtle_name, 'carrot1', past, rospy.Duration(1.0)) except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException): }}} <> {{{#!python try: past = rospy.Time.now() - rospy.Duration(5.0) trans = tfBuffer.lookup_transform_full( target_frame=turtle_name, target_time=rospy.Time.now(), source_frame='carrot1', source_time=past, fixed_frame='world', timeout=rospy.Duration(1.0) ) }}} <> {{{ $ roslaunch learning_tf2 start_demo.launch }}} And yes, the second turtle is directed to where the first carrot was 5 seconds ago! ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## TutorialTurtlesim ## PythonCategory ## LearningCategory