tf_remove_child_frames.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 # Copyright 2016 The Cartographer Authors
00005 # Copyright 2018 DFKI GmbH
00006 #
00007 # Licensed under the Apache License, Version 2.0 (the "License");
00008 # you may not use this file except in compliance with the License.
00009 # You may obtain a copy of the License at
00010 #
00011 #    http://www.apache.org/licenses/LICENSE-2.0
00012 #
00013 # Unless required by applicable law or agreed to in writing, software
00014 # distributed under the License is distributed on an "AS IS" BASIS,
00015 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016 # See the License for the specific language governing permissions and
00017 # limitations under the License.
00018 
00019 import rospy
00020 from tf.msg import tfMessage
00021 
00022 
00023 def main():
00024     rospy.init_node('tf_remove_child_frames')
00025     remove_frames = rospy.get_param('~remove_frames', [])
00026 
00027     # filter tf_in topic
00028     tf_pub = rospy.Publisher('tf_out', tfMessage, queue_size=1)
00029 
00030     def tf_cb(msg):
00031         msg.transforms = [t for t in msg.transforms
00032                           if t.child_frame_id.lstrip('/') not in remove_frames]
00033         tf_pub.publish(msg)
00034 
00035     rospy.Subscriber('tf_in', tfMessage, tf_cb)
00036 
00037     # filter tf_static_in topic
00038     tf_static_pub = rospy.Publisher('tf_static_out', tfMessage, queue_size=1, latch=True)
00039 
00040     def tf_static_cb(msg):
00041         msg.transforms = [t for t in msg.transforms
00042                           if t.child_frame_id.lstrip('/') not in remove_frames]
00043         tf_static_pub.publish(msg)
00044 
00045     rospy.Subscriber('tf_static_in', tfMessage, tf_static_cb)
00046 
00047     rospy.spin()
00048 
00049 
00050 if __name__ == '__main__':
00051     main()


mir_driver
Author(s): Martin Günther
autogenerated on Wed May 8 2019 02:53:33