I want the robot to use 1 camera and move to different locations. Right now it waits for the cameras to take the photo and then resumes. Below I describe the current method which is taking photos with 9 cameras attached to the wall instead of the rob.
We have 3 Kuka robots with Occubot Seat program to test seats.
We need to take photos after N cycles and Kuka provided a method described below:
The method involves 3 files
1. The main file controls the motion and sends keeps count to when is photo time.
2. the main program calls the the second program called Photo_Stop which moves the robot out of the way and waits for photos to finish
3. The 3rd file is tied to the second file. It's the serial communmmgr.scr which reads the information from the RS232 port and writes back when the photo stop is finished.
I'll attach the code below and I have to explain that most of the code comes from one of the manuals. It all depends on the robot being put on a frozen state while taking pictures with one or both of these commands
CREAD(HANDLE_, SR_T, MR_T, TIMEOUT_, OFFSET_, "%S", Str[])
CWRITE(HANDLE_, SW_T, MW_T, "%S", Str[] )
If the robot doesn't get the correct info from the RS232 port then it just stops and waits for a human to take photos.
Since the robot is frozen, I wonder if there's any way to change the code for the the robot to move to different locations (instead of having 3 cameras per seat = 3 * 3 =9) to take the photos with a camera attached to the robot. I still need to send the robot the same data (the number of cycles) and for the robot to send back the same data (everything OK, ).
This is the Photo_Stop.src
&ACCESS RVP2
&REL 175
&PARAM EDITMASK = *
DEF photo_stop(seatNum:IN, Action:IN, numCycles:IN, totalCycles, autoPic)
DECL AFTERPHOTOTYPE Action
INT seatNum, numCycles, totalCycles
BOOL autoPic
CHAR sndString[128]
BOOL bret
BOOL testRun
;FOLD INI;%{PE}%V3.2.0,%MKUKATPBASIS,%CINIT,%VCOMMON,%P
;FOLD BAS INI;%{E}%V3.2.0,%MKUKATPBASIS,%CINIT,%VINIT,%P
GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
INTERRUPT ON 3
BAS (#INITMOV,0 )
;ENDFOLD (BAS INI)
;FOLD USER INI;%{E}%V3.2.0,%MKUKATPUSER,%CINIT,%VINIT,%P
;MAKE YOUR MODIFICATIONS HERE
;ENDFOLD (USER INI)
;ENDFOLD (INI)
testrun = TRUE
cmdString[]="Seat%d_PhotoReady_%s_%d_%d"
IF testrun == FALSE THEN
;*** Location is seat 2 Safety Pt
;FOLD PTP P37 CONT Vel= 50 % PDAT38 Tool[1]:TORSO Base[0];%{PE}%R 4.1.16,%MKUKATPBASIS,%CMOVE,%VPTP,%P eDITED OUT
;ENDFOLD
;*** Move sequencially to safe PHOTO pos
;FOLD PTP P39 CONT Vel= 50 % PDAT40 Tool[1]:TORSO Base[0];%{PE}%R 4.1.16,%MKUKATPBASIS,%CMOVE,%VPTP,%PeEDITED OUT
;ENDFOLD
ENDIF
IF autoPic THEN
;;;; send command to camera
ChannelOpen()
bRet = strclear(sndString[])
offset = 0
IF Action==#STOP_ THEN
SWRITE(sndString[], state, offset, cmdString[], seatNum, "Stop",numCycles,totalCycles)
ELSE
SWRITE(sndString[], state, offset, cmdString[], seatNum, "Cont",numCycles,totalCycles)
ENDIF
ChannelWrite(sndString[])
bRet = strclear(rcvString[])
IF (NOT ChannelRead(rcvString[])) THEN
HALT
ELSE
IF (NOT StrComp(rcvString[], "Resume", #NOT_CASE_SENS)) THEN
HALT
ENDIF
ENDIF
ChannelClose()
IF Action==#STOP_ THEN ; half way. measurements
HALT
ENDIF
ELSE ; manual
; WAIT FOR operator
;*** take KCP into cell !!
;*** ackn all (lower right)
;*** ackn all (lower right)
;*** restart drives (upper right)
;*** press top green run (mid left)
HALT
ENDIF
;*** Return to seat 2 Safety Pt
IF testrun == FALSE THEN
;FOLD PTP P41 CONT Vel= 50 % PDAT42 Tool[1]:TORSO Base[0];%{PE}%R 4.1.16,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P41, 3:C_PTP, 5:50, 7:PDAT42
eDITED OUT
;ENDFOLD
;FOLD PTP P38 CONT Vel= 50 % PDAT39 Tool[1]:TORSO Base[0];%{PE}%R 4.1.16,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P38, 3:C_PTP, 5:50, 7:PDAT39
eDITED OUT
;ENDFOLD
ENDIF
END
Display More
The following is the Serialcommmgr.src and it's pretty much exactly what's in the communcations manual.
&ACCESS RVP12
&REL 21
&PARAM TEMPLATE = C:\KRC\Roboter\Template\ExpertVorgabe
&PARAM EDITMASK = *
DEF serialCommMgr( )
END
GLOBAL DEF ChannelOpen()
COPEN(:SER_3,HANDLE_)
IF (HANDLE_==0) THEN
HALT
ENDIF
END
GLOBAL DEF ChannelWrite(Str[]:IN)
CHAR Str[]
MW_T=#SYNC
MR_T=#ABS
CWRITE(HANDLE_, SW_T, MW_T, "%S", Str[] )
IF (SW_T.RET1<>#CMD_OK) THEN
HALT
ENDIF
END
GLOBAL DEFFCT BOOL ChannelRead(Str[]:OUT)
CHAR Str[]
INT numTries, i, temp
IF readSerialTimeout*60 < TIMEOUT_ THEN
numTries = 1
ELSE
numTries = readSerialTimeout*60/TIMEOUT_
ENDIF
FOR i=1 TO numTries
OFFSET_=0
MW_T=#SYNC
MR_T=#ABS
CREAD(HANDLE_, SR_T, MR_T, TIMEOUT_, OFFSET_, "%S", Str[])
SWITCH SR_T.RET1
CASE #CMD_ABORT
RETURN FALSE
CASE #CMD_OK
RETURN TRUE
CASE #CMD_TIMEOUT
IF i>= numTries THEN
RETURN FALSE
ENDIF
CASE #DATA_OK
RETURN TRUE
CASE #DATA_BLK
RETURN TRUE
CASE #DATA_END
RETURN TRUE
CASE #FMT_ERR
RETURN FALSE
ENDSWITCH
ENDFOR
ENDFCT
GLOBAL DEF ChannelClose()
CCLOSE (HANDLE_, SC_T)
IF(SC_T.RET1<>#CMD_OK) THEN
HALT
ENDIF
END
Display More
And I won't post the controlling program and file because it's too long, but the important thing is only this. When a photo is needed it sends this command:
photo_stop(2, #CONTINUE_, totalCycles2, totalCycles2, stopAtEndTest) |
My question: Can I change the program so that instead of the robot being frozen, it actually moves around the seat to take the necessary photos? The photo program is controlled by a second independent computer which just recieves the command to take photos and the number of cycles to label the photos.