# Rotate Robot

**URL:** <https://tech-community.robotics.abb.com/t/rotate-robot/7284>\
**Category:** RobotStudio\
**Created:** [July 27, 2016, 9:26am UTC](https://tech-community.robotics.abb.com/t/rotate-robot/7284 "2016-07-27T09:26:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samucha](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Samucha](https://tech-community.robotics.abb.com/u/Samucha)\
**Post date:** [July 27, 2016, 9:26am UTC](https://tech-community.robotics.abb.com/t/rotate-robot/7284/1 "2016-07-27T09:26:43Z")

</div>

Hi, All

I have many questions. I get Position X , Position Y, Angle of component from camera,but I don’t know how to use command(Rapid) for robot move to new Position.

I know I can use command MoveL offs( … ); for move new position x ,y .But I don’t know how to use command for Rotate(Angle).

Ex. Values from camera Delta x = 10 mm. , Delta y = 20 mm. , Delta Angle = 5°

I use  
MoveL Offs(robot\_cur,10,20,0),v100,fine,tool0;

I sorry if you understand, I use google translate.  
Thank for help.

---

<div class="post-metadata">

**Author:** ![OskarHenriksson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/oskarhenriksson/32/1961_2.png) [@OskarHenriksson](https://tech-community.robotics.abb.com/u/OskarHenriksson)\
**Post date:** [July 27, 2016, 9:56am UTC](https://tech-community.robotics.abb.com/t/rotate-robot/7284/2 "2016-07-27T09:56:58Z")

</div>

Hello Samucha  
I understand that you want to rotate the position after you have made an offset.  
Please read the help section about orient in RobotStudio.

It its possible to use OrientZYX(anglez, angley, anglex) instead of the object orient1 if needed.

````auto
VAR orient orient1;

```
VAR robtarget p20;
```

````

```auto

orient1 := [0.707, 0, 0.707, 0];
        
p20 := CRobT(\Tool:=tool0\wobj:=wobj0);
p20 := Offs(p20,10,0,0);
**p20.rot := orient1; //** <b>p20.rot := OrientZYX(30,30,30); 

Hope it was the answer you're looking for
/Oskar</b>

```

---

<div class="post-metadata">

**Author:** ![Samucha](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Samucha](https://tech-community.robotics.abb.com/u/Samucha)\
**Post date:** [July 28, 2016, 1:22am UTC](https://tech-community.robotics.abb.com/t/rotate-robot/7284/3 "2016-07-28T01:22:20Z")

</div>

Hi, OskarHenriksson  
Thanks for reply.

````auto
<b>p20.rot := OrientZYX(30,30,30);

30 is Angle ? If I want to rotate z-axis only. What is command to use?
</b>

```
But I try this command p20.rot **:=** OrientZYX(30,0,0); . It not work.

Thanks for help.

```

````

---

<div class="post-metadata">

**Author:** ![Pavel\_Riabichev](https://avatars.discourse-cdn.com/v4/letter/p/8e7dd6/32.png) [@Pavel\_Riabichev](https://tech-community.robotics.abb.com/u/Pavel_Riabichev)\
**Post date:** [July 28, 2016, 6:10am UTC](https://tech-community.robotics.abb.com/t/rotate-robot/7284/4 "2016-07-28T06:10:37Z")

</div>

Example:

PERS robtarget p10:=[[423.76,413.882,0],[3.78552E-08,0.866025,0.5,2.18557E-08],[0,2,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];  
VAR num anglex;  
VAR num angley;  
VAR num anglez;

PROC main()

!Get current angles for p10  
anglex:=EulerZYX(\X,p10.rot);  
angley:=EulerZYX(\Y,p10.rot);  
anglez:=EulerZYX(\Z,p10.rot);

p10.rot:=OrientZYX(anglez,angley,anglex);  
MoveJ p10,v1000,z50,tool0\WObj:=wobj0;  
WaitRob\InPos;

**p10.rot:=OrientZYX(anglez+30,angley,anglex);**

MoveJ p10,v1000,z50,tool0\WObj:=wobj0;  
WaitRob\InPos;

ENDPROC

---

<div class="post-metadata">

**Author:** ![sturner](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/sturner/32/3432_2.png) [@sturner](https://tech-community.robotics.abb.com/u/sturner)\
**Post date:** [August 1, 2016, 10:12am UTC](https://tech-community.robotics.abb.com/t/rotate-robot/7284/5 "2016-08-01T10:12:44Z")

</div>

Check out the RelTool function… this will allow you to use a position and optional rotation in degrees

Basic examples  
The following examples illustrate the function RelTool.  
Example 1  
MoveL RelTool (p1, 0, 0, 100), v100, fine, tool1;  
The robot is moved to a position that is 100 mm from p1 in the z direction of the tool.  
Example 2  
MoveL RelTool (p1, 0, 0, 0 \Rz:= 25), v100, fine, tool1;  
The tool is rotated 25° around its z-axis.

---

<div class="post-metadata">

**Author:** ![Marcello](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/marcello/32/2243_2.png) [@Marcello](https://tech-community.robotics.abb.com/u/Marcello)\
**Post date:** [August 2, 2016, 12:16pm UTC](https://tech-community.robotics.abb.com/t/rotate-robot/7284/6 "2016-08-02T12:16:34Z")

</div>

try to combine offset and reltool in the same command

**MoveL Offs(RelTool(robot\_cur**\*\*,0,0,0\Rx:=0\Ry:=0\Rz:=5),10,20,0)\*\*\*\*,v100,fine,tool0;\*\*

---

<div class="post-metadata">

**Author:** ![John\_Verheij](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/john_verheij/32/1724_2.png) [@John\_Verheij](https://tech-community.robotics.abb.com/u/John_Verheij)\
**Post date:** [August 4, 2016, 7:28am UTC](https://tech-community.robotics.abb.com/t/rotate-robot/7284/7 "2016-08-04T07:28:31Z")

</div>

It depends if you want to use the “_active tool coordinate system_” or “_object coordinate system_”. In case of the “_active tool coordinate system_”, then you can use the function _RelTool_ as stated above.  
In your first post you indicate using the function _Offs_ for translation, which uses the “_object coordinate system_”. If this is also the case for the rotations, i would recommend just quaternion multiplications. Remark, you have to be careful in which order you apply the rotations, for example the function “_RelTool_” and “_OrientZYX_” uses the ZYX order. You can think of a function like this:

```auto

  FUNC robtarget Angle(robtarget Point,num Rx,num Ry,num Rz,\switch ZYX|switch XYZ|switch ZXY)

    VAR robtarget PointRot;

    VAR orient rot;

    ! copy robtarget

    PointRot:=Point;

    ! rotate 180 degrees around x-axis to get "object coordinate system

    PointRot.Rot:=Point.rot*OrientZYX(0,0,180);

    ! choose rotation order and define rotation

    IF present(XYZ) THEN

      rot:=OrientZYX(0,0,Rx)*OrientZYX(0,Ry,0)*OrientZYX(Rz,0,0);

    ELSEIF present(ZXY) THEN

      rot:=OrientZYX(Rz,0,0)*OrientZYX(0,0,Rx)*OrientZYX(0,Ry,0);

    ELSE

      ! OrientZYX uses the order: rotation around Z-axis, rotation around the new Y-axis, rotation around the new X-axis

      rot:=OrientZYX(Rz,Ry,Rx);

    ENDIF

    ! apply rotation and rotate back 180 degrees around x-axis

    PointRot.Rot:=PointRot.Rot*rot*OrientZYX(0,0,180);

    ! return rotated robtarget

    RETURN PointRot;

  ENDFUNC

```
