tf_reconfigure_publisher.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import rospy
00004 import tf
00005 from dynamic_reconfigure.server import Server
00006 from dynamic_tf_publisher.cfg import TfParameterConfig
00007 
00008 g_broadcaster = None
00009 g_frame_id = None
00010 g_parent_frame_id = None
00011 g_parmas = None
00012 def callback(config, level):
00013     global g_broadcaster, g_frame_id, g_parent_frame_id, g_params
00014     g_frame_id = config.frame_id
00015     g_parent_frame_id = config.parent_frame_id
00016     g_params = (config.x, config.y, config.z, config.roll, config.pitch, config.yaw)
00017     return config
00018 
00019 def timerCallback(event):
00020     global g_broadcaster, g_frame_id, g_parent_frame_id, g_params
00021     if g_frame_id and g_parent_frame_id and g_params:
00022         g_broadcaster.sendTransform(
00023             g_params[0:3],
00024             tf.transformations.quaternion_from_euler(*g_params[3:6]),
00025             rospy.Time.now(),
00026             g_frame_id,
00027             g_parent_frame_id)
00028 
00029 def main():
00030     global g_broadcaster
00031     g_broadcaster = tf.TransformBroadcaster()
00032     srv = Server(TfParameterConfig, callback)
00033     rospy.Timer(rospy.Duration(0.1), timerCallback)
00034     rospy.spin()
00035 
00036 if __name__ == "__main__":
00037     rospy.init_node("tf_reconfigure_publisher")
00038     main()


dynamic_tf_publisher
Author(s): Manabu Saito
autogenerated on Sun Jan 25 2015 12:37:13