TFBroadcaster.py
Go to the documentation of this file.
00001 #!/usr/bin/python
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 #from subprocess import call
00015 
00016 import getopt
00017 
00018 
00019 import tf
00020 class broadcaster (script):
00021 
00022     def __init__(self,in_frame,out_frame):
00023         #rospy.init_node("trafo_")
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        # self.ori.append(self.q.x)
00031        # self.ori.append(self.q.y)
00032        # self.ori.append(self.q.z)
00033        # self.ori.append(self.q.w)
00034        # self.ori.append(self.q[0])
00035        # self.ori.append(self.q[1])
00036        # self.ori.append(self.q[2])
00037        # self.ori.append(self.q[3])
00038        # print self.ori[2]
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)


cob_3d_mapping_gazebo
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:04:44