CS 484 - Artificial Intelligence
Fall 2007


Loyola College > Department of Computer Science > CS 484 > Labs & Projects > Lab 2

Due

Thursday, September 27th at the beginning of class.
Lab will be penalized 20% for each class meeting after the due date.

CONTENTS


INTRODUCTION

For this lab you may work in pairs to learn how to control robots through Pyro. You will create a wall following brain for a simulated Pioneer robot. On October 2nd, you'll get to test these brains on the real Pioneer robot and see how well they transfer from simulation to reality.


LAB INSTRUCTIONS

ul>

  • There is a collection of materials available online to help you learn how to control robots with Pyro. Read through the Pyro introduction and focus on the subsections dealing with morphology, effectors, the Pyro interface, sensors, and brains.

  • Start the Pyro GUI and load the Pyro simulator with the Tutorial.py. Select the PyrobotRobot60000.py robot. (Each pair needs to work on a different machine). Copy the following avoid obstacles brain to your home directory and then load it into Pyro as the current brain. This uses a very simple strategy to try to wander around the environment and avoid obstacles. If it manages to enter the smaller room, it tends to get stuck there. Try to improve this brain so that the robot can more effectively explore the entire environment without getting stuck. Every time you update the brain, press the Reload button in the Pyro GUI.
    #File: Avoid.py
    from pyrobot.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 = min([s.distance() for s in self.robot.range["left-front"]])
          fright = min([s.distance() for s in self.robot.range["right-front"]])
          front = min([s.distance() for s in self.robot.range["front"]])
    
          if (front < Ftolerance):
             print "obstacle front"
             self.robot.move(0, 0.2)
          elif (fright < FRtolerance):
             print "obstacle right"
             self.robot.move(0, .2)
          elif (fleft < FLtolerance):
             print "obstacle left"
             self.robot.move(0, -.2)
          else:
             print "clear"
             self.robot.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)
    
  • Now try to create a wall following brain. Ideally we'd like the robot to be able to follow the walls around the entire environment into the small room and back out again. We'd also like the robot to follow as close to the wall as possible without getting stuck. If the robot loses the wall we'd like it to try to recapture the wall as quickly as possible.
  • Once your wall following brain is complete, be sure to include a clear explanation of your stragegy in a comment at the top of the file.

    HAND IN

    Email me your robot brain file. Make sure that the file contains both names in it.
    Turn in a print out in class.