1

我想用 C# 用遥控器控制一个 NAO 机器人。Aldebaran 网站上只有一个 Python 示例。不幸的是,我没有学过 Python。谁能帮我把这个 Python 示例转换成 C#?以下链接可能对您有所帮助。 https://community.aldebaran-robotics.com/doc/1-14/naoqi/sensors/alinfrared-tuto.html#alinfrared-tuto https://community.aldebaran-robotics.com/doc/1-14/naoqi /sensors/alinfrared-api.html

# -*- encoding: UTF-8 -*-

"""
Receive and display remote buttons event:
"""
import naoqi
import time

# create python module
class myModule(naoqi.ALModule):

    def pythondatachanged(self, strVarName, value, strMessage):
        """callback when data change"""
        print "Data changed on", strVarName, ": ", value, " ", strMessage

# call method
try:
    lircProxy = naoqi.ALProxy("ALInfrared")
    lircProxy.initReception(repeatThreshold = 10)
    pythonModule = myModule("pythonModule")
    memProxy = naoqi.ALProxy("ALMemory")
    memProxy.subscribeToEvent("InfraRedRemoteKeyReceived", "pythonModule",
             "pythondatachanged")
except Exception, e:
    print "error"
    print e
    exit(1)
time.sleep(10)
exit(0)
4

0 回答 0