# Manipulator end-effector orientation with quaternions

I have the following problem:

Given 3 points on a surface, I have to adjust a manipulator end-effector (i.e. pen) on a Baxter Robot, normal to that surface.

From the three points I easily get the coordinate frame, as well as the normal vector. My question is now, how can I use those to tell the manipulator its supposed orientation.

The Baxter Inverse Kinematics solver takes a $(x,y,z)$-tuple of Cartesian coordinates for the desired position, as well as a $(x,y,z,w)$-quaternion for the desired orientation. What do I set the orientation to? My feeling would be to just use the normal vector $(n_1,n_2,n_3)$ and a $0$, or do I have to do some calculation?

• You need to look up how to transform a rotation matrix to a quaternion! – Brian Lynch Dec 2 '15 at 17:13
• One other thing you will have to do is set a constraint on the other axes of your tool. Technically there are infinite orientations that will place the pen with that normal vector. I would recommend converting your normal vector into an azimuth-elevation representation, which can then be used to generate a full rotation matrix that can then be converted to a quaternion. – Brian Lynch Dec 2 '15 at 20:57

As Brian indicated in a comment, you simply need to convert your rotation matrix (or Euler angles) into a quaternion. Maths - Conversion Matrix to Quaternion is my favorite site for geometric conversions.

Quaternions are a great representation and have a number of benefits over other representations, so you should definitely read up on them.

• Awesome link, gonna add that to my bookmarks, thanks! – Brian Lynch Dec 2 '15 at 20:58
• @BrianLynch Yeah, there is a lot of great stuff there. – Ben Dec 3 '15 at 15:07
• For those preferring a more mathematical and comprehensive guide to rotation parameterizations and conversions, check out this paper. – kamek Dec 4 '15 at 15:52

I'm not familiar with your device, but here are a few tips that might help...

Since the device is using a quaternion to describe an orientation, they must also specify some base coordinate frame against which that rotation applies.

The w term in a quaternion is the cosine of the half-angle of desired rotation around the (x,y,z) vector component. If you don't care about the angle of rotation, then w can be anything (subject to normalization requirements), including 0.