RobotStudio event

Saving an offset of a robtarget as differently named robtarget.

nezzreth
nezzreth
edited September 2017 in RobotStudio
I know that you can do something like the following:
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;
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

Best Answers

Answers

  • Thank you very much for the answers and examples!
  • 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.