# Rotate tool around work object Z-axis

**URL:** https://tech-community.robotics.abb.com/t/rotate-tool-around-work-object-z-axis/9265
**Category:** RAPID Programming
**Tags:** rapid, robtarget, movement, reorientation, tcp
**Created:** [January 10, 2020, 2:04pm UTC](https://tech-community.robotics.abb.com/t/rotate-tool-around-work-object-z-axis/9265 "2020-01-10T14:04:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kreddit](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@Kreddit](https://tech-community.robotics.abb.com/u/Kreddit)
#### Post date: [January 10, 2020, 2:04pm UTC](https://tech-community.robotics.abb.com/t/rotate-tool-around-work-object-z-axis/9265/1 "2020-01-10T14:04:56Z")

</div>

Greetings.  
I am looking for a way to define a new point with the same pos-data as an old one, but rotated about 15 degrees around a work object’s Z-axis.  
That is, change the “ori” of a robtarget to be rotated around the Z-axis.  
I still have not gotten the hang of Quaternions, so I was hoping there was a RAPID function to do this for me.  
I am, however, unable to find such a function in my reference manual, and was hoping for some help.

This will be used for alligning a held item with two analog distance sensors. The exact position and orientation of the item on the gripper is not known, so these sensors will be used to account for that. I will move linearly using SearchL untill I hit both the sensors, then rotate using another SearchL untill the inputs from both sensors are equal, using an analog interrupt to set the bool to stop the searches.  
I will use this routine with lots of different items, tools and tool orientations, so I need a way to calculate the point to rotate toward so that the rotation happens only along one axis of the work object that describes these analog sensors.

---

<div class="post-metadata">

### Author: ![j\_proulxFB](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@j\_proulxFB](https://tech-community.robotics.abb.com/u/j_proulxFB)
#### Post date: [January 10, 2020, 2:34pm UTC](https://tech-community.robotics.abb.com/t/rotate-tool-around-work-object-z-axis/9265/2 "2020-01-10T14:34:54Z")

</div>

The function you want is RelTool

VAR num nZaxisRotation:=-15;  
PERS tooldata Tooldata\_1:=[TRUE,[[0,0,100],[1,0,0,0]],[1,[0,0,1],[1,0,0,0],0,0,0]];  
CONST robtarget Target\_10:=[[302,0,458],[0,0,1,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];  
CONST robtarget Target\_20:=[[436.769200716,0,457.999973956],[0.000000008,0,1,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];  
VAR robtarget pSearchPos1:=[[302,0,458],[0,0,1,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];  
VAR robtarget pSearchPos2:=[[302,0,458],[0,0,1,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];

PROC Path\_10()  
MoveL Target\_10,v1000,fine,Tooldata\_1\WObj:=wobj0;  
SearchL\Stop,diSearch1,pSearchPos1,Target\_20,v50,Tooldata\_1;  
SearchL \Stop,diSearch2,pSearchPos2,RelTool(pSearchPos1,0,0,0\Rz:=nZaxisRotation),v50,Tooldata\_1;  
ENDPROC

Move to Target\_10. SearchL towards Target\_20. Stop when diSearch1 is made. The stop position is pSeachPos1.  
Next do a searchL rotating around the z axis of pSearchPos1 using RelTool -15 degrees to stop at pSearchPos2.

---

<div class="post-metadata">

### Author: ![Kreddit](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@Kreddit](https://tech-community.robotics.abb.com/u/Kreddit)
#### Post date: [January 13, 2020, 8:13am UTC](https://tech-community.robotics.abb.com/t/rotate-tool-around-work-object-z-axis/9265/3 "2020-01-13T08:13:21Z")

</div>

> [@](#):
>

I greatly appreciate your reply, but with all due respect, I disagree.  
As I understand the RelTool function, it uses the acitve tool’s coordinate system, which is not what I want.  
I would like to rotate around the Z-axis of a work object, not the tool. The orientation of the tool can vary from call to call, but the work object is always the same.  
The work object Z-axis is parallel to the world coordinate system, so if rotating around world Z-axis is easier, that works too.

---

<div class="post-metadata">

### Author: ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)
#### Post date: [January 13, 2020, 1:51pm UTC](https://tech-community.robotics.abb.com/t/rotate-tool-around-work-object-z-axis/9265/4 "2020-01-13T13:51:13Z")

</div>

I think that I would look into using the PoseMult function.

---

<div class="post-metadata">

### Author: ![EricH](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@EricH](https://tech-community.robotics.abb.com/u/EricH)
#### Post date: [January 13, 2020, 3:15pm UTC](https://tech-community.robotics.abb.com/t/rotate-tool-around-work-object-z-axis/9265/5 "2020-01-13T15:15:25Z")

</div>

You could use the workobject as tool and then use RelTool. Shouldn’t be a problem.
