I have a Scribbler robot that I would like to perform the following particular task. When placed in a rectangular arena of 5*3 sheets of paper, it must find the one yellow sheet and then stop next to it and beep. There are 9 white sheets, 3 blue, 3 green and 1 yellow. I have two different programs I have written below but I'm not sure how to properly merge them together. The first program is designed to detect yellow and the second program is designed to keep the robot moving around an arena without hitting any walls and turning around once it gets close enough. I know both work independently but I want to merge them such that it will avoid detecting walls and once it sees the yellow sheet of paper it will stop in front and the program will end. Any ideas? Thanks in advanced! Here is my code for the detect yellow program:
def TreasureHunt(): #This program detects yellow
Wall=takePicture()
for pixel in getPixels(Wall):
r,g,b = getRGB(pixel)
if (r>=200 and g>=200): #my criteria for yellow. if yellow turn white
setRGB(pixel, (255,255,255))
else: #if not yellow turn black
setRGB(pixel, (0,0,0))
show(Wall)
Here is the avoid obstacle program:
def goout():
while getObstacle(1) <= 6399: #starts moving with 6400 IR detection
motors(1,1)
getObstacle(1) #checks for obstacle if none found, continues moving and checking
else: #if obstacle is found
stop()
while getObstacle(1) >=6399: #Scans again if osbstacle detected
motors (-1,1) #Rotates robot to scan
getObstacle(1) #Scans
while getObstacle(1) >=6399: #Scans again if obstacle detected
motors (1,-1) #Rotates robot to scan other direction
getObstacle(1) #Scans
else:
motors(1,1) #Continues back straight again
goout() #Restarts entire function