# Get actual Euler and Quaternion angles

**URL:** <https://tech-community.robotics.abb.com/t/get-actual-euler-and-quaternion-angles/7210>\
**Category:** RAPID Programming\
**Tags:** robotstudio, rapid-code, trap, status-update\
**Created:** [June 6, 2016, 4:34pm UTC](https://tech-community.robotics.abb.com/t/get-actual-euler-and-quaternion-angles/7210 "2016-06-06T16:34:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMob](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/stevemob/32/1600_2.png) [@SteveMob](https://tech-community.robotics.abb.com/u/SteveMob)\
**Post date:** [June 6, 2016, 4:34pm UTC](https://tech-community.robotics.abb.com/t/get-actual-euler-and-quaternion-angles/7210/1 "2016-06-06T16:34:29Z")

</div>

Hello,

I have a list of targets(Targets 001-127), and I have a TRAP routine set up to constantly update and print out the position (X,Y,Z) of the robot, even while it is in the middle of a move. My question is, can I also update and print out the current Euler and Quaternion Angles, even while the robot is moving? I am updating the status 10 times a second, and I am trying to compare the commanded vs. actual for position and the angles. I got the position part, just not sure what to do about the angles?

Thanks for any help,  
SM

---

<div class="post-metadata">

**Author:** ![jsph](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@jsph](https://tech-community.robotics.abb.com/u/jsph)\
**Post date:** [June 7, 2016, 12:28pm UTC](https://tech-community.robotics.abb.com/t/get-actual-euler-and-quaternion-angles/7210/2 "2016-06-07T12:28:41Z")

</div>

Yes, you can use the RAPID function CRobT, which “returns a robtarget value with position (x, y, z), orientation (q1 … q4), robot axes configuration, and external axes position.” It would then be straightforward to convert the orientations into Euler angles, if required.

---

<div class="post-metadata">

**Author:** ![SteveMob](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/stevemob/32/1600_2.png) [@SteveMob](https://tech-community.robotics.abb.com/u/SteveMob)\
**Post date:** [June 8, 2016, 1:43pm UTC](https://tech-community.robotics.abb.com/t/get-actual-euler-and-quaternion-angles/7210/3 "2016-06-08T13:43:39Z")

</div>

jsph,

Thank you for your reply. I am using CRobT just like you said. I am trying to send the data as a string to LabVIEW via sockets. I get an error saying that the string is too long. How can I break the data into multiple strings, 1 string for position, 1 string for quaternions, etc.?

Also, how can I parse the Quaternion angles and then convert to Euler angles?

Thanks for the help!  
SM

---

<div class="post-metadata">

**Author:** ![SteveMob](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/stevemob/32/1600_2.png) [@SteveMob](https://tech-community.robotics.abb.com/u/SteveMob)\
**Post date:** [June 8, 2016, 2:52pm UTC](https://tech-community.robotics.abb.com/t/get-actual-euler-and-quaternion-angles/7210/4 "2016-06-08T14:52:10Z")

</div>

Or is there a way to eliminate some of the values from CRobT, such as the External Axes values or Axis Configurations? That would shorten the string.

Thanks,  
SM

---

<div class="post-metadata">

**Author:** ![jsph](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@jsph](https://tech-community.robotics.abb.com/u/jsph)\
**Post date:** [June 13, 2016, 9:41am UTC](https://tech-community.robotics.abb.com/t/get-actual-euler-and-quaternion-angles/7210/5 "2016-06-13T09:41:20Z")

</div>

You can access each component of the the RobTarget record before converting to a string, which will result in shorter stings.

In the header, add:

```auto
VAR robtarget currentRT;
VAR string posStr;
VAR string orientStr;
VAR string confdataStr;
VAR string extjointStr;

```

In the procedure, add:

```auto
currentRT := CRobT(\Tool:=tool0 \WObj:=wobj0); !read current robtarget
posStr:=ValToStr(currentRT.trans); !current robot position
orientStr:=ValToStr(currentRT.rot); !current robot orientation
confdataStr:=ValToStr(currentRT.robconf); !current robot configuration
extjointStr:=ValToStr(currentRT.extax); !current external axis position

```

Or you could go even further down, if required, e.g.

```auto
xStr := NumToStr(currentRT.trans.x,3);

```

The function EulerZYX can into an Euler angle component from an orient-type variable.

```auto
anglex := EulerZYX(\X, currentRT.rot);
angley := EulerZYX(\Y, currentRT.rot);
anglez := EulerZYX(\Z, currentRT.rot);

```

These nums could then be converted to strings and concatenated if you wish, although I would be temped to do the conversion to Euler angles in LabVIEW or even in Excel after recording the data.

Hope this helps. Note, the code is untested.

Regards,  
Joseph
