tf_reconfigure_publisher.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import tf
5 from dynamic_reconfigure.server import Server
6 from dynamic_tf_publisher.cfg import TfParameterConfig
7 
8 g_broadcaster = None
9 g_frame_id = None
10 g_parent_frame_id = None
11 g_parmas = None
12 def callback(config, level):
13  global g_broadcaster, g_frame_id, g_parent_frame_id, g_params
14  g_frame_id = config.frame_id
15  g_parent_frame_id = config.parent_frame_id
16  g_params = (config.x, config.y, config.z, config.roll, config.pitch, config.yaw)
17  return config
18 
19 def timerCallback(event):
20  global g_broadcaster, g_frame_id, g_parent_frame_id, g_params
21  if g_frame_id and g_parent_frame_id and g_params:
22  g_broadcaster.sendTransform(
23  g_params[0:3],
24  tf.transformations.quaternion_from_euler(*g_params[3:6]),
25  rospy.Time.now(),
26  g_frame_id,
27  g_parent_frame_id)
28 
29 def main():
30  global g_broadcaster
31  g_broadcaster = tf.TransformBroadcaster()
32  srv = Server(TfParameterConfig, callback)
33  rospy.Timer(rospy.Duration(0.1), timerCallback)
34  rospy.spin()
35 
36 if __name__ == "__main__":
37  rospy.init_node("tf_reconfigure_publisher")
38  main()


dynamic_tf_publisher
Author(s): Manabu Saito
autogenerated on Tue Feb 6 2018 03:44:59