Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 import roslib
00035 roslib.load_manifest('turtle_tf2')
00036
00037 import rospy
00038 import tf2_ros
00039 import geometry_msgs.msg
00040 import math
00041
00042 if __name__ == '__ STATIC main__':
00043 rospy.init_node('my_tf2_broadcaster')
00044 br = tf2_ros.TransformBroadcaster()
00045 t = geometry_msgs.msg.TransformStamped()
00046
00047 t.header.frame_id = "turtle1"
00048 t.child_frame_id = "carrot1"
00049 t.transform.translation.x = 0.0
00050 t.transform.translation.y = 2.0
00051 t.transform.translation.z = 0.0
00052 t.transform.rotation.x = 0.0
00053 t.transform.rotation.y = 0.0
00054 t.transform.rotation.z = 0.0
00055 t.transform.rotation.w = 1.0
00056
00057 rate = rospy.Rate(10.0)
00058 while not rospy.is_shutdown():
00059 t.header.stamp = rospy.Time.now()
00060 br.sendTransform(t)
00061 rate.sleep()
00062
00063 if __name__ == '__main__':
00064 rospy.init_node('my_tf2_broadcaster')
00065 br = tf2_ros.TransformBroadcaster()
00066 t = geometry_msgs.msg.TransformStamped()
00067
00068 t.header.frame_id = "turtle1"
00069 t.child_frame_id = "carrot1"
00070
00071 rate = rospy.Rate(10.0)
00072 while not rospy.is_shutdown():
00073 x = rospy.Time.now().to_sec() * math.pi
00074
00075 t.header.stamp = rospy.Time.now()
00076 t.transform.translation.x = 10 * math.sin(x)
00077 t.transform.translation.y = 10 * math.cos(x)
00078 t.transform.translation.z = 0.0
00079 t.transform.rotation.x = 0.0
00080 t.transform.rotation.y = 0.0
00081 t.transform.rotation.z = 0.0
00082 t.transform.rotation.w = 1.0
00083
00084 br.sendTransform(t)
00085 rate.sleep()