Trouble getting a variable robtarget program to function (variable robtarget module)
in RobotStudio
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:
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:
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!
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
~~~~ETC.
CONST num amount := 5;
CONST string x_coor_list{5}:=["x_coor_1","x_coor_2",~~~~~ETC.
~~~~ETC.
##
PROC Path_10()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
~~~~ETC.
CONST num amount := 5;
CONST string x_coor_list{5}:=["x_coor_1","x_coor_2",~~~~~ETC.
~~~~ETC.
##
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!
0
Answers
-
Forget the GetDataVal.
FOR i FROM 1 to amount DO MoveJ robtargetnames{i},v1000,z100,MyTool\WObj:=wobj1 ENDFOR
Change the datatype for robtargetnames from string to robtarget and store the positions in the array.Lee Justice0 -
lemster68 said:Forget the GetDataVal.
FOR i FROM 1 to amount DO MoveJ robtargetnames{i},v1000,z100,MyTool\WObj:=wobj1 ENDFOR
Change the datatype for robtargetnames from string to robtarget and store the positions in the array.
Type error(101): Type mismatch of expected type robtarget and found type robtarget{3}
Here's the short testing code I tried it with:CONST robtarget Target_10:=[[1750,2750,100.00],[0,0,0,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONST robtarget Target_20:=[[1550,2750,100.00],[0,0,0,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONST robtarget Target_30:=[[1750,2450,100.00],[0,0,0,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];CONST robtarget robtargetnames{3}:=[Target_10,Target_20,Target_30];CONST num amount:=3;PROC Path_10()FOR i FROM 1 TO amount DOMoveJ robtargetnames{i},v1000,z100,MyTool\WObj:=wobj1;ENDFORENDPROC0 -
Move the actual data, the declarations with the values, into the array.Lee Justice0
-
lemster68 said:Move the actual data, the declarations with the values, into the array.I'm sorry but I don't fully understand how it should look like in RAPID-language, do you mean like this:
CONST robtarget robtargetnames{3}:=[[[2222,0,0],[0,0,0,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[[2222,0,150],[0,0,0,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],[[2222,0,260],[0,0,0,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]];
I just keep getting Type Error 101. Tried multiple ways of writing it each giving a check error of "wrong number of record components".
I guess I'm probably writing the array wrong in the RAPID language but I just can't seem to find a clear example of how one should look like in other forums or even in the RAPID manual.0 -
Yes, you are on the right track. Here is one I made in RS:CONST robtarget myRobtargets{3}:=[[[100,200,300],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]],[[100,200,300],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]],[[100,200,300],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]]];Wrong number of components means you said three but it does not see three. Could be a misplaced comma, wrong braces.Lee Justice0
-
As far as I know rotation data must be normalized, sum must be=1. [1,0,0,0] as in Lemster example is ok, 0.0.0.0 is not ok.-----------------
David
Swedish freelance ABB robot programmer0 -
Filling in the rotation data makes the simulation "work", but I have to write down the correct (possible) values otherwise the arm just ends up in an unable to move state. I feel like this method isn't really the way to go.
I could also only run the Path inside the RAPID tab and not the simulation/home tab. Using the Move Along Path function in the simulation tab results in errors, but set pointer to path routine in the RAPID tab and selecting Start does work. weird?
I think I'm going to try it with var robtarget offsets and with ConfJ\off function and just use the CONST num X,Y,Z values instead of making a robtarget out of them.
Trying to create robtargets in a script that tries to guess what rotation data to write sounds like a sure-fire way to end up in a lot of problems...
Unless there is a way to copy certain robtarget data from one to another.0 -
Hello,I've made a soft to help in orient data:You can have a look in this module to know hows to transform Euler to Quaternions.0
-
Just a short update here:
Instead of using Python written robtargets, I'm more succesful with a Python written array containing the XYZ values and using those with offsets for replacing pre-existing VAR robtargets.
Doing this is have to turn off ConfJ and ConfL as so the robot can move to those points without saying "Argument Error" with every single mm it moves. This hasn't resulted in trouble yet (but I'm warry of possible problems that might occure).
Short segment of how the working code looks like:EntryPointvar:=Offs(TCP_000,Xvaluetarget,Yvaluetarget,Zvaluetarget);HoverPointvar:=Offs(EntryPointvar,0,0,HoverHeight);
EndPointvar:=Offs(EntryPointvar,0,0,DrillDepth);ConfJ\Off;ConfL\Off;MoveJ HoverPointvar,vmax,fine,Tdrill\WObj:=Object1;WaitTime 0.5;MoveL EntryPointvar,v800,fine,Tdrill\WObj:=Object1;WaitTime 0.5;MoveL EndPointvar,v100,fine,Tdrill\WObj:=Object1;WaitTime 0.5;MoveL HoverPointvar,v500,fine,Tdrill\WObj:=Object1;WaitTime 0.5;ConfJ\On;ConfL\On;
Thank you Lemster, Newman and Denis for the replies! If I later need to do stuff with rotations and quaternions I'll known what to look out for.1
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings