ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem is that tf_msg.transforms should be a Python list containing one or more transforms. Change your code like this:

tf_msg = TFMessage()

tf_msg.transforms.append(TransformStamped())

tf_msg.transforms[0].header.stamp.secs =  float(msg.utime)/1e6
tf_msg.transforms[0].header.frame_id = "camera"

tf_msg.transforms[0].child_frame_id = "base_laser"

tf_msg.transforms[0].transform.translation = Vector3()
tf_msg.transforms[0].transform.translation.x = msg.trans[0]
tf_msg.transforms[0].transform.translation.y = msg.trans[1]
tf_msg.transforms[0].transform.translation.z = msg.trans[2]

tf_msg.transforms[0].transform.rotation = Quaternion()
tf_msg.transforms[0].transform.rotation.x = msg.quat[0]
tf_msg.transforms[0].transform.rotation.y = msg.quat[1]
tf_msg.transforms[0].transform.rotation.z = msg.quat[2]
tf_msg.transforms[0].transform.rotation.w = msg.quat[3]
print msg.quat[3]