# Orientate orthogonal to point [closed]

Hello,

I am having some trouble regarding tf and orientation. I am trying to have one of my manipulators point directly towards another point in space. By this I mean that the new orientation of the manipulator should be such that the given point is on the x-axis of its reference frame.

How would this be accomplished, for example using quaternions? I imagine this could, for example be done by obtaining the Euler angles from the vector in the current reference frame and converting that into a quaternion. But perhaps there is a more elegant solution?

Cheers, Brick

edit retag reopen merge delete

### Closed for the following reason question is not relevant or outdated by tfoote close date 2017-04-20 13:44:48.798851

Assuming the position of your manipulator is fixed, finding RPY from the vector (directed to interest point from manipulator position) seems the way to go. If manipulator position is not fixed, there are many solutions.

( 2015-12-11 15:15:39 -0500 )edit

Sort by » oldest newest most voted

I have tried the following but I'm not getting any correct results so far:

tf::Vector3 fwd{1.0, 0.0, 0.0};
tf::Vector3 newFwd{(pointToHere - pointFromHere).normalized()};
tf::Vector3 ax{fwd.cross(newFwd)};
double alpha = acos(fwd.dot(newFwd));
tf::Quaternion newOrientation{ax.normalized(), alpha};


My idea is to construct the orientation with respect to my world frame, so all vectors I am using here have been appropriately transformed into my world coordinate system. My steps (as detailed in the code above) are as follows:

1. Get the new pointing direction via pointToHere-pointFromHere
2. Calculate the axis of rotation using the cross product of what I consider my old and new forward vector (which is the x-axis of my manipulator)
3. Get the corresponding angle using the dot product
4. Build the quaternion

In most cases where I get a valid pose, the direction of my forward axis is actually completely wrong. It should be pointing the other way...

Any ideas on what I may be missing here? The only thing I can think of right now is that the rotation axis may end up being incorrect..

more