using arrays and for loops
Afternoon,
I am familiarising myself with Arrays for the first time and was wondering if anyone had a tidy way to solve the following issue;
I am populating an array with robtargets so that the robot can plot a path back to a home position. However depending on the position the robots has to navigate home from the array is not always entirely populated.
when I run my final bit of code:
Obviously I get an error when the array is not entirely populated.
Is there a function to either ignore items in an array without any value? or failing this, rather than declaring my array as:
VAR Robtarget HomePath{10};
Could could i make the declaration of how many items are in the list variable so there is only ever the amount of items in the Array that the robot needs to navigate home?
Thanks in advance
I am familiarising myself with Arrays for the first time and was wondering if anyone had a tidy way to solve the following issue;
I am populating an array with robtargets so that the robot can plot a path back to a home position. However depending on the position the robots has to navigate home from the array is not always entirely populated.
when I run my final bit of code:
FOR i FROM 1 TO DIM(aHomePath,1) DO
MoveL aHomePath{i},v100,fine,tool0;
WaitUntil\InPos, TRUE;
ENDFOR
Obviously I get an error when the array is not entirely populated.
Is there a function to either ignore items in an array without any value? or failing this, rather than declaring my array as:
VAR Robtarget HomePath{10};
Could could i make the declaration of how many items are in the list variable so there is only ever the amount of items in the Array that the robot needs to navigate home?
Thanks in advance
Tagged:
0
Answers
-
This could work:
FOR i FROM 1 TO DIM(aHomePath,1) DO IF aHomePath{i}.trans <> [0,0,0] THEN MoveL aHomePath{i},v100,fine,tool0; WaitUntil\InPos, TRUE; ENDIF ENDFOR
If the robtarget is empty, it will be ignored.
Make the array the maximum size you will need, you can't edit array sizes during runtime.
Systemintegrator - Web / C# / Rapid / Robotstudio
If I helped, please press Vote Up
☑️2024 - RobotStudio® User Group1 -
Thanks for your time and appreciate the advice
I had thought of something similar, I was just interested to see if their was a more efficient way.
Not that it matters as this is a working solution, but if the array was declared as size {20} and only 2 positions were required to safely navigate home this causes a small delay whilst in the FOR loop.0 -
You can put the forloop in a separate proc and return when you find the first empty robtarget.Systemintegrator - Web / C# / Rapid / Robotstudio
If I helped, please press Vote Up
☑️2024 - RobotStudio® User Group1 -
I've had the same thing before with storing information about unknown quantities, I usually store the index of the last item in the array so I know when I hit that index it will finish. I also find that useful because I can view that value in program data or remotely and see what the current index is and the final index as opposed to having to look at the array and figure out how many iterations are left. This is for dealing with large fillet welds up to ~90 passes, it might not be useful in your application to see that.
Good Luck.
1 -
Hi...This is a very pertinent 'dynamic array' question.I share a possible solution if there is still a need.
MODULE Testing ! Program 1 PROC PRG1() VAR Robtarget HomePath{10}; ! Move at HOME ... RobotHome HomePath; ENDPROC ! Program 2 PROC PRG2() VAR Robtarget HomePath{2}; ! Move at HOME ...<br> RobotHome HomePath; ENDPROC ! Program 3 PROC PRG3() VAR Robtarget HomePath1; VAR Robtarget HomePath2; VAR Robtarget HomePath3; ! Move at HOME ...<br> RobotHome [HomePath1,HomePath2,HomePath3]; ENDPROC ! Return at HOME PROC RobotHome(robtarget P_PathsP{*}) FOR id FROM 1 TO Dim(P_PathsP,1) DO MoveJ P_PathsP{id},v100,z50,tool0; ENDFOR ERROR TPErase; TEST ERROR CASE ERR_OVERFLOW: ErrWrite "ERR_OVERFLOW","" \RL2:="Time memory overflow." \RL3:="Time measurements have been reset and the counter has been stopped." \RL4:="After restarting, the error counters will be restarted."; Stop; Stop; EXIT; DEFAULT: ErrWrite "NOT TREATED","Heating path - incorrect" \RL2:="Error not handled by the system. Please contact the automation team."; ENDTEST ENDPROC ENDMODULE
Good works.0
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)
- 798 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings