Skip to content

Instantly share code, notes, and snippets.

@CryZe
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CryZe/b93733fc78daaab025d4 to your computer and use it in GitHub Desktop.
Save CryZe/b93733fc78daaab025d4 to your computer and use it in GitHub Desktop.
NAO Classes
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
self.gotInput1 = False
self.gotInput2 = False
def onUnload(self):
pass
def onInput_onInput1(self):
self.gotInput1 = True
if self.gotInput2:
self.onStopped()
def onInput_onInput2(self):
self.gotInput2 = True
if self.gotInput1:
self.onStopped()
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
self.isOpen = False
def onUnload(self):
pass
def onInput_onOpen(self):
self.isOpen = True
def onInput_onInput(self):
if self.isOpen:
self.onStopped()
def onInput_onReset(self):
self.isOpen = False
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
self.detector = ALProxy("ALLandMarkDetection")
self.memory = ALProxy("ALMemory")
self.subscribed = False
self.BIND_PYTHON(self.getName(), "onLandmarkDetected")
def onLoad(self):
self.subscribed = False
def onUnload(self):
if self.subscribed:
self.memory.unsubscribeToEvent("LandmarkDetected", self.getName())
self.detector.unsubscribe("Test_LandMark")
self.subscribed = False
def onLandmarkDetected(self, key, value, message):
self.onFound()
self.onStop()
def onInput_onStart(self):
self.detector.subscribe("Test_LandMark", 500, 1.0)
self.memory.subscribeToEvent("LandmarkDetected", self.getName(), "onLandmarkDetected")
self.subscribed = True
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment