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

tf.getYaw() in python? [closed]

asked 2012-08-19 18:59:10 -0600

Well I feel very foolish to ask this question, but I am looking for the equivalent of tf::getYaw() that exists in the C++ API for Python. I've tried looking in the API docs and using the dir() and help() functions in the Python console, but so far coming up short. Does this function exist?

If not, can anyone point to a reliable implementation where I can pass a Quaternion message and get the yaw back? I can go back and rewrite my code in C++, but that would be a little silly.

I'm on Electric

Thanks!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by dougbot01
close date 2012-09-23 19:15:32

1 Answer

Sort by ยป oldest newest most voted
6

answered 2012-08-19 21:24:15 -0600

michikarg gravatar image

You can use euler_from_quaternion:

 (roll,pitch,yaw) = euler_from_quaternion(quaternion)
edit flag offensive delete link more

Comments

It's basically not a real equivalent but i guess the easiest way to get yaw from a quaternion.

michikarg gravatar image michikarg  ( 2012-08-19 21:35:01 -0600 )edit
1

Thank you, that works! As a note one must add "from tf.transformations import euler_from_quaternion" to the top of the file. I don't know why I cannot mark this as answered. Someone please help if you can!

dougbot01 gravatar image dougbot01  ( 2012-08-21 22:09:13 -0600 )edit

Beware that this function expects a list of values, not a geometry_msgs/Quaternion! So, if you have a geometry_msgs/PoseStamped message, you have to convert it before like this: quaternion = [pose.pose.orientation.x, pose.pose.orientation.y, pose.pose.orientation.z, pose.pose.orientation.w]

Micha Sende gravatar image Micha Sende  ( 2022-06-08 08:10:15 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-08-19 18:59:10 -0600

Seen: 4,137 times

Last updated: Aug 19 '12