# How to make a robtarget position dependent from a variable

**URL:** <https://tech-community.robotics.abb.com/t/how-to-make-a-robtarget-position-dependent-from-a-variable/11708>\
**Category:** RAPID Programming\
**Tags:** robtarget\
**Created:** [November 25, 2024, 6:24am UTC](https://tech-community.robotics.abb.com/t/how-to-make-a-robtarget-position-dependent-from-a-variable/11708 "2024-11-25T06:24:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alpakkon](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@alpakkon](https://tech-community.robotics.abb.com/u/alpakkon)\
**Post date:** [November 25, 2024, 6:24am UTC](https://tech-community.robotics.abb.com/t/how-to-make-a-robtarget-position-dependent-from-a-variable/11708/1 "2024-11-25T06:24:09Z")

</div>

I have about 10 robtarget positions whose x and y coordinates are all dependent from a which is an input variable so it cannot be constant. My robtarget positions look something like this:

VAR robtarget Target\_10:=[[(10_a), (8_a), 0],…];  
VAR robtarget Target\_20:=[[(18_a), (10_a), 0],…];

But the problem is that the values in robtarget positions have to be constant.  
So is it somehow possible to make my positions dependent from a?

---

<div class="post-metadata">

**Author:** ![nicolahinssen](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@nicolahinssen](https://tech-community.robotics.abb.com/u/nicolahinssen)\
**Post date:** [November 25, 2024, 7:21am UTC](https://tech-community.robotics.abb.com/t/how-to-make-a-robtarget-position-dependent-from-a-variable/11708/2 "2024-11-25T07:21:01Z")

</div>

You can do the following after the variable declarations:

```auto
Target_10.trans := [10*a, 8*a, 0];

```

---

<div class="post-metadata">

**Author:** ![Tompanhuhu](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/tompanhuhu/32/3366_2.png) [@Tompanhuhu](https://tech-community.robotics.abb.com/u/Tompanhuhu)\
**Post date:** [November 25, 2024, 7:38am UTC](https://tech-community.robotics.abb.com/t/how-to-make-a-robtarget-position-dependent-from-a-variable/11708/3 "2024-11-25T07:38:48Z")

</div>

You can also use functions if you don’t want the robtarget to be changed by operators.

```auto
    CONST robtarget a:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];

    FUNC robtarget Target_10()
        VAR robtarget ret;
        ret := a;
        ret.trans:= [10*a.trans.x, 8*a.trans.y, 0];
        RETURN ret;
    ENDFUNC
    
    PROC main()
        MoveL a,v1000,z50,tool0\WObj:=wobj0;
        MoveL Target_10(),v1000,z50,tool0\WObj:=wobj0;
    ENDPROC

```

---

<div class="post-metadata">

**Author:** ![alpakkon](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@alpakkon](https://tech-community.robotics.abb.com/u/alpakkon)\
**Post date:** [November 25, 2024, 8:03am UTC](https://tech-community.robotics.abb.com/t/how-to-make-a-robtarget-position-dependent-from-a-variable/11708/4 "2024-11-25T08:03:14Z")

</div>

Thanks, that’s really helpful! I’m gonna try it out later

---

<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:** [November 25, 2024, 1:29pm UTC](https://tech-community.robotics.abb.com/t/how-to-make-a-robtarget-position-dependent-from-a-variable/11708/5 "2024-11-25T13:29:40Z")

</div>

@Tompanhuhu If you don’t want a position to be modified by anyone at all, do this:

```auto
         CONST robtarget myRobtarget:=[[471.96,165.24,337.40],[0.147458,0.375124,0.905628,0.131821],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
CONST robtarget myRobtarget10:=[[360.69,346.35,337.40],[0.116071,0.174066,0.964666,0.16015],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
CONST robtarget myRobtarget20:=[[328.12,315.08,266.77],[0.0483949,0.176969,0.980755,0.0667735],[0,0,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
CONST robtarget pLockDown{3}:=[myRobtarget,myRobtarget10,myRobtarget20];

```

The controller will report a position modify error, without a clue as to why.
