Getting a proxy to ALVisionRecognition
After some initialization steps, we first instantiate a proxy to the ALVisionRecognition module.
This test demonstrates how to use the ALVisionRecognition module.
Note: | You might not have this module depending on your distribution. |
---|
- We instantiate a proxy to the ALVisionRecognition module.
The module output its results in ALMemory in a variable called "PictureDetected".Note: this module should be loaded on the robot's NAOqi.
- We read this AlMemory value and check whether or not we get interesting things.
import os import sys import time import naoqi from naoqi import * period = 1000 moduleName = "Python_Reco" IP = "nao.local" # Replace here with your NAOqi's IP address PORT = 9559 # Create a proxy to ALVisionRecognition try: recoProxy = ALProxy("ALVisionRecognition", IP, PORT) except RuntimeError,e: print "Error when creating ALVisionRecognition proxy:" exit(1) # Subscribe to the ALVisionRecognition proxy # This means that the module will write in memValue with # the given period below. try: recoProxy.subscribe(moduleName, period, 0.0 ) except RuntimeError,e: print "Error when subscribing to ALVisionRecognition" exit(1) # Let it run for 30 seconds time.sleep(30) # Unsubscribe from the ALVisionRecognition proxy try: recoProxy.unsubscribe(moduleName) except RuntimeError,e: print "Error when unsubscribing from ALVisionRecognition" exit(1)