I used AlColorBlobDetection
to detect the green light (I have a toy traffic light which switches colors), however, it looks like my robot tracks the light or white color, but definitely not the green color. I attached the code. I use choreographe.
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
# put initialization code here
pass
def onUnload(self):
# put clean-up code here
pass
def onInput_onStart(self):
motion = ALProxy("ALMotion")
posture = ALProxy("ALRobotPosture")
tracker = ALProxy("ALTracker")
# First, wake up.
motion.wakeUp()
fractionMaxSpeed = 0.8
# Go to posture stand
posture.goToPosture("StandInit", fractionMaxSpeed)
motionProxy = ALProxy("ALColorBlobDetection")
motionProxy.setColor(0,250,0, 200)
eventName = "ALTracker/ColorBlobDetected"
# set mode
mode = "Head"
tracker.setMode(mode)
# Then, start tracker.
tracker.trackEvent(eventName)
print "ALTracker successfully started, now show green color to robot!"
print "Use Ctrl+c to stop this script."
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print
print "Interrupted by user"
print "Stopping..."
# Stop tracker, go to posture Sit.
tracker.stopTracker()
tracker.unregisterAllTargets()
posture.goToPosture("Sit", fractionMaxSpeed)
motion.rest()
print "ALTracker stopped."
def onInput_onStop(self):
self.onUnload() # it is recommended to reuse the clean-up as the box is stopped
self.onStopped() # activate the output of the box