I am fairly new to Visual Components and try to place parts on moving objects on a conveyor belt. However, sometimes the object on which the parts are placed stops even though the conveyor belt has not stopped. After it has been equipped the part starts to move again. The code I use for the robots is enclosed:
A robot picks 3 parts from the input conveyor, then looks for object on the conveyor part without any children and places the three parts on the object.
There occurs no error while the simulation is running, the object just stops moving while being handled. Does anyone know how to fix this issue?
Thanks in advance!
from vcScript import * from vcHelpers.Robot2 import * def getPositionClip(zaehler, seat): mtx = vcMatrix.new() zaehler = zaehler + 1 frame = seat.findFeature('Position_%i' % zaehler) mtx = frame.FramePositionMatrix if zaehler < 3: mtx.rotateRelY(240) else: mtx.rotateRelY(180) mtx.translateRel(0,0,-100) return mtx def OnRun(): app = getApplication() robot = getRobot() conveyorIn = app.findComponent("Sensor Conveyor #1") conveyorOut = app.findComponent("Conveyor #2") path = conveyorOut.findBehaviour("Path__HIDE__") #Clip positions UC1 mtx_1 = vcMatrix.new() mtx_2 = vcMatrix.new() mtx_3 = vcMatrix.new() mtx = [mtx_1, mtx_2, mtx_3] zaehler = 0 #while simulation is running while app.Simulation.IsRunning: #pick parts while robot.SignalMapIn.input(100) != True: delay(0.1) while conveyorIn.ComponentChildren: part = conveyorIn.ComponentChildren robot.pick(part) robot.callSubRoutine("MoveToHome") #Choose seat in range seats = path.Components num = 0 for seat in reversed(seats): distance = seat.getPathDistance() #print seat.getPathDistance() num = num + 1 if distance < 1500 and distance > 500: if seat.Children == : break #place parts zaehler = 0 robot.SignalMapOut.output(100,True) while zaehler < 3: mtx[zaehler] = getPositionClip(zaehler, seat) try: # here the object on the conveyor randomly stops #delay(0.05) robot.linearMoveToMtx_ExternalBase(seat,mtx[zaehler]) robot.releaseComponent(seat) robot.moveAway(50) zaehler = zaehler + 1 except: e = sys.exc_info() print e robot.callSubRoutine("MoveToHome")