Orientate orthogonal to point
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
Asked by Brick on 2015-12-11 14:11:03 UTC
Answers
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:
- Get the new pointing direction via pointToHere-pointFromHere
- 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)
- Get the corresponding angle using the dot product
- 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..
Asked by Brick on 2015-12-12 09:39:41 UTC
Comments
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.
Asked by 2ROS0 on 2015-12-11 16:15:39 UTC