Get robtarget values from array
Hello,
I have multiple robtargets in arrays and a string with the name of the target. How do I go about pulling out the first target from an array?
For example:
I have multiple robtargets in arrays and a string with the name of the target. How do I go about pulling out the first target from an array?
For example:
CONST jointtarget 0614_1550{161} := [
[[-14.724370, 27.791708, 41.837761, 92.336242, 87.393000, -131.890905], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9]],
[[-14.724370, 27.791708, 41.837761, 92.336242, 87.393000, -131.890905], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9]],
[[-14.724370, 27.791708, 41.837761, 92.336242, 87.393000, -131.890905], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9]],
[[-14.724370, 27.791708, 41.837761, 92.336242, 87.393000, -131.890905], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9]],
[[-14.724370, 27.791708, 41.837761, 92.336242, 87.393000, -131.890905], [9E9, 9E9, 9E9, 9E9, 9E9, 9E9]]]
VAR string sCurrentTarget = "0614_1550";
VAR jointtarget jCurrentTarget;
I tried GetDataVal but the command doesn't seem to be able to access data from an array. How do i go about doing this?
VAR string sCurrentTarget = "0614_1550";
VAR jointtarget jCurrentTarget;
I tried GetDataVal but the command doesn't seem to be able to access data from an array. How do i go about doing this?
0
Comments
-
Hello,Variable names are not allowed to start with a number, i.e. the name "0614_1550" is invalid.Generally the prefix "jt" is used for the name of jonttarget, so your array should be named "jt0614_1550"."GetDataVal can read complete arrays, but not single elements.That means you have to define an array into which the data of the source array is copied and both arrays must have the same dimension. If the dimensions are different, a handleable error is generated.Afterwards you can access the content of the array.PROC Example()MoveAbsJ jt0614_1550{1},v1000,z50,tool0;MoveAbsJ GetPosition(1),v1000,z50,tool0;ENDPROCFUNC jointtarget GetPosition(num Index)VAR jointtarget jtTemp{161};GetDataVal "jt"+sCurrentTarget,jtTemp;RETURN jtTemp{Index};ENDFUNC0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings