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

Help with tf2 tutorial "Writing a tf2 listener"

asked 2019-06-26 21:07:48 -0500

pitosalas gravatar image

updated 2019-06-27 01:58:57 -0500

gvdhoorn gravatar image

A line of code in this tutorial confuses me: http://wiki.ros.org/tf2/Tutorials/Wri...

Line 25 in "The Code" looks like this:

trans = tfBuffer.lookup_transform(turtle_name, 'turtle1', rospy.Time())

Where the variable turtle_name is likely going to be turtle2. But When I look at the tf tree, turtle2 is not even mentioned.

As we want to compute a cmd_vel for turtle2 which will amount to it following turtle1 around, I would think that this lookup would be between "world" and "turtle1", in other words, to figure out where turtle1 is so that turtle2 can drive towards it.

Anyone can help me understand? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-27 05:31:50 -0500

To answer your first question about the missing turtle2 frame. How are you viewing the TF tree? Did you read section three which says the transforms may take a while before they're all being broadcast.

Your second question about looking up the world frame. To make one turtle follow another the location of the lead turtle in the world frame is not important because the cmd_vel topic which is used to control the chaser turtle is defined in the body frame of the chaser turtle. So the only information that is needed is the location of the lead turtle in the body frame of the chaser turtle.

Hope this makes sense.

edit flag offensive delete link more

Comments

Thanks for the response and explanation.

I used the tf2 rosrun tf2_tools view_frames.pytool. I found my mistake. To make that tutorial work it is necessary to have launched the previous tutorial: http://wiki.ros.org/tf2/Tutorials/Wri... and launched it with the launch file. That launch file actually launches two nodes with the same code, one broadcasting turtle1's tf and the other turtle2's tf. With that I was able to get it all to work.

FYI I am seeing if I can convert these tutorials into Jupyter Notebook examples using the "Jupyter Ros" library which is quite cool. There you launch nodes directly not with .launch files, hence the problem.

Thanks again.

pitosalas gravatar image pitosalas  ( 2019-06-27 19:32:33 -0500 )edit

Glad it's working. Converting these to jupyter notebooks is a great project. We're hoping to use them for teaching ROS on a course next year.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-06-28 02:11:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-06-26 21:07:48 -0500

Seen: 284 times

Last updated: Jun 27 '19