tf_remove_child_frames.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 # Copyright 2016 The Cartographer Authors
5 # Copyright 2018 DFKI GmbH
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 
19 import rospy
20 from tf.msg import tfMessage
21 
22 
23 def main():
24  rospy.init_node('tf_remove_child_frames')
25  remove_frames = rospy.get_param('~remove_frames', [])
26 
27  # filter tf_in topic
28  tf_pub = rospy.Publisher('tf_out', tfMessage, queue_size=1)
29 
30  def tf_cb(msg):
31  msg.transforms = [t for t in msg.transforms
32  if t.child_frame_id.lstrip('/') not in remove_frames]
33  tf_pub.publish(msg)
34 
35  rospy.Subscriber('tf_in', tfMessage, tf_cb)
36 
37  # filter tf_static_in topic
38  tf_static_pub = rospy.Publisher('tf_static_out', tfMessage, queue_size=1, latch=True)
39 
40  def tf_static_cb(msg):
41  msg.transforms = [t for t in msg.transforms
42  if t.child_frame_id.lstrip('/') not in remove_frames]
43  tf_static_pub.publish(msg)
44 
45  rospy.Subscriber('tf_static_in', tfMessage, tf_static_cb)
46 
47  rospy.spin()
48 
49 
50 if __name__ == '__main__':
51  main()


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