# Manual quaternion example gives me a different result? What am I missing?

**URL:** <https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404>\
**Category:** RAPID Programming\
**Created:** [April 1, 2020, 2:00am UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404 "2020-04-01T02:00:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 1, 2020, 2:00am UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/1 "2020-04-01T02:00:30Z")

</div>

Just in general:

If i try run the example below i have a different result than the manual:  
Mine is 1.93185, 0, 0.517638, 0.

Am i making a mistake? Is the example correct? Any input appreciated

double q1 = sqrt(cos(0.523599)+ 1 + cos(0.523599) +1);  
double q2 = sqrt(cos(0.523599) -1 - cos(0.523599) + 1);  
double q3 = sqrt(1 - cos(0.523599) - cos(0.523599) + 1);

double q4 = sqrt(cos(0.523599) - cos(0.523599) -1 + 1);

 ![image.png](https://europe1.discourse-cdn.com/flex005/uploads/robotics1/original/1X/f1d3c7e16bde29abc6ecfb625846a56f86760ad3.png)

---

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 1, 2020, 8:17am UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/2 "2020-04-01T08:17:48Z")

</div>

Closer but that would be [0.2588223, 0, 0.9659249, 0] in abb notation?  
Abb notation is x, y, z, w?

 ![image.png](https://europe1.discourse-cdn.com/flex005/uploads/robotics1/original/1X/7dc095ed9212d9b80c4b05c3a63a5d62c7fa2115.png)

The result in the example looks correct (middle not rotated) unit but how?

const robtarget test2\_1\_l0:=[[-0.52, -30.00, 10.13], [0.9659249, 0, 0.2588223, 0],[-1,0,-1,0], [9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];  
const robtarget test2\_2\_l0:=[[4.18, -29.71, 10.26], [0, 0.2588223, 0, 0.9659249],[-1,0,-1,0], [9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]

 ![image.png](https://europe1.discourse-cdn.com/flex005/uploads/robotics1/original/2X/5/5681e1919914a24d4eda0033662f78a2a9eafe70.png)

The doc doesnt exactly explain the notation?

Components  
The data type orient has the following components:  
q1  
Data type: num  
Quaternion 1.  
q2  
Data type: num  
Quaternion 2.  
q3  
Data type: num  
Quaternion 3.  
q4  
Data type: num  
Quaternion 4.

---

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 1, 2020, 9:01am UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/3 "2020-04-01T09:01:53Z")

</div>

Can we just confirm this is a correct example and the notation?

Will robotstudio deal with scientific notation like 5.68811e-14? I dont think it did in my quick test.

The calculator show above is this

> **[3D Rotation Converter](https://www.andre-gaschler.com/rotationconverter/)**

---

<div class="post-metadata">

**Author:** ![graemepaulin](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@graemepaulin](https://tech-community.robotics.abb.com/u/graemepaulin)\
**Post date:** [April 1, 2020, 6:14pm UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/4 "2020-04-01T18:14:47Z")

</div>

I think the Euler angles are in the order Z,Y,X.  
As there is a RAPID function EulerZYX which obtains the rotation angles from the quaternions and OrientZYZ that build the quaternions.

---

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 1, 2020, 9:09pm UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/5 "2020-04-01T21:09:41Z")

</div>

So we think the result is correct? Or that quaternions are q= [w,Z,Y,X]?Or both :)?

I am using libigl, a proven library and have trouble to make any sense of the results in robotstudio

---

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 1, 2020, 9:49pm UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/6 "2020-04-01T21:49:26Z")

</div>

Here is the result with EulerZYX

---

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 1, 2020, 10:16pm UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/7 "2020-04-01T22:16:44Z")

</div>

With const robtarget test2\_1\_l0:=[[-0.52, -30.00, 10.13], [0.965926, 0, 0.258819, 0],[-1,0,-1,0], [9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];  
only y has an angle

 ![image.png](https://europe1.discourse-cdn.com/flex005/uploads/robotics1/original/2X/8/8c94cd3c4478e201e9d6dce69dcddd78d974cb5e.png)

---

<div class="post-metadata">

**Author:** ![graemepaulin](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@graemepaulin](https://tech-community.robotics.abb.com/u/graemepaulin)\
**Post date:** [April 1, 2020, 10:25pm UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/8 "2020-04-01T22:25:38Z")

</div>

I am not any good at the math involved in this…  
So I went online found a converter which used ZYX for the Euler input and plugged in 30,0,30 - got a completely different result to the manual extract!  
So had a good look at the diagram of the robot diagram in your extract from the manual it looks like a 30° rotation round the Y axis.  
You plug those numbers into the converter ( z= 0, y=30, x=0) you get the result shown in the manual.

What was the manual you got the extract from and I will raise it as a correction?

---

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 1, 2020, 11:08pm UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/9 "2020-04-01T23:08:50Z")

</div>

Thanks so much, that matches robotstudios result. The example this is page 1152

3 Data types  
3.37. orient - Orientation  
RobotWare - OS  
in

ABB Robotics  
Technical reference manual  
RAPID Instructions, Functions and Data types

I assume there isnt anything else available? No i know howit doesnt work mainly

---

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 6, 2020, 1:03am UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/10 "2020-04-06T01:03:01Z")

</div>

Can somebody confirm robotstudio has a right-handed coordinate system?

---

<div class="post-metadata">

**Author:** ![k\_schmid](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@k\_schmid](https://tech-community.robotics.abb.com/u/k_schmid)\
**Post date:** [April 7, 2020, 8:23am UTC](https://tech-community.robotics.abb.com/t/manual-quaternion-example-gives-me-a-different-result-what-am-i-missing/9404/11 "2020-04-07T08:23:42Z")

</div>

rotations are in world space? parent space?

so my coordinate system is z down, right handed , ZYX order…
