Hi,
You will need at minimum two sensors. Here the routine I use. Notice that some digital inputs used by routine are cross connected somehow with the real sensors used.
About the sensors, ultrasonic sensor works fine with flat glasses and when you just need to find glass. With curved glass you will have lot of problems with ultrasonic sensors. I haven’t try ultrasonic sensor with reorient, so I can’t say will it work (is it accurate enough). I use mechanical contact (sensors) to be sure of accuracy of reorientation.
PROC Reorient()
! Routine: Reorient 3.7.2007
! Modified:
! Routine reorient the gripper
!
VAR bool bDoneOnce:=FALSE;
!
SendMsg(100);
PathResol 25;
! Which tool TCP values to use
IF DiToolSizeMax=1 THEN
! Gripper is in its maximum size
toolDownLeftSen:=ToolLeftMax;
toolDownRghtSen:=ToolRightMax;
ELSEIF DiToolSizeMin=1 THEN
! Gripper is in its minimum size
toolDownLeftSen:=ToolLeftMin;
toolDownRghtSen:=ToolRightMin;
ELSE
! Gripper is in middle size
toolDownLeftSen:=ToolLeftMed;
toolDownRghtSen:=ToolRightMed;
ENDIF
!
! Rotate the gripper so both lower sensors touch the glass
! Witch sensor is touching the glass
bDoneOnce:=FALSE;
WHILE DiDownSensors=0 DO
IF DiSenDownRight=1 AND DiSenDownLeft=0 THEN
! Right one is touching
pCurr:=CRobT(Tool:=toolDownRghtSenWObj:=wobjRack);
SearchLSStop, DiSenDownLeft, pCurr, RelTool(pCurr,0,0,0Rx:=10), vRotSlow, toolDownRghtSenWObj:=wobjRack;
bDoneOnce:=TRUE;
ELSEIF DiSenDownRight=0 AND DiSenDownLeft=1 THEN
! Left one is touching
pCurr:=CRobT(Tool:=toolDownLeftSenWObj:=wobjRack);
SearchLSStop, DiSenDownRight, pCurr, RelTool(pCurr,0,0,0Rx:=-10), vRotSlow, toolDownLeftSenWObj:=wobjRack;
bDoneOnce:=TRUE;
ELSEIF DiSenDownRight=1 AND DiSenDownLeft=1 THEN
! Right and left are touching
pCurr:=CRobT(Tool:=toolDownRghtSenWObj:=wobjRack);
pBack.rot:=pCurr.rot;
bDoneOnce:=TRUE;
ELSE
! We don’t have lower sensors touching the glass
! Search glass, We haven’t yet reorient so search the surface
pCurr:=CRobT(Tool:=ToolGlssDwnEdgeWObj:=wobjRack);
pBack.rot:=pCurr.rot;
SearchLSStop,DiSomeDwnSensor,pCurr,pBack,v20,ToolGlssDwnEdgeWObj:=wobjRack;
bDoneOnce:=FALSE;
ENDIF
!
! If we are done the reoreintation and not have both sensor on glass just push a bit
IF bDoneOnce AND DiDownSensors=0 THEN
! We don’t have lower sensors touching the glass
! Search glass, we already have reorient so just push little bit
pCurr:=CRobT(Tool:=ToolGlssDwnEdgeWObj:=wobjRack);
pBack.rot:=pCurr.rot;
SearchLSStop,DiDownSensors,pCurr,pBack,v20,ToolGlssDwnEdgeWObj:=wobjRack;
ENDIF
ENDWHILE
!
! Should we use also the gripper upper vacuum cup
IF DiUseUpCup=1 THEN
! Rotate the upper sensor to touch the glass
IF DiSenUp=0 THEN
! Get the upper sensor on the glass
WaitTime 0.2;
pCurr:=CRobT(Tool:=ToolGripperWObj:=wobjRack);
SearchLSStop, DiSenUp, pCurr, RelTool(pCurr,0,0,0Ry:=7), vRotSlow, ToolGripperWObj:=wobjRack;
ENDIF
!
! Make sure that all sensors are on glass
IF DiAllSensors=0 THEN
! We don’t have all sensor touching the glass
! Search glass
pCurr:=CRobT(Tool:=ToolGlssDwnEdgeWObj:=wobjRack);
pBack.rot:=pCurr.rot;
SearchLSStop,DiAllSensors,pCurr,pBack,v20,ToolGlssDwnEdgeWObj:=wobjRack;
ENDIF
ELSE
!
! Make sure that both bottom sensors are on glass
IF DiDownSensors=0 THEN
! We don’t have both sensor touching the glass
! Search glass
pCurr:=CRobT(Tool:=ToolGlssDwnEdgeWObj:=wobjRack);
pBack.rot:=pCurr.rot;
SearchLSStop,DiDownSensors,pCurr,pBack,v20,ToolGlssDwnEdgeWObj:=wobjRack;
ENDIF
ENDIF
PathResol 100;
ERROR
IF ERRNO=ERR_WHLSEARCH THEN
! 10 deg angle is not enough - Error
Alarm (100);
VacuumOff;
pCurr:=CRobT(Tool:=ToolGripperWObj:=wobjRack);
MoveL RelTool(pCurr,0,0,-100),v50,z1,ToolGripperWObj:=wobjRack;
bRejectMission:=TRUE;
RETURN;
ENDIF
IF ERRNO=ERR_SIGSUPSEARCH THEN
! Sensor already on
TRYNEXT;
ENDIF
ENDPROC
Regards,
Mika