Basic array question.
nezzreth
✭
in RobotStudio
I am trying to figure out how to use arrays.
The manuals are very confusing (for me) about this topic.
As an example, I would like to store some numbers in an array to use for offsetting from a position.
How do I format the syntax to make that happen?
If I wanted to replace row with 5 and column with 2 how do I code that?
The manuals are very confusing (for me) about this topic.
As an example, I would like to store some numbers in an array to use for offsetting from a position.
PERS num nMyArray{2,3}:=[[1,2],[3,4],[5,6]]; CONST robtarget centerpos:=[[-490.16,1517.62,1804.67],[0.262408,-0.265629,-0.646938,0.664872],[1,0,-1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]; PROC main() spraypos:=Offs(centerpos, <b>row</b>*12.7, <b>column</b>*12.7, 0); MoveL spraypos, v400, fine, t_spray; ENDPROCIn the example above, I want to offset the robtarget centerpos by calling the data from the array to replace row and column.
How do I format the syntax to make that happen?
If I wanted to replace row with 5 and column with 2 how do I code that?
Tagged:
0
Best Answer
-
Give this a shot:
MODULE mArrays
PERS num nMyArray{3,2}:=[[1,2],[3,4],[5,6]];
CONST robtarget centerpos:=[[-490.16,1517.62,1804.67],[0.262408,-0.265629,-0.646938,0.664872],[1,0,-1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
VAR robtarget spraypos;
VAR tooldata t_spray;
VAR num row;
VAR num column;
PROC main()
row:=nMyArray{3,1};
column:=nMyArray{3,2};
TPErase;
TPWrite "Row = "+NumToStr(row,0)+" Column = "+NumToStr(column,0);
!spraypos:=Offs(centerpos, row*12.7, column*12.7, 0);
!MoveL spraypos, v400, fine, t_spray;
ENDPROC
ENDMODULE
5
Answers
-
Thank you very much! Most of the mystery has been solved.
Now I just need to figure out how to define and index a 3D array0
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