def findTape(): link.camera_update() if link.get_object_area(c.chanPink, 0) >= c.blobSize: tape = 1 else: tape = 0 return tape
def lookForGreen() : print "cameraTrack" link.camera_update() time.sleep (0.5) #$#################### print "waiting until we see something" for i in range(15): print "i: ", i greenArea = link.get_object_area( c.chanGreen, 0 ) redArea = link.get_object_area( c.chanRed, 0 ) print "green: ", greenArea print "red: ", redArea if greenArea > c.blobSize: break elif redArea > c.blobSize: break link.camera_update() time.sleep( 0.02 ) ###################### if link.get_object_area( c.chanGreen, 0 ) >= c.blobSize: print "green" print link.get_object_area( c.chanGreen, 0 ) return True print "green not seen" return False
def findTape(): link.camera_update() if link.get_object_area( c.chanPink, 0 ) >= c.blobSize: tape = 1 else: tape = 0 return tape
def getCoordinateOfFoamBall(pingPongBallNumber): """Returns the coordinate of the biggest red ball the camera sees""" camera_update() sleep(.1) x = get_object_center_x(CHANNEL_GREEN,pingPongBallNumber) y = get_object_center_y(CHANNEL_GREEN,pingPongBallNumber) cood = Coordinate(x,y) return cood
def sortTribble() : print "sortTribble" link.camera_update() time.sleep(.15) link.camera_update() print "camera updated" found = 1 if link.get_object_area( c.chanGreen, 0 ) >= c.blobSize: print "green, y=", link.get_object_center_y(c.chanGreen, 0) if link.get_object_center_y(c.chanGreen, 0) >= 90: drive.withStop(30, 30, .5) link.camera_update() print "*******new y=", link.get_object_center_y(c.chanGreen, 0) #act.DEBUG("bad green alignment")\ print link.get_object_area( c.chanGreen, 0 ) print "moveSorter" sortAndKick( c.sorterLeft) elif link.get_object_area(c.chanRed, 0 ) >= c.blobSize or link.get_object_area(c.chanGold, 0 ) >= c.blobSize: print "red/gold" print "red, y=", link.get_object_center_y(c.chanRed, 0) if link.get_object_center_y(c.chanRed, 0) >= 90: drive.withStop(30, 30, .5) link.camera_update() print "*******new y=", link.get_object_center_y(c.chanRed, 0) print link.get_object_area( c.chanRed, 0 ) print "moveSorter" sortAndKick( c.sorterRight) else: print "nothing found" found = 0 return found
def sortTribble(): print "sortTribble" link.camera_update() time.sleep(.15) link.camera_update() print "camera updated" found = 1 if link.get_object_area(c.chanGreen, 0) >= c.blobSize: print "green, y=", link.get_object_center_y(c.chanGreen, 0) if link.get_object_center_y(c.chanGreen, 0) >= 90: drive.withStop(30, 30, .5) link.camera_update() print "*******new y=", link.get_object_center_y(c.chanGreen, 0) #act.DEBUG("bad green alignment")\ print link.get_object_area(c.chanGreen, 0) print "moveSorter" sortAndKick(c.sorterLeft) elif link.get_object_area(c.chanRed, 0) >= c.blobSize or link.get_object_area( c.chanGold, 0) >= c.blobSize: print "red/gold" print "red, y=", link.get_object_center_y(c.chanRed, 0) if link.get_object_center_y(c.chanRed, 0) >= 90: drive.withStop(30, 30, .5) link.camera_update() print "*******new y=", link.get_object_center_y(c.chanRed, 0) print link.get_object_area(c.chanRed, 0) print "moveSorter" sortAndKick(c.sorterRight) else: print "nothing found" found = 0 return found
def testCamera(): servo.moveShutter(c.shutterOpen) for i in range(5): link.camera_update() area = link.get_object_area(c.chanRed, 0) print i, area
def cameraTest(): print "testing camera" link.camera_update() time.sleep(.1) link.camera_update()
def takePicture(): link.camera_update()
def camTakePicture(): link.camera_update()
def getNumVisibleFoamBalls(): """Returns the number of red balls in the camera's frame""" camera_update() count = get_object_count(CHANNEL_RED); return count