Odom message to tf node (python)
Hello everyone,
I am interested creating a publisher node that publishes a transformation between header "odom" and child_frame "camera_pose" using the information that exists in a nav_msgs/Odometry that is published by a topic in a bag. The odometry message contains the pose as usual with the rotation described in quaternions and not in euler. After reading some tutorials on ros I believe that I should make something similiar with this.
#!/usr/bin/env python
import rospy
# Because of transformations
import tf_conversions
import tf2_ros
import geometry_msgs.msg
import turtlesim.msg
def handle_turtle_pose(msg, turtlename):
br = tf2_ros.TransformBroadcaster()
t = geometry_msgs.msg.TransformStamped()
t.header.stamp = rospy.Time.now()
t.header.frame_id = "world"
t.child_frame_id = turtlename
t.transform.translation.x = msg.x
t.transform.translation.y = msg.y
t.transform.translation.z = 0.0
q = tf_conversions.transformations.quaternion_from_euler(0, 0, msg.theta)
t.transform.rotation.x = q[0]
t.transform.rotation.y = q[1]
t.transform.rotation.z = q[2]
t.transform.rotation.w = q[3]
br.sendTransform(t)
if __name__ == '__main__':
rospy.init_node('tf2_turtle_broadcaster')
turtlename = rospy.get_param('~turtle')
rospy.Subscriber('/%s/pose' % turtlename,
turtlesim.msg.Pose,
handle_turtle_pose,
turtlename)
rospy.spin()
but I do not know how to turn this useful for my case. Can anybody point me somewhere in order to figure this out ?