基础实验 用视觉线索**迷宫

主要通过放在迷宫中的NAOMark标志引导NAO左转或者右转

NAO实验10

NAOMark 64 表示 左转, 84表示 右转,Timer让NAO每隔5秒向前走0.04米

高级任务 **迷宫的正确方法

NAO实验10

其中,Explore maze的代码为:

class MyClass(GeneratedClass):
    def __init__(self):
        GeneratedClass.__init__(self)

    def onLoad(self):
        #put initialization code here
        self.motionProxy = ALProxy("ALMotion")
        self.front = False
        self.rear = False
        self.forwardDist = 0.1 #How far is each cell to walk across in m ?

    def onUnload(self):
        #put clean-up code here
        pass

    def onInput_onStart(self):
        #self.onStopped() #activate the output of the box
        pass

    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

    def onInput_Front(self):
        self.front = True
 
    def onInput_middle(self):
        self.computeNextAction()
        self.front = False
        self.rear = False

    def onInput_rear(self):
        self.rear = True
        
    def computeNextAction():
        if(not self.rear): #no wall to the right
            self.motionProxy.walkTo(0, 0, -1.57) #Turn to the right
            self.motionProxy.walkTo(self.forwardDist, 0, 0)
        elif(self.rear and not self.front): #Wall to the right, no wall in front
            self.motionProxy.walkTo(self.forwardDist, 0, 0)
        else :
            self.motionProxy.walkTo(0, 0, 1.57) #Turn to the left        

 

相关文章:

  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2022-01-12
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
猜你喜欢
  • 2021-11-24
  • 2021-04-20
  • 2021-08-01
  • 2021-07-08
  • 2021-10-07
  • 2021-05-12
  • 2021-09-17
相关资源
相似解决方案