# Define end-effector pose by point and vector

Hi all,

I am using a UR10 with Moveit! for motion planning (move group interface C++). I want to align my end-effector with a vector in space. I read a lot about quaternions and rotation in 3d space, but at the moment I struggle to find out the best way to do this.

I have a given point (x,y,z) and a given vector for orientation (a,b,c), how can I set a target pose for the end-effector? Tried to use a geometry_msg but it needs a point and a quaternion. Also tried to calculate a quaternion between the current vector and the goal vector using cross product etc. but therefore I would need the vector of the current pose and I struggled to find it out -.- Does anybody know a clean solution for my problem?

Thank you very much in advance!

Hannes

Originally posted by HannesIII on ROS Answers with karma: 27 on 2017-01-31

Post score: 1

If you know the direction of the tool's approach vector then yes you can use the cross product to "produce" the other two orthogonal vectors needed to define an orthonormal 3x3 orientation matrix. The 3x3 orientation matrix R can be represented as R = [tx ty tz] where each entry is a 3x1 unit vector and all vectors are perpendicular to each other. Assuming that the known tool vector [a,b ,c] is the tz vector then you can obtain tx as the cross product of tz and [0 1 0]' . Then ty is just the cross product between tz and tx. You can then form the matrix R. The Eigen library has very powerful tools for doing these sort of calculations and its well integrated into MoveIt!

Originally posted by jrgnicho with karma: 486 on 2017-01-31

This answer was ACCEPTED on the original site

Post score: 2

Comment by HannesIII on 2017-01-31:
Hi, thank you for your answer! It is the correcht approach. The next step is just to create a quaternion out of the matrix from your post and set it as orientation for the goal pose. Unfortunately I thought a bit to complicated. I will mark your answer as correct!

Comment by chriszzh on 2018-05-04:
Hi jrgnicho, would you mind sharing the source of your answer? I'm working on a very similar problem and would like more details about your solution. Is it from a book or something else? Thanks!

Comment by vamshi666 on 2019-12-10:
thanks for the nice answer @jrgnicho, I have one question, What if we don't have that goal vector [a,b,c]? Is there any way to solve it? like using for loop or something else?