ROS进二阶学习笔记(1) TF 学习笔记2 -- TF Broadcaster
Ref: http://wiki.ros.org/tf/Tutorials#Learning_tf
>>Ref: Writing a tf broadcaster (Python)
This tutorial teaches you how to broadcast the state of a robot to tf.
Ref内的东西请读者自行研读,这里要做点总结:
- /tf topic上 是有一个发布器broadcaster 发布 /tf 消息才能被 /tf 的 listener 收听到。
- /tf 的发布器类:python: tf.TransformBroadcaster 所以我们要理解它里面的方法: sendTransform(translation, rotation, time, child, parent)
1. 先看看tf broadcaster的示例代码:
#!/usr/bin/env python
import roslib
roslib.load_manifest('learning_tf')
import rospy
import tf
import turtlesim.msg
def handle_turtle_pose(msg, turtlename):
br = tf.TransformBroadcaster()
br.sendTransform((msg.x, msg.y, 0), #the translation of the transformtion as a tuple (x, y, z)
tf.transformations.quaternion_from_euler(0, 0, msg.theta),
#the rotation of the transformation as a tuple (x, y, z, w)
rospy.Time.now(), #the time of the transformation, as a rospy.Time()
turtlename, #child frame in tf, string
"world") #parent frame in tf, string
if __name__ == '__main__':
rospy.init_node('turtle_tf_broadcas