# Array using robtarget

**URL:** <https://tech-community.robotics.abb.com/t/array-using-robtarget/9318>\
**Category:** RAPID Programming\
**Tags:** array, programming, robotstudio, rapid\
**Created:** [February 12, 2020, 9:00am UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318 "2020-02-12T09:00:38Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakobfranzzon](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/jakobfranzzon/32/3137_2.png) [@jakobfranzzon](https://tech-community.robotics.abb.com/u/jakobfranzzon)\
**Post date:** [February 12, 2020, 9:00am UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/1 "2020-02-12T09:00:38Z")

</div>

Hello! Been stuck with doing an array with 6 different robtargets. It is possible to do it this way:

PERS num nPartCount := 0;

PERS robtarget LeavePos{6} :=  
[[[620,1200,-86.402252976],[0.001544941,-0.70381839,-0.710369702,-0.003489157],[-2,0,1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],  
[[220,1200,-86.402252976],[0.001544941,-0.70381839,-0.710369702,-0.003489157],[-2,0,1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],  
[[-220,1200,-86.402252976],[0.001544941,-0.70381839,-0.710369702,-0.003489157],[-2,0,1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],  
[[620,875,-86.402252976],[0.001544941,-0.70381839,-0.710369702,-0.003489157],[-2,0,1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],  
[[220,875,-86.402252976],[0.001544941,-0.70381839,-0.710369702,-0.003489157],[-2,0,1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],  
[[-220,875,-86.402252976],[0.001544941,-0.70381839,-0.710369702,-0.003489157],[-2,0,1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]];

And in my main I would write something like this:

nPartCount := nPartcount+1;  
LeavePos{nPartCount};

The last line is where I get the error message. I think it’s an easy fix but I can’t figure it out. Thanks in advance!

---

<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:** [February 12, 2020, 12:42pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/2 "2020-02-12T12:42:36Z")

</div>

Sure, this works. Last line just needs a movement order.

```auto
  MoveJ LeavePos{nPartCount},v100,z200,tool0;

```

---

<div class="post-metadata">

**Author:** ![jakobfranzzon](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/jakobfranzzon/32/3137_2.png) [@jakobfranzzon](https://tech-community.robotics.abb.com/u/jakobfranzzon)\
**Post date:** [February 12, 2020, 1:11pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/3 "2020-02-12T13:11:03Z")

</div>

Thanks! Didn’t think about that at all. Very helpful!

---

<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:** [February 12, 2020, 1:46pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/4 "2020-02-12T13:46:03Z")

</div>

Please do not do this: nPartCount := nPartcount+1;. Simply written is expressed: Incr nPartCount;

---

<div class="post-metadata">

**Author:** ![jakobfranzzon](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/jakobfranzzon/32/3137_2.png) [@jakobfranzzon](https://tech-community.robotics.abb.com/u/jakobfranzzon)\
**Post date:** [February 12, 2020, 2:23pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/5 "2020-02-12T14:23:58Z")

</div>

Didn’t know you could do that, thanks. Will change it right away.

---

<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:** [February 12, 2020, 4:23pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/6 "2020-02-12T16:23:56Z")

</div>

Just a pet peeve of mine, Incr and Decr are mathematical instructions. :# It will help make your code look smarter.

---

<div class="post-metadata">

**Author:** ![Daper](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daper](https://tech-community.robotics.abb.com/u/Daper)\
**Post date:** [November 17, 2023, 1:13pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/7 "2023-11-17T13:13:14Z")

</div>

Hello,

In a similar way, I am using a dynamic assigment to the robot targets in a loop like herebelow:

FOR i FROM 1 to n  
MoveJ LeavePos{i}, v100, z200, tool0;  
ENDFOR

And I am wondering if the execution of this code will result in the same trajectory as:

MoveJ LeavePos{1}, v100, z200, tool0  
MoveJ LeavePos{2}, v100, z200, tool0  
MoveJ LeavePos{3}, v100, z200, tool0  
MoveJ LeavePos{4}, v100, z200, tool0  
…  
MoveJ LeavePo{n}, v100, z200, tool0

in terms of controller internal path planning. Will it ?

As far as I understood, the robot reads one line of movement ahead to generate a smooth trajectory (depending on the zone size) but in the case of the loop, it kind of can’t read in advance, can it ?

Will the resulting trajectory be less smooth in comparison to the MoveJ sequence ?  
Or is there absolutely no difference, and the robot directly interpretates the next freshly built moveJ ? @lemster68

Thank you very much in advance

---

<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 17, 2023, 1:46pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/8 "2023-11-17T13:46:05Z")

</div>

It will work just fine. As a matter of fact, some of our programs do pretty much the same thing as in your FOR loop.

---

<div class="post-metadata">

**Author:** ![Daper](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daper](https://tech-community.robotics.abb.com/u/Daper)\
**Post date:** [November 17, 2023, 2:04pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/9 "2023-11-17T14:04:23Z")

</div>

Thank you for your quick reply !

Good to know that ABB does kind of the same thing.

And also, what if another instruction is added within the FOR loop like:

FOR i FROM 1 to n  
_One motionless instruction;_  
MoveJ LeavePos{i}, v100, z200, tool0;  
ENDFOR

Will the trajectory planner still remain unaffected either if the instruction is a priori not computationnaly intense ?

---

<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 17, 2023, 2:07pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/10 "2023-11-17T14:07:45Z")

</div>

It will not be a problem. By the way, the motion planner reads ahead more than one move instruction.

---

<div class="post-metadata">

**Author:** ![Daper](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daper](https://tech-community.robotics.abb.com/u/Daper)\
**Post date:** [November 17, 2023, 2:39pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/11 "2023-11-17T14:39:42Z")

</div>

Thank you for the reactive support. Really appreciate

---

<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 17, 2023, 3:49pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/12 "2023-11-17T15:49:17Z")

</div>

Be advised that ANY non-motion instruction that causes a wait will break up the fluidity.

---

<div class="post-metadata">

**Author:** ![Daper](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daper](https://tech-community.robotics.abb.com/u/Daper)\
**Post date:** [June 21, 2024, 1:26pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/13 "2024-06-21T13:26:54Z")

</div>

Hi,

I would like to use a pretty large array of robtargets thereof values are written by a C# program thanks to REST API commands.

I initialized my array as: PERS robtagret TgtArray{200};

But I didn’t work. I reduced the array size down to 31 and it worked. (32 and more didn’t).  
Is RAPID expert aware of such a limit? Is there a maximal amount specified somewhere ?

When I look into the virtual flexpendant system info → software resources → RAPID → RAPID memory, I can see that the current free RAPID Memory = 31.78 MB and Total RAPID memory 39.02 MB.

Even with 200 robtargets, I feel like I am far below 31.78 MB of data…

---

<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:** [June 21, 2024, 2:23pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/14 "2024-06-21T14:23:38Z")

</div>

I made one with 200 in RS and it had no errors

---

<div class="post-metadata">

**Author:** ![Daper](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Daper](https://tech-community.robotics.abb.com/u/Daper)\
**Post date:** [June 25, 2024, 12:12pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/15 "2024-06-25T12:12:15Z")

</div>

Ok thanks good to know… I assume it was with IRC5, was it ?

---

<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:** [June 25, 2024, 1:54pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/16 "2024-06-25T13:54:04Z")

</div>

Yes, IRC5.

---

<div class="post-metadata">

**Author:** ![mandolas](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/mandolas/32/2496_2.png) [@mandolas](https://tech-community.robotics.abb.com/u/mandolas)\
**Post date:** [August 2, 2024, 6:46pm UTC](https://tech-community.robotics.abb.com/t/array-using-robtarget/9318/17 "2024-08-02T18:46:03Z")

</div>

Hi…  
See if this helps…

[https://forums.robotstudio.com/discussion/13805/using-arrays-and-for-loops#latest](https://forums.robotstudio.com/discussion/13805/using-arrays-and-for-loops#latest)

Good work.
