Control NAO with a remote control

When ALInfrared receive a remote control button, it raise an event with every information about it. The event name is InfraRedRemoteKeyReceived.

Every information of the event are also keep in memory.

The event array and the separated data are describe in the following table:

Event / Data Type ALMemory Description
Event array "InfraRedRemoteKeyReceived" Contain the 5 following data
Data string "Device/SubDeviceList/IR/LIRC/Remote/LircCode/Sensor/Value/" LIRC hexa code (LIRC documentation online)
Data int "Device/SubDeviceList/IR/LIRC/Remote/Repeat/Sensor/Value/" Same frame of the button receive in one shot
Data string "Device/SubDeviceList/IR/LIRC/Remote/Key/Sensor/Value/" Name of the button
Data string "Device/SubDeviceList/IR/LIRC/Remote/Remote/Sensor/Value/" Name of the remote (device model)
Data int "Device/SubDeviceList/IR/LIRC/Remote/IrSide/Sensor/Value/" 0 means received on the left eye, 7 means on the right eye.

Python example to receive and display remote buttons event:

from naoqi import * import time # create python module class myModule(ALModule): """python class myModule test auto documentation""" def pythondatachanged(self, strVarName, value, strMessage): """callback when data change""" print "----------------------------------------------------------" print "Data changed on", strVarName, ": ", value, " ", strMessage print "----------------------------------------------------------" broker = ALBroker("pythonBroker","127.0.0.1",9999,"127.0.0.1",9559) # call method try: lirc=ALProxy("ALInfrared") repeatThreshold = 10 eventName = "InfraRedRemoteKeyReceived" lirc.initReception(repeatThreshold) pythonModule = myModule("pythonModule") prox = ALProxy("ALMemory") prox.subscribeToEvent(eventName,"pythonModule", "pythondatachanged") except Exception,e: print "error" print e exit(1) time.sleep(10) exit(0)





Copyright © 2010 Aldebaran-Robotics - All rights reserved