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

turtle tf tutorial fails to work

asked 2012-10-15 02:01:22 -0600

niosus gravatar image

updated 2012-10-15 02:02:58 -0600

Hi all,

I am fairly new to ros and was going through the tf tutorials and stumbled upon a strange error. After fiddling around for an hour or so I'm still not able to understand the behavior. I'm doing everything exactly as stated in these tutorials, using C++. The code is exactly as stated there. I'm on fuerte, and ubuntu 12.04.

The problem is that the second turtle goes in circles instead of approaching the first one. The broadcaster works well, so, I would guess, that the issue is in the listener in the "lookupTransform" method. In the end the angular speed appears to be wrong.

I also attach the image of how the turtle moves. This happens on 2 different machines of the same configuration with fresh ros-fuerte installed.

image description

Any ideas what could explain such a behavior?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
8

answered 2012-11-08 13:32:25 -0600

Tones gravatar image

Hi,

I had the same problem and just changed the order of the arguments for the Quaterion in turtle_tf_broadcaster.cpp. Now it looks like this and works for me:

transform.setRotation(  tf::Quaternion(0, 0, msg->theta) );

Not sure, what reason causes this problem.

edit flag offensive delete link more

Comments

1

Good find! I was looking at the listener. I'm guessing the API changed the order of the constructor parameters from RPY to YPR. Anyway, the Quaternion constructor w/Euler angles was deprecated since the tutorial was written. You should make the quaternion another way or use the setEulerZYX function.

thebyohazard gravatar image thebyohazard  ( 2012-11-09 03:03:13 -0600 )edit

Thanks, worked for me too. Anyway, the tutorial should be changed, I guess...

niosus gravatar image niosus  ( 2012-11-16 04:57:53 -0600 )edit

Very good catch! I've updated the tutorial http://www.ros.org/wiki/tf/Tutorials/Writing%20a%20tf%20broadcaster%20%28C%2B%2B%29. Review is appreciated! Also, relevant announcement about Bullet migration http://goo.gl/8gJOn

130s gravatar image 130s  ( 2012-12-27 23:43:31 -0600 )edit

The code in the tutorial is still faulty. Thanks for the answer!

RafBerkvens gravatar image RafBerkvens  ( 2013-03-21 00:53:29 -0600 )edit

Thanks for the answer! There seems to be a discrepancy between the tutorial and the class reference on how lookupTransform works too. The tutorial says it gives the transform from the 1st arg to the 2nd arg, but the class reference says the exact opposite. The class reference seems to be correct.

wesleyc gravatar image wesleyc  ( 2013-08-06 23:08:48 -0600 )edit
0

answered 2014-08-01 22:02:29 -0600

PaulBouchier gravatar image

updated 2014-08-01 22:05:14 -0600

Tones found the answer (above) - good find Tones! However, the code was never updated, and the wiki was changed incorrectly (cited wrong line)) I pushed a change which has been merged and which fixes the problem. I've repaired the incorrect wiki changes by now telling what has to change in case you're on an earlier version than that when the API changed. Here's the commit comment (in part - edited for clarity):

Fix wrong order of arguments to q.setRPY in commit 82964f6.
The API shows the order is:
void    setRPY (const tfScalar &roll, const tfScalar &pitch, const tfScalar 

Line 14 should read:

q.setRPY(0, 0, msg->theta);

This fault breaks this tutorial:

http://wiki.ros.org/tf/Tutorials/Writing%20a%20tf%20broadcaster%20%28C%2B%2B

In a way that doesn't show up until the subsequent tutorial, where the
follower doesn't follow. The fix to line 14 proposed above fixes the
subsequent tutorial.

The problem is discussed in this thread:

http://answers.ros.org/question/45884/turtle-tf-tutorial-fails-to-work/?answ

and an incorrect fix was applied to the wiki. The note in the wiki under
the code, which says the code should read:

transform.setRotation( tf::Quaternion(0, 0, msg->theta) );

is wrong - it should reference q.setRPY(), but in any case, should talk about the earlier version where mst->theta is the first argument, since the code has now been repaired.
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2012-10-15 02:01:22 -0600

Seen: 1,554 times

Last updated: Aug 01 '14