ABB robotic quaternion euler calculation

unhandled

(Amaurythomas) #1

Hello,

I am developing my own abb invert kinematic robotic plugin for a specific project.
However I need understand all the calculation to feed the rapid code.
Someone can quickly explain how to calculate the number needed (Please have a look to the red rectangle on the image below) acording to the oriented planes.

Best,

Amaury


(Vicente Soler) #2

They are quaternions (euler would be 3 numbers). You can check my robots plugin: http://www.github.com/visose/robots


#3

I just recently heard about “Quaternion Rotation” from @Michael_Pryor - sounds fascinating:

More here:


(Vicente Soler) #4

If you just want to convert planes to quaternions, this is the code I use:

public static double[] PlaneToQuaternion(Plane plane)
{
var q = Quaternion.Rotation(Plane.WorldXY, plane);
return new double[] { plane.OriginX, plane.OriginY, plane.OriginZ, q.A, q.B, q.C, q.D };
}

Or you want to interpolate 3d rotations? That’s more tricky and theres no “best” way, but a usual way is using axis angle, this is the code I use:

public Plane CartesianLerp(Plane a, Plane b, double t, double min, double max)
{
t = (t - min) / (max - min);
if (double.IsNaN(t)) t = 0;
var newOrigin = a.Origin * (1 - t) + b.Origin * t;
Quaternion q = Quaternion.Rotation(a, b);
q.GetRotation(out var angle, out var axis);
angle = (angle > PI) ? angle - 2 * PI : angle;
a.Rotate(t * angle, axis, a.Origin);
a.Origin = newOrigin;
return a;
}


(Michael Pryor) #5

Hi Vicente, have you seen these ones from Daniel?


(Vicente Soler) #6

Not that one, but an older one, which I reference in the github repository:

    /// <summary>
    /// Quaternion interpolation based on: http://www.grasshopper3d.com/group/lobster/forum/topics/lobster-reloaded
    /// </summary>

Slight advantage of my code is a bit less newing and follows c sharp conventions rather than Daniel’s weird pascal case on parameters and local variables :stuck_out_tongue:


(Michael Pryor) #7

:smiley: then I am sure you will love his QuaternionSpline.gh Obfuscation


(Amaurythomas) #8

thanks a lot for your help, I will look at this carefully !!!


(Vicente Soler) #9

Very creative. I was learning a bit of JavaScript recently and my first thought was that I opened the minified version.


#10

Here’s a very special application where quaternions can help - Avoid Gimbal Lock or you are going to Burn! (you are still going to get smoked, but anyway) :slight_smile:

// Rolf


(Amaurythomas) #11

Thanks a lot, I had time to have a look to your code, it was very helpful !!! now I need to create the socket the send the rapid code !!!