Robtarget Manipulations / Calculations v.s Pos
Morning all,
Im trying to perform calculations/Frame offsets ect as follows and im missing something in the syntax.. Error im getting is Type mismatch robtarget found type Pos.. thanks in advance for the assistance
******************************CODE***************************
PROC AppPark()bPathFound:=FALSE;
temp_wobj:=CWObj();
temp_tool:=CTool();
pAppTc:=pApproTChanger.trans;
pAppSafePark:=pApproSafePark.trans;
pSafePark:=plocSafePark.trans;
pAppWelder:=pApproWelder.trans;
pWelder:=pLocPtWelder.trans;
pAppLHTABLE:=pApproLHTable.trans;
pAppRHTABLE:=pApproRHTable.trans;
pAppDOOR:=pApproDoor.trans;
pDOOR:=pLocPtDoor.trans;
pAppScrap:=pApproScrap.trans;
pos_act:=CPos(Tool:=temp_toolWObj:=temp_wobj);
TPErase;
TPWrite "Pos_Act.X="NUM:=pos_act.X;
TPWrite "Pos_Act.Y="NUM:=pos_act.Y;
IF (distance(pos_act,pAppSafePark)=0) or (distance(pos_act,pSafePark)=0) AND bPathFound=False THEN
bpathfound:=TRUE;
ENDIF
IF distance(pos_act,pAppTc)=0 AND bPathFound=False THEN
TPWrite " Moving From TC Approach";
pTempPoint:=pApproTChanger;
pTempPoint.Trans.Z:=nSafeZ;
MoveL pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproTChanger);
MoveJ pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproSafePark);
MoveJ pTempPoint,v1000,fine,temp_tool;
MoveJ pApproSafePark,v1000,fine,temp_tool;
bpathfound:=TRUE;
ENDIF
IF distance(pos_act,pAppWelder)=0 AND bPathFound=False THEN
TPWrite " Moving From Welder Approach";
pTempPoint:=pApproWelder;
pTempPoint.Trans.Z:=nSafeZ;
MoveL pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproWelder);
MoveJ pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproSafePark);
MoveJ pTempPoint,v1000,fine,temp_tool;
MoveJ pApproSafePark,v1000,fine,temp_tool;
bpathfound:=TRUE;
ENDIF
IF (distance(pos_act,pApproLHTable)=0)AND bPathFound=False THEN
TPWrite " Moving From LH Table Approach";
pTempPoint:=pApproLHTable;
pTempPoint.Trans.Z:=nSafeZ;
MoveL pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproLHTable);
MoveJ pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproSafePark);
MoveJ pTempPoint,v1000,fine,temp_tool;
MoveJ pApproSafePark,v1000,fine,temp_tool;
bpathfound:=TRUE;
ENDIF
IF (distance(pos_act,pApproRHTable)=0)AND bPathFound=False THEN
TPWrite " Moving From RH Table Approach";
pTempPoint:=pApproRHTable;
pTempPoint.Trans.Z:=nSafeZ;
MoveL pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproRHTable);
MoveJ pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproSafePark);
MoveJ pTempPoint,v1000,fine,temp_tool;
MoveJ pApproSafePark,v1000,fine,temp_tool;
bpathfound:=TRUE;
ENDIF
IF (distance(pos_act,pApproDoor)=0) or (distance(pos_act,pDoor)=0) AND bPathFound=False THEN
TPWrite " Moving From RH Table Approach";
pTempPoint:=pApproDoor;
pTempPoint.Trans.Z:=nSafeZ;
MoveL pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproDoor);
MoveJ pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproSafePark);
MoveJ pTempPoint,v1000,fine,temp_tool;
MoveJ pApproSafePark,v1000,fine,temp_tool;
bpathfound:=TRUE;
ENDIF
IF (distance(pos_act,pAppScrap)=0) AND bPathFound=False THEN
TPWrite " Moving From Welder Approach";
pTempPoint:=pApproScrap;
pTempPoint.Trans.Z:=nSafeZ;
MoveL pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproScrap);
MoveJ pTempPoint,v1000,fine,temp_tool;
pTempPoint:=CalcSafePoint(pApproSafePark);
MoveJ pTempPoint,v1000,fine,temp_tool;
MoveJ pApproSafePark,v1000,fine,temp_tool;
bpathfound:=TRUE;
ENDIF
IF bPathFound=False THEN
!Current position is not a predefined approach point
bApproSuccess:=FALSE;
ELSE
!Current position was found
bApproSuccess:=TRUE;
ENDIF
RETURN;
ENDPROCFUNC POS CalcSafePoint(robtarget pStart)
!Return point at SafeRadius and SafeZ towards the robot center
!Define Zero
pZeroPoint:=pZero;
!Find radius
!equalize the Z component
pZeroPoint.Trans.Z:=pStart.Trans.Z;
!Now calculate the starting radius
nRadius:=distance(pStart.Trans,pZeroPoint.Trans);
pReturn:=pZero;
IF nRadius<nSafeRadius THEN
!Safe to move without retracting
pZeroPoint.Z:=pStart.Trans.Z;
pReturn.Trans.X:=pStart.Trans.X;
pReturn.Trans.Y:=pStart.Trans.Y;
pReturn.Trans.Z:=nSafeZ;
ELSE
!retract to nSafeRadius
pZeroPoint.Z:=pStart.Z;
pReturn.Trans.Z:=nSafeZ;
pReturn.Trans.X:=pStart.Trans.X*(nSafeRadius/distance(pStart.TRANS,pZeroPoint.Trans));
pReturn.Trans.Y:=pStart.Trans.Y*(nSafeRadius/distance(pStart.TRANS,pZeroPoint.Trans));
ENDIF
RETURN pReturn;
ENDFUNC
0
Categories
- All Categories
- 5.5K RobotStudio
- 395 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 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