Can UR robot script generate new variables automatically?
/ Most recent by cwwstc
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
Var_now = get_actual_tcp_pose()
if point_dist( Var_start,Var_now) > 0.1 then
(Var_) + i = Var_now
Var_start = Var_now
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.