CS 372 (Artificial Intelligence) Fall 2004 Robot Lab: Exercise 1
Stimulus response Agents: Bump-N-Grind
In this exercise we will design an SR agent capable of bumping around its environment. The agent has a bunch of bump sensors that can sense if the robot has bumped into something in its environment. By sensing these bumps the agent has to manouvre around objects and keep moving (durative behavior). Imagine if you entered a pitch dark room and had to move about in it. This behavior is similar.
You will implement this behavior in Pyro using the Stage Simulator using the tutorial.world with a simulated Pioneer robot (connect through Player6665). The robot has five bump sensors arranged in an arc around one end of the robot. The following simple algorithm is suggested:
if left bump then back up a little and turn right, go forward else if right bump then back up a little and turn left, go forward else if front bump then back up a little, turn left or right a little, go forward else go forward
Doing something for a short while can be achieved by using the sleep command:
# go backward sleep(0.5) # do something else
That is, start going backward, do that for 0.5 seconds, and then do something else. The sleep command is available in the standard Python library time (time.sleep(...)). You will need to adjust the amount of turns and the amount of sleep to get seemingly robust behaviors.
Start by implemnting the above algorithm and observe the behavior of the robot for several different runs. Then answer the following questions:
-
How would you characterize the robot's behavior?
-
Does it seem robust? Try the behaviors by placing the robot in different parts of the environment.
-
How well does it deal with corners? Try sending the robot diagonally into a corner a few times. Was the robot able to negotiate itself out of the corner? If not, think about how you could improve the brain program and implement it. Describe your solution.
-
Show the behavior to some of your friends (or others in the lab who are not in the class). Ask them to describe the robot's behavior (do not tell them what your algorithm or task is). Write down their description(s).
Hand in a written report with your answers to the questions above. Also, attach a printout of your brain program and a short discussion of your own on your overall experience.
Comments and Questions
-
Q1: I used from pyrobot.brain import Brain to start my Python document. The command mentioned in class (pyrobot.brain.Brain) didn't work for me. -- AndrewCantino
A1: You'll have to supply more detail. What error did you get? What did you type exactly? What computer were you on? What simulator/robot? -- Doug
Q2: The bumper sensor does not always detect a collision. Stall=1 but the bumper data is (0,0,0,0,0). --Ioana
A2: Stall is different from a bumper hit. Stall indicates that the motors are trying to move, but sensors in the motors tell us that they aren't moving. A2a: Yes, the robot may be stalled and it may appear as though one or more bumpers ought to register a hit, but that is not always guaranteed. Such is life, even though simulations are doomed to succeed. This happens all the time on real robots as well. However, detecting the stall is another way to account for serious bumps! --Deepak
Q3:I also experienced the same problem as Andrew. The error was:
Attempting to import 'ibSRbrain'...
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/src/build/394694-i386/install/usr/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
File "/usr/local/pyrobot/gui/__init__.py", line 280, in loadBrain
self.engine.loadBrain(f)
File "/usr/local/pyrobot/engine/__init__.py", line 163, in loadBrain
self.brain = system.loadINIT(file, self)
File "/usr/local/pyrobot/system/__init__.py", line 76, in loadINIT
exec("import " + module + " as userspace")
File "<string>", line 1, in ?
File "/home/ibutoi/AI/Hw1/ibSRbrain.py", line 7, in ?
from pyrobot.brain.Brain import *
ImportError: No module named Brain
-
A3: In the brain file I had from pyrobot.brain.Brain import * . Now I have from pyrobot.brain import * and it works. I ssh into pdp8. I used Stage simulator, and the simulated robot Player6665. --Ioana
