Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi, you can use the following piece of code to publish tf between two frames. For example tf between "base_link" to "scans"

import tf

def handle_transform(parent, child, tr):
br.sendTransform((tr[0], tr[1], 0), tf.transformations.quaternion_from_euler(0, 0, tr[2]), rospy.Time.now(), child,parent)

if __name__ == "__main__":

    rospy.init_node('main', anonymous=True) #make node 
    rate = rospy.Rate(5) # 5hz  
    br = tf.TransformBroadcaster() 

    while not rospy.is_shutdown():

        handle_transform("base_link", "scans", [0,0,0])
        rate.sleep()

Hi, you can use the following piece of code to publish tf between two frames. For example tf between "base_link" to "scans"

import tf

def handle_transform(parent, child, tr):
 br.sendTransform((tr[0], tr[1], 0), tf.transformations.quaternion_from_euler(0, 0, tr[2]), rospy.Time.now(), child,parent)

if __name__ == "__main__":

    rospy.init_node('main', anonymous=True) #make node 
    rate = rospy.Rate(5) # 5hz  
    br = tf.TransformBroadcaster() 

    while not rospy.is_shutdown():

        handle_transform("base_link", "scans", [0,0,0])
        rate.sleep()

Hi, you can use the following piece of code to publish tf between two frames. For example tf between "base_link" to "scans""scans" in 2D -> [x,y,theta]

import tf

def handle_transform(parent, child, tr):
    br.sendTransform((tr[0], tr[1], 0), tf.transformations.quaternion_from_euler(0, 0, tr[2]), rospy.Time.now(), child,parent)

if __name__ == "__main__":

    rospy.init_node('main', anonymous=True) #make node 
    rate = rospy.Rate(5) # 5hz  
    br = tf.TransformBroadcaster() 

    while not rospy.is_shutdown():

        handle_transform("base_link", "scans", [0,0,0])
        rate.sleep()