Go to the documentation of this file.00001
00002 import sys
00003 import roslib
00004 roslib.load_manifest('cob_3d_mapping_gazebo')
00005 roslib.load_manifest('cob_script_server')
00006
00007 import rospy
00008 import os
00009 import math
00010 import time
00011
00012 from gazebo.srv import *
00013 from simple_script_server import *
00014
00015
00016 import getopt
00017
00018
00019 import tf
00020 class broadcaster (script):
00021
00022 def __init__(self,in_frame,out_frame):
00023
00024 rospy.init_node('tf_map_bc')
00025 self.br = tf.TransformBroadcaster()
00026 self.in_frame= in_frame
00027 self.out_frame = out_frame
00028 self.srv_get_model_state = rospy.ServiceProxy('/gazebo/get_model_state',GetModelState)
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 def Run(self):
00040 req_get = GetModelStateRequest()
00041 req_get.model_name = "robot"
00042 state = self.srv_get_model_state(req_get)
00043 q = [state.pose.orientation.x,state.pose.orientation.y,state.pose.orientation.z,state.pose.orientation.w]
00044 self.br.sendTransform((state.pose.position.x,state.pose.position.y,state.pose.position.z),q,rospy.Time.now(),self.out_frame,self.in_frame)
00045
00046
00047 if __name__ == "__main__":
00048 tf_br = broadcaster("/map","/base_link")
00049 while not rospy.is_shutdown():
00050 tf_br.Run()
00051 rospy.sleep(0.005)