DoF - a Robotiq Community
Warning sign
The Dof Community was shut down in June 2023. This is a read-only archive.
If you have questions about Robotiq products please reach our support team.


I have a question about generate new variables automatically with UR5 robot while performing a path recording task.

Assume I have a starting position variable Var_start, and a variable get current position Var_now. From waypoint 1 to waypoint 2, I need to record the trajectory for each displacement of 0.1 m, and store the position in new variables starting from Var_1, Var2,...etc. However, I do not know the exact number of new variables needed to perform this task. Therefore, I am asking if there is a way the script can generate new variables with different names automatically?

The pseudo code is as following:

i = 1

Var_start = waypoint 1

While True:

    Var_now = get_actual_tcp_pose()

    if point_dist( Var_start,Var_now) > 0.1 then

        (Var_) + i = Var_now

        Var_start = Var_now

    end if


Comments: I have few thoughts about achieving this, such as:

1) update new name of variables as in pseudo code.

Problem: UR script cannot combine string and integer together, which is able to be done in Python 3.0 but not here. And new name string cannot be accessed as new name of variable directly.

2) Create a long array of position variables and then use them in sequence.

Problem: position value itself is already an array of 6. I have not tried, but I do think I can create 2-D array for achieving this since UR script defines strickly on the format of its variables.

Thus, please let me know if there is a way or an alternative way can achieve to generate unknown number of new variables in a UR program.

Thank you very much in advance.




Yes, that is exactly what I meant.  I have never tried creating large lists of poses but I know a regular list can hold somewhere around 254 elements before there are issues.  If you get this working please let the community know so that we can see how you solved that problem.

Thank you so much! The test will be conducted next week. I will upload the result and follow ups of this program.