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

rotate a quaternion

asked 2012-08-03 13:11:49 -0600

Nan Jiang gravatar image

updated 2012-08-03 14:48:18 -0600

I have a quaternion that represents the orientation of the robot gripper. Now, I want to define a set of primitive actions to change this orientation in some directions, so that all possible orientations are reachable (to some accuracy).

My solution is to convert quaternions into Euler angles, then add a certain amount (say 10 degrees) to one of the three angles, and convert back to quaternions. This worked quite well as I thought but had the problem of gimbal lock.

So here is my question. Is there a way to achieve the behaviour obtained here, without converting back and forth between quaternions and Euler angles?

====================================================

EDIT: From some tutorials, I learn that I can apply a rotation quaternion q to a orietation quaternion v to obtain a new orietation quaternion v'=qvq*. So my question is, given v=(w,x,y,z), what are the q's that only change its pitch, roll and yaw respectively?

After some thinking, I get the following:

yaw: (cos(alpha),0,0,sin(alpha))

roll: (cos(alpha),x,y,z) --> normalization

pitch: (cos(alpha),y,-x,0) --> normalization

Am I right?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
6

answered 2012-08-05 08:37:37 -0600

Lorenz gravatar image

Just use TF's functions for creating a quaternion from euler angles and the multiplication operator for combining quaternions. Have a look here, in particular at the method tf::createQuaternionFromRPY.

edit flag offensive delete link more

Comments

How do you invoke the quaternion multiplication operator from python?

dinosaur gravatar image dinosaur  ( 2015-07-08 16:43:58 -0600 )edit

For example, I have a vector X (x,y,z) and its ERY is (0,0,a), and I have another vector Y(x',y',z') and ERY is (0,0,b), if I want to get Y by doing RX+T, can I get the rotation matrix R and transformation matrix T by using TF's function? Or if its not possible, how can I compute this? Thx a lot!

Henschel.X gravatar image Henschel.X  ( 2016-03-17 20:13:09 -0600 )edit
1

answered 2012-08-03 13:50:52 -0600

Kevin gravatar image

(1) Yes a quaternion takes 4 numbers

(2) How about this

edit flag offensive delete link more

Comments

Thanks for your answer. I was misunderstanding what is a rotation quaternion when I posted the question. I have edited my question so that it is more detailed (and hopefully it makes sense this time).

Nan Jiang gravatar image Nan Jiang  ( 2012-08-03 14:44:32 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2012-08-03 13:11:49 -0600

Seen: 9,420 times

Last updated: Aug 05 '12