Saving an offset of a robtarget as differently named robtarget.
nezzreth
✭
I know that you can do something like the following:
This way I can name all of my offsets something that is more intuitive and just use them as normal MoveL like this:
p1 := Offs (p1, 5, 10, 15);I want to do something like this:
pNewTarget := Offs (p1, 5, 10, 15);RAPID doesn't let me do this in the header where I declare all my other variables.
This way I can name all of my offsets something that is more intuitive and just use them as normal MoveL like this:
MoveL pNewTarget, v1000, z50, tool1;Instead of having lots of offset instructions which are impossible to tell what they are used for, like my current code:
PROC Debur_Left()
PulseDO\PLength:=0.5, DO9_Debur_Clear;
WaitDI DI8_Unloader_Ready, 1;
Set DO2_Motor_On;
Set DO2_Motor_On;
MoveJ pLeftHighAboveOrigin, v1500, z200, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 31.423, 96.408, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 31.423, 96.408, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 31.423, 96.408, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 87.124, 51.074, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 87.124, 51.074, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 87.124, 51.074, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, -11.226, 44.976, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, -11.226, 44.976, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, -11.226, 44.976, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 72.297, 5.734, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 72.297, 5.734, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 72.297, 5.734, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 0, 0, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 0, 0, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 0, 0, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 129.728, -47.536, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 129.728, -47.536, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 129.728, -47.536, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, -6.188, -69.845, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, -6.188, -69.845, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, -6.188, -69.845, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 34.204, -70.155, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 34.204, -70.155, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 34.204, -70.155, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 20.315, -106.562, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 20.315, -106.562, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 20.315, -106.562, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 68.075, -107.666, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 68.075, -107.666, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 68.075, -107.666, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 21.933, -177.249, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 21.933, -177.249, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 21.933, -177.249, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 102.576, -180.720, nClearanceHeight), v1500, fine, tool0\Wobj:=wLeftCasting;
SearchL \Stop, DI1_Motor, pStopPoint, Offs(pLeftOrigin, 102.576, -180.720, nSearchDistance), v100, tool0\Wobj:=wLeftCasting;
MoveL Offs (pLeftOrigin, 102.576, -180.720, nClearanceHeight), v1500, z50, tool0\Wobj:=wLeftCasting;
RETURN;
ENDPROC
Tagged:
0
Best Answers
-
Try to declare new name of robottarget at the begging of module like below:
VAR robtarget pNewTarget:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
and then in your procedure:
pNewTarget := Offs (p1, 5, 10, 15);
MoveL pNewTarget, v1000, z50, tool1;
5 -
As @IzaR said -- you can't use Offs in the declaration, but you can use Offs to redefine the target in a procedure.
Example:
MODULE mTemp
CONST robtarget p1:=[[-500,1500,1500],[0.262408,-0.265629,-0.646938,0.664872],[1,0,-1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
PERS robtarget pNewTarget0001:=[[0,0,0],[0,0,0,1],[1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
PERS robtarget pNewTarget0002:=[[0,0,0],[0,0,0,1],[1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
PERS robtarget pNewTarget0003:=[[0,0,0],[0,0,0,1],[1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
PROC ApplyOffsets()
pNewTarget0001 := Offs (p1, 15, 10, 15);
pNewTarget0002 := Offs (p1, 25, 20, 25);
pNewTarget0003 := Offs (p1, 35, 30, 35);
ENDPROC
PROC main()
TPErase;
TPWrite ValToStr(pNewTarget0001.trans);
TPWrite ValToStr(pNewTarget0002.trans);
TPWrite ValToStr(pNewTarget0003.trans);
TPWrite "----------------------------------";
ApplyOffsets;
TPWrite ValToStr(pNewTarget0001.trans);
TPWrite ValToStr(pNewTarget0002.trans);
TPWrite ValToStr(pNewTarget0003.trans);
ENDPROC
ENDMODULE
5
Answers
-
Thank you very much for the answers and examples!0
-
When declaring VAR robtargets that I will overwrite later I like to give them a safe default translation value in the off-chance that target should ever get called prior to being assigned a new value. One easy way to do this is to take existing safe targets like a pHome or pService and copying them then renaming them and changing their declaration from CONST to VAR.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