In this lab you will learn how to control robots through Pyro. You will create a wall following brain for a simulated Pioneer robot. Next week we'll test these brains on the real Pioneer robot and see how well they transfer from simulation to reality.
#File: Avoid.py from pyro.brain import Brain class AvoidBrain(Brain): # Only method you have to define is the step method: def step(self): Ftolerance = 1.0 FLtolerance = 1.0 FRtolerance = 1.0 fleft = self.getRobot().get('range', 'value', 'front-left', 'min')[1] fright = self.getRobot().get('range', 'value', 'front-right', 'min')[1] front = self.getRobot().get('range', 'value', 'front', 'min')[1] if (front < Ftolerance): print "obstacle front" self.getRobot().move(0, 0.2) elif (fright < FRtolerance): print "obstacle right" self.getRobot().move(0, .2) elif (fleft < FLtolerance): print "obstacle left" self.getRobot().move(0, -.2) else: print "clear" self.getRobot().move(0.2, 0) # ------------------------------------------------------- # This is the interface for calling from the gui engine. # Takes one param (the robot), and returns a Brain object: # ------------------------------------------------------- def INIT(engine): return AvoidBrain('AvoidBrain', engine)
Use cs63handin to turn in your wall following brain.