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

getting the tf between camera and markers

asked 2017-12-05 10:25:19 -0500

fil gravatar image

I'm preety new to ROS and python. I'm using the ar_track_alvar pkg and i need to get the tf from camera to marker. Supposeaddly it's given by the package so i thought to create a listener to get it but i have no idea how to do it

edit retag flag offensive close merge delete

Comments

jayess gravatar image jayess  ( 2017-12-07 12:08:17 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-12-07 11:59:53 -0500

Gayan Brahmanage gravatar image

updated 2017-12-07 12:04:06 -0500

Hi, you can use the following piece of code to publish tf between two frames. For example tf between "base_link" to "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()
edit flag offensive delete link more

Comments

The OP is asking how to query the TF system, not publish to it

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2017-12-07 12:21:28 -0500 )edit
0

answered 2017-12-07 12:26:44 -0500

If your first task is to find out if the TFs are being broadcast at all then I'd recommend staring rviz and subscribing to the TF topic. If you select an active frame_id from the drop down list in rviz then you should see any frames that are being broadcast by any nodes currently running.

This check will find out if they are being broadcast in the first place and what their frame_id's are. Then if you find out the TFs are there in the first place you can start writing a node to query them, it's not the same as subscribing to a topic in this case. There are good tutorials here for c++ and here for python.

edit flag offensive delete link more

Comments

thx for the help i'll check the tutorials

fil gravatar image fil  ( 2017-12-07 12:36:55 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2017-12-05 10:25:19 -0500

Seen: 1,018 times

Last updated: Dec 07 '17