Exemplo n.º 1
0
 def getpercepts(self, beliefbase):
     dist = pi2go.getDistance()
     beliefbase['distance'] = dist
     irR = pi2go.irRight()
     beliefbase['obstacle_right'] = irR
     irL = pi2go.irLeft()
     beliefbase['obstacle_left'] = irL
     irC = pi2go.irCentre()
     beliefbase['obstacle_centre'] = irC
     irLL = pi2go.irLeftLine()
     beliefbase['line_left'] = irLL
     irRL = pi2go.irRightLine()
     beliefbase['line_right'] = irRL
     switch = pi2go.getSwitch()
     beliefbase['switch_pressed']= switch
     lightFL = pi2go.getLightFL()
     beliefbase['lightFL'] = lightFL
     lightFR = pi2go.getLightFR()
     beliefbase['lightFR'] = lightFR
     lightBL = pi2go.getLightBL()
     beliefbase['lightBL'] = lightBL
     lightBR = pi2go.getLightBR()
     beliefbase['lightBR'] = lightBR
     super()
     return
Exemplo n.º 2
0
 def getpercepts(self, beliefbase):
     dist = 50
     beliefbase['distance'] = dist
     irR = robohat.irRight()
     beliefbase['obstacle_right'] = irR
     irL = robohat.irLeft()
     beliefbase['obstacle_left'] = irL
     irLL = robohat.irLeftLine()
     beliefbase['no_line_left'] = irLL
     irRL = robohat.irRightLine()
     beliefbase['no_line_right'] = irRL
     super()
     return
Exemplo n.º 3
0
 def getpercepts(self, beliefbase):
     dist = initio.getDistance()
     beliefbase['distance'] = dist
     irR = initio.irRight()
     beliefbase['obstacle_right'] = irR
     irL = initio.irLeft()
     beliefbase['obstacle_left'] = irL
     irLL = initio.irLeftLine()
     beliefbase['line_left'] = irLL
     irRL = initio.irRightLine()
     beliefbase['line_right'] = irRL
     super()
     return
Exemplo n.º 4
0
import simclient.simrobot as initio
import time

speed = 20
turn_speed = 10

initio.init()

# main loop
try:
    while True:
        if initio.irLeftLine():
            initio.turnForward(speed - turn_speed, speed + turn_speed)
            time.sleep(0.1)
        elif initio.irRightLine():
            initio.turnForward(speed + turn_speed, speed - turn_speed)
            time.sleep(0.1)
        else:
            initio.forward(speed)

except KeyboardInterrupt:
    initio.cleanup()