Skip to content

Instantly share code, notes, and snippets.

@matlabbe
Last active January 27, 2020 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matlabbe/ff8d3405ef65ec6116d077dbe6fb86b7 to your computer and use it in GitHub Desktop.
Save matlabbe/ff8d3405ef65ec6116d077dbe6fb86b7 to your computer and use it in GitHub Desktop.
Fix /tf_static not latched when replaying a rosbag (see https://answers.ros.org/question/207551/how-to-save-static-transforms-in-bag-files/?answer=207647#post-id-207647). Start this script before running a rosbag, then do: `rosbag play --clock tf_static:=tf_static_old`
#!/usr/bin/env python
import rospy
from tf2_msgs.msg import TFMessage
def callback(data):
rospy.loginfo("Received /tf_static_old and republising latched /tf_static")
pub.publish(data)
if __name__ == '__main__':
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("tf_static_old", TFMessage, callback)
pub = rospy.Publisher('tf_static', TFMessage, queue_size=10, latch=True)
rospy.spin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment