Hi there,
I’m fairly new to RAPID/RobotStudio and only have some fairly decent programming experience in Python.
I currently have a Python script that writes a RAPID module bases on user input that contains basically robtargets of work locations.
The amount of robtargets can change with every new product. One time it’s 5 work locations, other time it’s over a 100.
Example code of the robtarget module looks like this:
MODULE data_module
CONST robtarget WL_1 := [ [1750,2750,100.00], [0, 0, 0, 0], [0, 0, 0, 0], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST robtarget WL_2 := [ [1750,3250,100.00], [0, 0, 0, 0], [0, 0, 0, 0], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST robtarget WL_3 := [ [2250,3250,100.00], [0, 0, 0, 0], [0, 0, 0, 0], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST robtarget WL_4 := [ [2250,2750,100.00], [0, 0, 0, 0], [0, 0, 0, 0], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST robtarget WL_5 := [ [2500,2500,100.00], [0, 0, 0, 0], [0, 0, 0, 0], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST num amount := 5;
CONST string robtargetnames {5} := [“WL_1”,“WL_2”,“WL_3”,“WL_4”,“WL_5”];
ENDMODULE
This Python written module is supposed to be loaded in the controller in addition with the robot’s main modules that work on the provided robtargets.
However I’m having trouble realising this.
I’ve tried doing it like in an array way:
PROC Path_10()
VAR robtarget current_robtarget;
FOR i FROM 1 TO amount DO
GetDataVal robtargetnames{i},current_robtarget;
MoveJ current_robtarget,v1000,z100,MyTool\WObj:=wobj1;
ENDFOR
ENDPROC
Also tried it with Offsets (with a script written module containing CONST of robtarget, x, y and z values):
##Example of segments in data_module:
CONST num x_coor_1:=100
CONST num y_coor_1:=300
*CONST num amount := 5;*
*CONST string x_coor_list{5}:=**["x_coor_1","x_coor_2",*~~~~~ETC.
~~~~ETC.
##
*PROC Path_10()*
*CONST robtarget home:=**[ [1000,0,100.00], [0, 0, 0, 0], [0, 0, 0, 0], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];*
*VAR robtarget current_robtarget;*
*VAR num x_value;*
*VAR num y_value;*
_FOR i FROM 1 to **amount** DO_
xval:=x_coor_list{i};
yval:=y_coor_list{i};
current_robtarget:=Offs(home, xval, yval, 0);
MoveJ current_robtarget,*v1000,z100,MyTool\WObj:=wobj1;*
*ENDFOR*
*ENDPROC*
Non really has run smooth and I can't really find clear examples of working with variable robtargets.
A lot of attempts in RobotStudio end up in constant errors like:
*Check the controller status*
*Execution Error*
*Argument Error*
*and more...*
Other times it tries to straight up move to the world coordinate 0,0,0 (robotarms base).
I can't really find likewise problems except a handfull of array and offset based questions/example videos but they all work with pre-existing robtargets.
The only "functionable" solution I know of is writing all the instructions with their unique work locations as a script in Python and uploading that to a controller, but I'm trying to have all the instructions pre-written in RAPID itself.
Any advise is appreciated!